Skip to content

Commit 12072e5

Browse files
committed
ci: don't try to use self-hosted runners when running in forks
In forks, the ppc64le and s390x jobs sit indefinitely waiting for a runner to pick them up, blocking the workflow from completing. We want to skip those jobs, but the job's if: directive can't read the matrix context. Instead, preprocess the matrix from the prelude job.
1 parent 2e117a7 commit 12072e5

File tree

3 files changed

+119
-53
lines changed

3 files changed

+119
-53
lines changed

.github/workflows/build_all.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ jobs:
2323
runs-on: ubuntu-latest
2424
outputs:
2525
cache-key: ${{ steps.cache-key.outputs.cache-key }}
26+
matrix-alpine: ${{ steps.alpine.outputs.matrix }}
27+
matrix-ubuntu: ${{ steps.ubuntu.outputs.matrix }}
2628
steps:
2729
- uses: actions/checkout@v5
2830
with:
2931
fetch-depth: 0
3032

3133
- name: Install packages
32-
run: python3 -m pip install git+https://github.com/mesonbuild/meson
34+
run: python3 -m pip install PyYAML git+https://github.com/mesonbuild/meson
3335

3436
- name: Calculate cache key
3537
id: cache-key
@@ -59,22 +61,48 @@ jobs:
5961
path: subprojects/packagecache
6062
enableCrossOsArchive: true
6163

62-
Ubuntu:
63-
if: github.event_name != 'schedule' || github.repository == 'mesonbuild/wrapdb'
64-
name: Ubuntu (${{ matrix.platform }})
65-
runs-on: ${{ matrix.runner }}
66-
needs: prelude
67-
strategy:
68-
matrix:
69-
include:
64+
- name: Build Ubuntu matrix
65+
id: ubuntu
66+
shell: python tools/filter_matrix.py {0}
67+
run: |
68+
- platform: aarch64
69+
runner: ubuntu-24.04-arm
70+
- platform: ppc64le
71+
runner: ubuntu-24.04-ppc64le
72+
selfhosted: true
73+
- platform: s390x
74+
runner: ubuntu-24.04-s390x
75+
selfhosted: true
76+
- platform: x86_64
77+
runner: ubuntu-latest
78+
79+
- name: Build Alpine matrix
80+
id: alpine
81+
shell: python tools/filter_matrix.py {0}
82+
run: |
7083
- platform: aarch64
7184
runner: ubuntu-24.04-arm
85+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
7286
- platform: ppc64le
7387
runner: ubuntu-24.04-ppc64le
88+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
89+
selfhosted: true
7490
- platform: s390x
7591
runner: ubuntu-24.04-s390x
92+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
93+
selfhosted: true
7694
- platform: x86_64
7795
runner: ubuntu-latest
96+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
97+
98+
Ubuntu:
99+
if: github.event_name != 'schedule' || github.repository == 'mesonbuild/wrapdb'
100+
name: Ubuntu (${{ matrix.platform }})
101+
runs-on: ${{ matrix.runner }}
102+
needs: prelude
103+
strategy:
104+
matrix:
105+
include: ${{ fromJson(needs.prelude.outputs.matrix-ubuntu) }}
78106
steps:
79107
- uses: actions/checkout@v5
80108
with:
@@ -105,19 +133,7 @@ jobs:
105133
needs: prelude
106134
strategy:
107135
matrix:
108-
include:
109-
- platform: aarch64
110-
runner: ubuntu-24.04-arm
111-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
112-
- platform: ppc64le
113-
runner: ubuntu-24.04-ppc64le
114-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
115-
- platform: s390x
116-
runner: ubuntu-24.04-s390x
117-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
118-
- platform: x86_64
119-
runner: ubuntu-latest
120-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
136+
include: ${{ fromJson(needs.prelude.outputs.matrix-alpine) }}
121137
steps:
122138
- uses: jirutka/setup-alpine@v1
123139
with:

.github/workflows/sanity_checks.yml

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ jobs:
1818
runs-on: ubuntu-latest
1919
outputs:
2020
cache-key: ${{ steps.cache-key.outputs.cache-key }}
21+
matrix-alpine: ${{ steps.alpine.outputs.matrix }}
22+
matrix-ubuntu: ${{ steps.ubuntu.outputs.matrix }}
2123
steps:
2224
- uses: actions/checkout@v5
2325
with:
2426
fetch-depth: 0
2527

2628
- name: Install packages
2729
run: |
28-
python3 -m pip install license-expression
30+
python3 -m pip install license-expression PyYAML
2931
python3 -m pip install --pre meson
3032
3133
- name: Calculate cache key
@@ -59,26 +61,61 @@ jobs:
5961
run: |
6062
./tools/fake_tty.py ./tools/sanity_checks.py
6163
62-
Ubuntu:
63-
name: Ubuntu (${{ matrix.platform }})
64-
runs-on: ${{ matrix.runner }}
65-
needs: prelude
66-
strategy:
67-
fail-fast: false
68-
matrix:
69-
include:
64+
- name: Build Ubuntu matrix
65+
id: ubuntu
66+
shell: python tools/filter_matrix.py {0}
67+
run: |
7068
- platform: aarch64
7169
runner: ubuntu-24.04-arm
7270
python: 3.8
7371
- platform: ppc64le
7472
runner: ubuntu-24.04-ppc64le
7573
python: 3.13
74+
selfhosted: true
7675
- platform: s390x
7776
runner: ubuntu-24.04-s390x
7877
python: 3.13
78+
selfhosted: true
7979
- platform: x86_64
8080
runner: ubuntu-latest
8181
python: 3.13
82+
83+
- name: Build Alpine matrix
84+
id: alpine
85+
shell: python tools/filter_matrix.py {0}
86+
run: |
87+
- platform: aarch64
88+
runner: ubuntu-24.04-arm
89+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
90+
- platform: armv7
91+
runner: ubuntu-24.04-arm
92+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
93+
- platform: ppc64le
94+
runner: ubuntu-24.04-ppc64le
95+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
96+
selfhosted: true
97+
- platform: riscv64
98+
runner: ubuntu-24.04-arm
99+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
100+
- platform: s390x
101+
runner: ubuntu-24.04-s390x
102+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
103+
selfhosted: true
104+
- platform: x86
105+
runner: ubuntu-latest
106+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
107+
- platform: x86_64
108+
runner: ubuntu-latest
109+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
110+
111+
Ubuntu:
112+
name: Ubuntu (${{ matrix.platform }})
113+
runs-on: ${{ matrix.runner }}
114+
needs: prelude
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
include: ${{ fromJson(needs.prelude.outputs.matrix-ubuntu) }}
82119
steps:
83120
- uses: actions/checkout@v5
84121
with:
@@ -124,28 +161,7 @@ jobs:
124161
strategy:
125162
fail-fast: false
126163
matrix:
127-
include:
128-
- platform: aarch64
129-
runner: ubuntu-24.04-arm
130-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
131-
- platform: armv7
132-
runner: ubuntu-24.04-arm
133-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
134-
- platform: ppc64le
135-
runner: ubuntu-24.04-ppc64le
136-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
137-
- platform: riscv64
138-
runner: ubuntu-24.04-arm
139-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
140-
- platform: s390x
141-
runner: ubuntu-24.04-s390x
142-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
143-
- platform: x86
144-
runner: ubuntu-latest
145-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
146-
- platform: x86_64
147-
runner: ubuntu-latest
148-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
164+
include: ${{ fromJson(needs.prelude.outputs.matrix-alpine) }}
149165
steps:
150166
- uses: actions/checkout@v5
151167
with:

tools/filter_matrix.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2025 Benjamin Gilbert <[email protected]>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import json
18+
import os
19+
import sys
20+
import yaml
21+
import typing as T
22+
23+
UPSTREAM_OWNER = 'mesonbuild'
24+
25+
with open(sys.argv[1]) as f:
26+
jobs: list[dict[str, T.Any]] = yaml.safe_load(f)
27+
28+
if os.environ['GITHUB_REPOSITORY_OWNER'] != UPSTREAM_OWNER:
29+
jobs = [j for j in jobs if not j.get('selfhosted', False)]
30+
31+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
32+
f.write('matrix=')
33+
json.dump(jobs, f, separators=(',', ':'))
34+
f.write('\n')

0 commit comments

Comments
 (0)