-
Notifications
You must be signed in to change notification settings - Fork 10
173 lines (147 loc) · 5.63 KB
/
Copy pathtest.yml
File metadata and controls
173 lines (147 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: test
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: checkout plugin
uses: actions/checkout@v4
with:
path: tauri-plugin-python
# TEMP: the plugin's Cargo.toml has `[patch.crates-io] async_py = { path = "../async_py" }`
# until async_py 0.3.2 is published to crates.io. Remove this step (and the patch) afterwards.
- name: checkout async_py (local patch source)
uses: actions/checkout@v4
with:
repository: marcomq/async_py
path: async_py
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: tauri-plugin-python
- name: install dependencies (ubuntu)
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: rustfmt
working-directory: tauri-plugin-python
run: cargo fmt --all --check
- name: clippy (pyo3 / default)
working-directory: tauri-plugin-python
run: cargo clippy --all-targets -- -D warnings
- name: clippy (rustpython)
working-directory: tauri-plugin-python
run: cargo clippy --no-default-features --features rustpython --all-targets -- -D warnings
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
backend: [pyo3, rustpython]
runs-on: ${{ matrix.os }}
steps:
- name: checkout plugin
uses: actions/checkout@v4
with:
path: tauri-plugin-python
# TEMP: see note in the `lint` job. Remove once async_py 0.3.2 is on crates.io.
- name: checkout async_py (local patch source)
uses: actions/checkout@v4
with:
repository: marcomq/async_py
path: async_py
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: tauri-plugin-python
key: ${{ matrix.backend }}
- name: install dependencies (ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# PyO3 embeds CPython, so a Python interpreter must be available to build & run.
- name: setup python
if: matrix.backend == 'pyo3'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: test (pyo3 / default)
if: matrix.backend == 'pyo3'
working-directory: tauri-plugin-python
run: cargo test --all-targets
# RustPython needs no Python installed; run it single-threaded (each test
# spins up a full embedded interpreter on a large-stack worker thread).
- name: test (rustpython)
if: matrix.backend == 'rustpython'
working-directory: tauri-plugin-python
run: cargo test --no-default-features --features rustpython -- --test-threads=1
# Deployment-recipe smoke test: build the plain-javascript example as a real
# release bundle and verify the Python sources actually ship as tauri
# resources (the #1 "works in dev, not in prod" failure). Uses the default
# PyO3 backend and the *local* plugin (the example depends on it via path).
example-bundle:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: examples/plain-javascript
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: examples/plain-javascript/src-tauri
# PyO3 links CPython, so a Python interpreter must be present to build & run.
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: install dependencies (ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: install frontend dependencies
run: npm install
- name: build example (release bundle)
run: npm run tauri build
- name: verify Python sources are bundled
run: python verify_bundle.py src-tauri/target
# Best-effort startup check (Linux only - GUI apps need a display). If the
# bundled binary starts and stays alive, Python initialized without
# panicking on startup. The plugin `.expect()`s during init, so a missing
# main.py / broken interpreter would crash the process immediately.
- name: smoke-launch the built binary (linux)
if: matrix.os == 'ubuntu-22.04'
working-directory: examples/plain-javascript/src-tauri
run: |
sudo apt-get install -y xvfb
BIN=$(find target/release -maxdepth 1 -type f -perm -u+x ! -name '*.so' | head -n1)
echo "Launching: $BIN"
xvfb-run -a "$BIN" &
PID=$!
sleep 8
if kill -0 "$PID" 2>/dev/null; then
echo "OK: app still running after startup - Python initialized without crashing."
kill "$PID" 2>/dev/null || true
else
echo "FAIL: app exited during startup (Python init likely panicked)."
exit 1
fi