-
Notifications
You must be signed in to change notification settings - Fork 2
426 lines (363 loc) · 14.4 KB
/
Copy pathci.yml
File metadata and controls
426 lines (363 loc) · 14.4 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
flatpak_runtime_smoke:
description: Run the experimental Flatpak PipeWire routing smoke test
type: boolean
default: false
smoke_only:
description: Skip ordinary CI work and run only the requested experimental smoke job
type: boolean
default: false
flatpak_runtime_build:
description: Build and reinstall the local Flatpak before the runtime smoke test
type: boolean
default: true
flatpak_runtime_install_remote:
description: Install the smoke target from Flathub instead of using a local build
type: boolean
default: false
flatpak_runtime_app_ref:
description: Optional Flatpak app ref to run; blank infers the build or install ref
type: string
default: ""
flatpak_runtime_install_ref:
description: Flathub ref to install when flatpak_runtime_install_remote is enabled
type: string
default: io.github.bhack.mini-eq
flatpak_runtime_expected_version:
description: Optional installed Flatpak version expected by the runtime smoke test
type: string
default: ""
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-24.04
outputs:
flatpak: ${{ steps.filter.outputs.flatpak }}
test: ${{ steps.filter.outputs.test }}
tooling: ${{ steps.filter.outputs.tooling }}
pwg: ${{ steps.filter.outputs.pwg }}
steps:
- name: Detect changed files
id: filter
env:
BEFORE: ${{ github.event.before }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
SMOKE_ONLY: ${{ inputs.smoke_only }}
run: |
set -euo pipefail
files="$(mktemp)"
set_all() {
{
echo "test=true"
echo "tooling=true"
echo "pwg=true"
echo "flatpak=true"
} >> "$GITHUB_OUTPUT"
}
case "$GITHUB_EVENT_NAME" in
workflow_dispatch)
if [[ "${SMOKE_ONLY:-false}" == "true" ]]; then
{
echo "test=false"
echo "tooling=false"
echo "pwg=false"
echo "flatpak=false"
} >> "$GITHUB_OUTPUT"
exit 0
fi
set_all
exit 0
;;
pull_request)
gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename' > "$files"
;;
push)
if [[ -z "${BEFORE:-}" || "$BEFORE" =~ ^0+$ ]]; then
set_all
exit 0
fi
gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$GITHUB_SHA" --jq '.files[].filename' > "$files"
;;
*)
set_all
exit 0
;;
esac
test=false
tooling=false
pwg=false
flatpak=false
while IFS= read -r path; do
case "$path" in
.github/workflows/ci.yml)
test=true
tooling=true
pwg=true
flatpak=true
;;
README.md|pyproject.toml|MANIFEST.in|src/*|tests/*|data/*|extensions/*)
test=true
;;
tools/check_gnome_shell_extension.py|tools/pack_gnome_shell_extension.sh)
test=true
;;
esac
case "$path" in
tools/*)
tooling=true
;;
esac
case "$path" in
.github/workflows/ci.yml|tools/check_pipewire_gobject.py|src/mini_eq/pipewire_backend.py|src/mini_eq/analyzer.py)
pwg=true
;;
esac
case "$path" in
.github/workflows/ci.yml|io.github.bhack.mini-eq.yaml|python3-dependencies.yaml|flatpak/*|src/*|data/*|pyproject.toml|MANIFEST.in|tools/check_pipewire_gobject.py)
flatpak=true
;;
esac
done < "$files"
{
echo "test=$test"
echo "tooling=$tooling"
echo "pwg=$pwg"
echo "flatpak=$flatpak"
} >> "$GITHUB_OUTPUT"
{
echo "### CI scope"
echo
echo "- test: \`$test\`"
echo "- tooling: \`$tooling\`"
echo "- pipewire-gobject: \`$pwg\`"
echo "- flatpak: \`$flatpak\`"
} >> "$GITHUB_STEP_SUMMARY"
tooling:
needs: changes
if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.smoke_only) }}
runs-on: ubuntu-24.04
steps:
- name: Require change detection
if: ${{ needs.changes.result != 'success' }}
run: exit 1
- name: Skip unchanged scope
if: ${{ needs.changes.outputs.tooling != 'true' }}
run: echo "No maintainer-tooling changes detected; skipping tooling job work."
- name: Check out repository
if: ${{ needs.changes.outputs.tooling == 'true' }}
uses: actions/checkout@v6
- name: Install Python tooling
if: ${{ needs.changes.outputs.tooling == 'true' }}
run: |
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install ruff
- name: Lint
if: ${{ needs.changes.outputs.tooling == 'true' }}
run: .venv/bin/python -m ruff check .
- name: Check formatting
if: ${{ needs.changes.outputs.tooling == 'true' }}
run: .venv/bin/python -m ruff format --check .
test:
needs: changes
if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.smoke_only) }}
runs-on: ubuntu-24.04
steps:
- name: Require change detection
if: ${{ needs.changes.result != 'success' }}
run: exit 1
- name: Skip unchanged scope
if: ${{ needs.changes.outputs.test != 'true' }}
run: echo "No Python/package changes detected; skipping test job work."
- name: Check out repository
if: ${{ needs.changes.outputs.test == 'true' }}
uses: actions/checkout@v6
- name: Install system dependencies
if: ${{ needs.changes.outputs.test == 'true' }}
run: |
sudo apt-get update
sudo apt-get install -y \
gir1.2-adw-1 \
gir1.2-gtk-4.0 \
gobject-introspection \
libgirepository1.0-dev \
libglib2.0-dev \
libpipewire-0.3-dev \
meson \
ninja-build \
pipewire \
python3-cairo \
python3-dev \
python3-gi \
python3-pip \
python3-setuptools \
python3-venv \
wireplumber
- name: Install Python dependencies
if: ${{ needs.changes.outputs.test == 'true' }}
run: |
python3 -m venv /tmp/mini-eq-pwg-build
/tmp/mini-eq-pwg-build/bin/python -m pip install --upgrade pip
/tmp/mini-eq-pwg-build/bin/python -m pip wheel 'pipewire-gobject>=0.3.4,<0.4' -w /tmp/mini-eq-wheelhouse
python3 -m venv --system-site-packages .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install --no-index --find-links /tmp/mini-eq-wheelhouse 'pipewire-gobject>=0.3.4,<0.4'
.venv/bin/python -m pip install -e '.[dev]'
- name: Lint
if: ${{ needs.changes.outputs.test == 'true' }}
run: .venv/bin/python -m ruff check .
- name: Check formatting
if: ${{ needs.changes.outputs.test == 'true' }}
run: .venv/bin/python -m ruff format --check .
- name: Test
if: ${{ needs.changes.outputs.test == 'true' }}
run: .venv/bin/python -m pytest -q
- name: Build package
if: ${{ needs.changes.outputs.test == 'true' }}
run: .venv/bin/python -m build
- name: Check package metadata
if: ${{ needs.changes.outputs.test == 'true' }}
run: .venv/bin/python -m twine check dist/*
- name: Smoke-test wheel CLI
if: ${{ needs.changes.outputs.test == 'true' }}
run: |
python3 -m venv --system-site-packages /tmp/mini-eq-wheel-test
/tmp/mini-eq-wheel-test/bin/python -m pip install --upgrade pip
/tmp/mini-eq-wheel-test/bin/python -m pip install --no-index --find-links /tmp/mini-eq-wheelhouse 'pipewire-gobject>=0.3.4,<0.4'
/tmp/mini-eq-wheel-test/bin/python -m pip install dist/mini_eq-*.whl
/tmp/mini-eq-wheel-test/bin/mini-eq --help
- name: Upload package artifacts
if: ${{ needs.changes.outputs.test == 'true' }}
uses: actions/upload-artifact@v7
with:
name: mini-eq-dist
path: dist/*
if-no-files-found: error
flatpak-build:
needs: changes
if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.smoke_only) && needs.changes.result == 'success' && needs.changes.outputs.flatpak == 'true' }}
runs-on: ubuntu-24.04
timeout-minutes: 60
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-50@sha256:9d3a99bef793cf99f55b0106130e68a781fd0815c8d2954f26e1ac9253b19e57
options: --privileged
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Configure Flathub remote
run: |
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Build Flatpak
uses: flatpak/flatpak-github-actions/flatpak-builder@401fe28a8384095fc1531b9d320b292f0ee45adb
with:
bundle: mini-eq.flatpak
manifest-path: io.github.bhack.mini-eq.yaml
upload-artifact: false
- name: Install built Flatpak
run: flatpak --user install -y ./mini-eq.flatpak
- name: Smoke-test Flatpak CLI
run: flatpak run io.github.bhack.mini-eq --help
- name: Check pipewire-gobject GI compatibility
run: |
flatpak run --filesystem="$PWD":ro --command=python3 io.github.bhack.mini-eq \
"$PWD/tools/check_pipewire_gobject.py" --expect-version 0.3.4
- name: Smoke-test Flatpak runtime modules
run: |
flatpak run --command=python3 io.github.bhack.mini-eq - <<'PY'
from pathlib import Path
required_files = [
"/app/lib/pipewire-0.3/libpipewire-module-filter-chain.so",
"/app/lib/spa-0.2/filter-graph/libspa-filter-graph.so",
"/app/lib/spa-0.2/filter-graph/libspa-filter-graph-plugin-builtin.so",
]
missing = [path for path in required_files if not Path(path).exists()]
if missing:
raise SystemExit(f"missing Flatpak runtime file(s): {', '.join(missing)}")
PY
flatpak run --command=python3 io.github.bhack.mini-eq - <<'PY'
from pathlib import Path
required_license_files = [
"/app/share/licenses/io.github.bhack.mini-eq/mini-eq/LICENSE",
"/app/share/licenses/io.github.bhack.mini-eq/pipewire-filter-chain-module/COPYING",
"/app/share/licenses/io.github.bhack.mini-eq/pipewire-filter-chain-module/LICENSE",
"/app/share/licenses/io.github.bhack.mini-eq/pipewire-gobject/LICENSE",
]
missing = [path for path in required_license_files if not Path(path).exists()]
if missing:
raise SystemExit(f"missing Flatpak license file(s): {', '.join(missing)}")
PY
flatpak run --command=python3 io.github.bhack.mini-eq - <<'PY'
import importlib
required_modules = ["numpy", "pipewire_gobject"]
missing = []
for name in required_modules:
try:
importlib.import_module(name)
except Exception as exc:
missing.append(f"{name}: {exc}")
if missing:
raise SystemExit(f"missing Python analyzer module(s): {', '.join(missing)}")
PY
flatpak:
needs:
- changes
- flatpak-build
if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.smoke_only) }}
runs-on: ubuntu-24.04
steps:
- name: Require change detection
if: ${{ needs.changes.result != 'success' }}
run: exit 1
- name: Skip unchanged scope
if: ${{ needs.changes.outputs.flatpak != 'true' }}
run: echo "No Flatpak-relevant changes detected; skipping Flatpak build."
- name: Require Flatpak build
if: ${{ needs.changes.outputs.flatpak == 'true' && needs['flatpak-build'].result != 'success' }}
run: exit 1
- name: Confirm Flatpak build
if: ${{ needs.changes.outputs.flatpak == 'true' && needs['flatpak-build'].result == 'success' }}
run: echo "Flatpak build passed."
flatpak-runtime-smoke:
needs: changes
if: ${{ github.event_name == 'workflow_dispatch' && inputs.flatpak_runtime_smoke }}
runs-on: ubuntu-24.04
timeout-minutes: 90
continue-on-error: true
steps:
- name: Require change detection
if: ${{ needs.changes.result != 'success' }}
run: exit 1
- name: Check out repository
uses: actions/checkout@v6
- name: Install Flatpak and PipeWire test dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
dbus-user-session \
flatpak \
jq \
pipewire \
pipewire-bin \
wireplumber
- name: Build and run experimental Flatpak runtime smoke
env:
MINI_EQ_FLATPAK_BUILD: ${{ inputs.flatpak_runtime_build && '1' || '0' }}
MINI_EQ_FLATPAK_INSTALL_REMOTE: ${{ inputs.flatpak_runtime_install_remote && '1' || '0' }}
MINI_EQ_FLATPAK_APP_REF: ${{ inputs.flatpak_runtime_app_ref }}
MINI_EQ_FLATPAK_INSTALL_REF: ${{ inputs.flatpak_runtime_install_ref }}
MINI_EQ_FLATPAK_EXPECT_VERSION: ${{ inputs.flatpak_runtime_expected_version }}
run: tools/run_flatpak_runtime_smoke_ci.sh