-
Notifications
You must be signed in to change notification settings - Fork 48
618 lines (507 loc) · 18.4 KB
/
Copy pathci.yml
File metadata and controls
618 lines (507 loc) · 18.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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# SPDX-FileCopyrightText: 2025 Aleksandr Mezin <mezin.alexander@gmail.com>
#
# SPDX-License-Identifier: CC0-1.0
name: ci
on:
workflow_call:
inputs:
push:
type: boolean
description: Push autogenerated changes
default: false
outputs:
dist-tarball-artifact-id:
description: Artifact id of dist tarball
value: ${{ jobs.dist.outputs.artifact-id }}
dist-tarball-checksum-artifact-id:
description: Artifact id of dist tarball checksum file
value: ${{ jobs.dist.outputs.checksum-artifact-id }}
bundle-artifact-id:
description: Artifact id of extension bundle file
value: ${{ jobs.bundle.outputs.artifact-id }}
release-notes-artifact-id:
description: Artifact id of release notes file, if a new release should be published
value: ${{ jobs.lint.outputs.release-notes-artifact-id }}
version-tag:
description: Current version tag
value: ${{ jobs.lint.outputs.tag }}
defaults:
run:
shell: bash
permissions:
contents: read
env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1
TERM: xterm-color
TQDM_DISABLE: 1
DEVTOOLS_COLOR: always
jobs:
plan:
runs-on: ubuntu-slim
timeout-minutes: 5
needs:
- bundle
- lint
outputs:
need-tests: ${{ steps.diff.outputs.changed != 'false' }}
test-containers: ${{ steps.test-config.outputs.containers }}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- id: actions
name: Get the list of actions used in build and test jobs
run: |
names="$(yq -oj -I0 "$YQ_FILTER" .github/workflows/ci.yml)"
echo "names=$names" | tee -a "$GITHUB_OUTPUT"
env:
YQ_FILTER: >-
[
.jobs["bundle", "test", "archlinux-package", "archlinux-package-check", "archlinux-installed-test"] |
.steps.[].uses |
select(.) |
capture("^\\./\\.github/actions/(?<name>.*)$") |
.name
] | unique
- id: diff
name: Check if tests are necessary
uses: amezin/detect-changes-action@95b2732dd7b66cafe3e683304c0a3da0fb0bf674 # v2.2.4
continue-on-error: true
with:
files: |
${{ needs.bundle.outputs.build-inputs }}
# Files that influence build and test, even though they aren't included in the package
.github/actions/{${{ join(fromJSON(steps.actions.outputs.names)) }}}/**
.github/workflows/ci.yml
requirements/{test,test-images,meson}.txt
tests/**
tools/heapgraph.py
pytest.ini
tox.ini
PKGBUILD
# Exclude any documentation and translations
!**/*.md
!**/*.license
!**/REUSE.toml
!LICENSES/**
!po/**
# Include meson.build files, even from po/ directory
**/meson.build
meson.options
subprojects/*.wrap
- id: test-config
name: Determine test configurations
working-directory: tests
run: |
containers="$(yq -oj -I0 "$YQ_FILTER" compose.yaml)"
echo "containers=$containers" | tee -a "$GITHUB_OUTPUT"
env:
YQ_FILTER: >-
[ .services | keys.[] | select(. != "archlinux") ]
lint:
runs-on: ubuntu-26.04
timeout-minutes: 5
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
release-notes-artifact-id: ${{ steps.release-notes.outputs.artifact-id }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- id: apt
uses: ./.github/actions/apt-install
with:
args: >-
--no-install-recommends
colorized-logs
tox
- name: Install development dependencies from npm
id: npm
uses: ./.github/actions/npm-install
if: ${{ !cancelled() && steps.checkout.outcome == 'success' }}
- name: Install Python dependencies
id: pip
uses: ./.github/actions/tox-preinstall
with:
environments: reuse,flake8,meson-format,pip-compile
if: ${{ !cancelled() && steps.apt.outcome == 'success' }}
- name: Install meson
uses: ./.github/actions/setup-meson
- name: Download subprojects
run: meson subprojects download
shell: pipetty bash -e {0}
- name: Lint JS code with ESLint
uses: ./.github/actions/eslint
if: ${{ !cancelled() && steps.npm.outcome == 'success' }}
- name: Lint Python code with flake8
uses: ./.github/actions/flake8
if: ${{ !cancelled() && steps.pip.outcome == 'success' }}
- name: Lint Markdown files
uses: ./.github/actions/markdownlint
if: ${{ !cancelled() && steps.npm.outcome == 'success' }}
- name: Check repository REUSE compliance
uses: ./.github/actions/reuse
if: ${{ !cancelled() && steps.pip.outcome == 'success' }}
- name: Check meson.build formatting
uses: ./.github/actions/meson-format
if: ${{ !cancelled() && steps.pip.outcome == 'success' }}
- name: Check Python requirements .txt files
uses: ./.github/actions/pip-compile
if: ${{ !cancelled() && steps.pip.outcome == 'success' }}
- name: Check PICT test cases
uses: ./.github/actions/pict
if: ${{ !cancelled() && steps.checkout.outcome == 'success' }}
- name: Add flake8 to PATH
run: echo "$GITHUB_WORKSPACE/.tox/flake8/bin" >>"$GITHUB_PATH"
if: ${{ !cancelled() && steps.pip.outcome == 'success' }}
- name: Check GitHub Actions workflows
uses: ./.github/actions/actionlint
if: ${{ !cancelled() && steps.checkout.outcome == 'success' }}
- name: Lint latest changelog entry
run: npm run lint:release-notes
if: ${{ !cancelled() && steps.npm.outcome == 'success' }}
- name: Get current version
id: version
run: |
version="$(jq -r .version package.json)"
tag="v${version}"
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
echo "tag=$tag" | tee -a "$GITHUB_OUTPUT"
- name: Ensure version is the same in all places
run: |
npm version --ignore-scripts=false --allow-same-version "$VERSION"
if ! git diff --exit-code --color=always
then
echo "::error:: Version doesn't match across files. Run 'npm version --ignore-scripts=false'"
exit 1
fi
env:
VERSION: ${{ steps.version.outputs.version }}
- name: List existing releases
id: releases
run: |
existing="$(gh release list --json tagName | jq -c '[.[].tagName]')"
echo "existing=$existing" | tee -a "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
- name: Verify changelog version
run: >-
npm run-script changelog --
${{ case(contains(fromJSON(steps.releases.outputs.existing), steps.version.outputs.tag), '-u', '-d "$(date +%F)"') }}
-v "$VERSION"
env:
VERSION: ${{ steps.version.outputs.version }}
- name: Extract changelog entry
run: npm run-script changelog -- -p "$RUNNER_TEMP/release-notes.md"
- name: Upload release notes
id: release-notes
if: ${{ !contains(fromJSON(steps.releases.outputs.existing), steps.version.outputs.tag) }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: "${{ runner.temp }}/release-notes.md"
if-no-files-found: error
archive: false
dist:
runs-on: ubuntu-26.04
timeout-minutes: 5
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
checksum-artifact-id: ${{ steps.checksum-upload.outputs.artifact-id }}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./.github/actions/apt-install
with:
cache-save: true
# Building package cache -> install all packages needed by other jobs
args: >-
--no-install-recommends
colorized-logs
desktop-file-utils
gettext
gjs
libgtk-3-bin
python3-gi
tox
xsltproc
- name: Install meson
uses: ./.github/actions/setup-meson
- name: Download subprojects
run: meson subprojects download
shell: pipetty bash -e {0}
- name: Prepare build directory
run: meson setup '-Dshebang_override=/usr/bin/env gjs' '-Dtests=disabled' build
shell: pipetty bash -e {0}
- name: Generate dist tarball
run: meson dist -C build --include-subprojects --no-tests --formats gztar
shell: pipetty bash -e {0}
- name: Upload dist tarball
id: upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: build/meson-dist/ddterm-*.tar.gz
if-no-files-found: error
archive: false
- name: Upload dist tarball checksum
id: checksum-upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: build/meson-dist/ddterm-*.tar.gz.*sum
if-no-files-found: error
archive: false
bundle:
runs-on: ubuntu-26.04
timeout-minutes: 5
needs:
- dist
outputs:
build-inputs: ${{ steps.ninja-inputs.outputs.inputs }}
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Download dist tarball
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.dist.outputs.artifact-id }}
path: ${{ runner.temp }}/dist
skip-decompress: true
- name: Extract dist tarball
run: tar xvf "$RUNNER_TEMP"/dist/* --strip-components=1
- uses: ./.github/actions/apt-install
with:
args: >-
--no-install-recommends
colorized-logs
desktop-file-utils
gettext
gjs
tox
xsltproc
- name: Install meson
uses: ./.github/actions/setup-meson
- name: Prepare build directory
run: meson setup '-Dshebang_override=/usr/bin/env gjs' '-Dtests=disabled' build
shell: pipetty bash -e {0}
- name: Build extension bundle
run: ninja -j1 bundle
working-directory: build
- name: Upload extension bundle as artifact
id: upload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: "build/*.shell-extension.zip"
if-no-files-found: error
archive: false
- name: Run checks
run: meson test -v -j1
working-directory: build
shell: pipetty bash -e {0}
- name: Check REUSE compliance of generated bundle
run: tox -e reuse-bundle -- build/*.shell-extension.zip
- name: Generate a list of input files
id: ninja-inputs
working-directory: build
run: |
inputs="$(ninja -t inputs | xargs realpath "--relative-base=$GITHUB_WORKSPACE" | grep -v '^build/')"
{ echo "inputs<<../EOF"; echo "$inputs"; echo "../EOF"; } | tee -a "$GITHUB_OUTPUT"
update-translations:
needs:
- lint
- bundle
runs-on: ubuntu-26.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./.github/actions/apt-install
with:
args: >-
--no-install-recommends
colorized-logs
gettext
gjs
libgtk-3-bin
tox
xsltproc
- name: Install meson
uses: ./.github/actions/setup-meson
- name: Prepare build directory
id: setup
run: meson setup '-Dtests=disabled' build
shell: pipetty bash -e {0}
- name: Update POTFILES.in
run: ninja -j1 potfiles
working-directory: build
- name: Update .pot file
run: ninja -j1 pot
working-directory: build
- name: Update .po files
run: ninja -j1 msgmerge
working-directory: build
- name: Diff
id: diff
# Note: git diff --name-only ignores --ignore-matching-lines arg
run: |
git diff --color '--ignore-matching-lines=^"POT-Creation-Date: ' 'po/*.po' 'po/*.pot' 'po/POTFILES.in' | tee "$RUNNER_TEMP/po.diff"
size="$(stat --printf=%s "$RUNNER_TEMP/po.diff")"
echo "size=$size" | tee -a "$GITHUB_OUTPUT"
- name: Create pull request
if: vars.APP_ID && fromJSON(steps.diff.outputs.size) && inputs.push
uses: ./.github/actions/pull-request
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_KEY }}
title: 'translations: update translation files'
description: 'Update translation files. Before merging this, make sure there are no unmerged changes from Weblate.'
files: |
po/*.po
po/*.pot
po/POTFILES.in
test:
needs:
- dist
- plan
- bundle
- lint
strategy:
fail-fast: false
matrix:
container: ${{ fromJSON(needs.plan.outputs.test-containers) }}
if: fromJSON(needs.plan.outputs.need-tests)
runs-on: ubuntu-26.04
timeout-minutes: 15
env:
VIRTUALENV_SYSTEM_SITE_PACKAGES: 'true'
steps:
- name: Download dist tarball
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.dist.outputs.artifact-id }}
path: ${{ runner.temp }}/dist
skip-decompress: true
- name: Extract dist tarball
run: tar xvf "$RUNNER_TEMP"/dist/* --strip-components=1
- uses: ./.github/actions/apt-install
with:
args: >-
--no-install-recommends
python3-gi
tox
- name: Download extension bundle
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.bundle.outputs.artifact-id }}
skip-decompress: true
- name: Install dependencies
uses: ./.github/actions/tox-preinstall
with:
environments: pytest,images
- name: Run tests
uses: ./.github/actions/container-test
with:
container: ${{ matrix.container }}
args: >-
${{ case(contains(matrix.container, 'alpine'), '', '--journald') }}
--bundle=ddterm@amezin.github.com.shell-extension.zip
archlinux-package:
needs:
- plan
- bundle
- lint
runs-on: ubuntu-26.04
timeout-minutes: 10
container:
image: ghcr.io/archlinux/archlinux:base-devel-20260705.0.552542@sha256:21a71a9356d75341088aea90fdae0973eb6ffeeaebc472086b26847605a50f5d
options: --privileged --tmpfs /run
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0 # for pkgver()
- name: Create build chroot
uses: ./.github/actions/mkarchroot
- name: Build package
uses: ./.github/actions/makechrootpkg
with:
makepkg-args: --nocheck
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}
path: |
*.pkg.tar.*
*.log
if-no-files-found: error
- id: pkgfilename
shell: bash -e -O extglob {0}
run: |
pkgfilename="$(echo -n *.pkg.tar@(|.+([^.])))"
echo "pkgfilename=$pkgfilename" | tee -a "$GITHUB_OUTPUT"
outputs:
pkgfilename: ${{ steps.pkgfilename.outputs.pkgfilename }}
archlinux-installed-test:
needs:
- plan
- archlinux-package
if: fromJSON(needs.plan.outputs.need-tests)
runs-on: ubuntu-26.04
timeout-minutes: 15
env:
VIRTUALENV_SYSTEM_SITE_PACKAGES: 'true'
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./.github/actions/apt-install
with:
args: >-
--no-install-recommends
python3-gi
tox
- name: Download extension package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: archlinux-package
- name: Install dependencies
uses: ./.github/actions/tox-preinstall
with:
environments: pytest,images
- name: Run tests
uses: ./.github/actions/container-test
with:
container: archlinux
args: --journald "--sys-package=$PKGFILENAME"
env:
PKGFILENAME: ${{ needs.archlinux-package.outputs.pkgfilename }}
archlinux-package-check:
needs:
- plan
- archlinux-package
if: fromJSON(needs.plan.outputs.need-tests)
runs-on: ubuntu-26.04
timeout-minutes: 10
container:
image: ghcr.io/archlinux/archlinux:base-devel-20260705.0.552542@sha256:21a71a9356d75341088aea90fdae0973eb6ffeeaebc472086b26847605a50f5d
options: --privileged --tmpfs /run --security-opt apparmor=unconfined
steps:
- name: Allow unprivileged userns in AppArmor
run: |
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0 # for pkgver()
- name: Create build chroot
uses: ./.github/actions/mkarchroot
- name: Build package
uses: ./.github/actions/makechrootpkg
with:
makepkg-args: --check
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}
path: |
*.pkg.tar.*
*.log
if-no-files-found: error