Skip to content

Commit 023bd5d

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 a06024a commit 023bd5d

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
@@ -20,13 +20,15 @@ jobs:
2020
runs-on: ubuntu-latest
2121
outputs:
2222
cache-key: ${{ steps.cache-key.outputs.cache-key }}
23+
matrix-alpine: ${{ steps.alpine.outputs.matrix }}
24+
matrix-ubuntu: ${{ steps.ubuntu.outputs.matrix }}
2325
steps:
2426
- uses: actions/checkout@v4
2527
with:
2628
fetch-depth: 0
2729

2830
- name: Install packages
29-
run: python3 -m pip install git+https://github.com/mesonbuild/meson
31+
run: python3 -m pip install PyYAML git+https://github.com/mesonbuild/meson
3032

3133
- name: Calculate cache key
3234
id: cache-key
@@ -56,22 +58,48 @@ jobs:
5658
path: subprojects/packagecache
5759
enableCrossOsArchive: true
5860

59-
Ubuntu:
60-
if: github.event_name != 'schedule' || github.repository == 'mesonbuild/wrapdb'
61-
name: Ubuntu (${{ matrix.platform }})
62-
runs-on: ${{ matrix.runner }}
63-
needs: prelude
64-
strategy:
65-
matrix:
66-
include:
61+
- name: Build Ubuntu matrix
62+
id: ubuntu
63+
shell: $GITHUB_WORKSPACE/tools/filter_matrix.py {0}
64+
run: |
6765
- platform: aarch64
6866
runner: ubuntu-24.04-arm
6967
- platform: ppc64le
7068
runner: ubuntu-24.04-ppc64le
69+
selfhosted: true
7170
- platform: s390x
7271
runner: ubuntu-24.04-s390x
72+
selfhosted: true
73+
- platform: x86_64
74+
runner: ubuntu-latest
75+
76+
- name: Build Alpine matrix
77+
id: alpine
78+
shell: $GITHUB_WORKSPACE/tools/filter_matrix.py {0}
79+
run: |
80+
- platform: aarch64
81+
runner: ubuntu-24.04-arm
82+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
83+
- platform: ppc64le
84+
runner: ubuntu-24.04-ppc64le
85+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
86+
selfhosted: true
87+
- platform: s390x
88+
runner: ubuntu-24.04-s390x
89+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
90+
selfhosted: true
7391
- platform: x86_64
7492
runner: ubuntu-latest
93+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
94+
95+
Ubuntu:
96+
if: github.event_name != 'schedule' || github.repository == 'mesonbuild/wrapdb'
97+
name: Ubuntu (${{ matrix.platform }})
98+
runs-on: ${{ matrix.runner }}
99+
needs: prelude
100+
strategy:
101+
matrix:
102+
include: ${{ fromJson(needs.prelude.outputs.matrix-ubuntu) }}
75103
steps:
76104
- uses: actions/checkout@v4
77105
with:
@@ -102,19 +130,7 @@ jobs:
102130
needs: prelude
103131
strategy:
104132
matrix:
105-
include:
106-
- platform: aarch64
107-
runner: ubuntu-24.04-arm
108-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
109-
- platform: ppc64le
110-
runner: ubuntu-24.04-ppc64le
111-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
112-
- platform: s390x
113-
runner: ubuntu-24.04-s390x
114-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
115-
- platform: x86_64
116-
runner: ubuntu-latest
117-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
133+
include: ${{ fromJson(needs.prelude.outputs.matrix-alpine) }}
118134
steps:
119135
- uses: jirutka/setup-alpine@v1
120136
with:

.github/workflows/sanity_checks.yml

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ jobs:
1515
runs-on: ubuntu-latest
1616
outputs:
1717
cache-key: ${{ steps.cache-key.outputs.cache-key }}
18+
matrix-alpine: ${{ steps.alpine.outputs.matrix }}
19+
matrix-ubuntu: ${{ steps.ubuntu.outputs.matrix }}
1820
steps:
1921
- uses: actions/checkout@v4
2022
with:
2123
fetch-depth: 0
2224

2325
- name: Install packages
2426
run: |
25-
python3 -m pip install license-expression
27+
python3 -m pip install license-expression PyYAML
2628
python3 -m pip install --pre meson
2729
2830
- name: Calculate cache key
@@ -56,22 +58,57 @@ jobs:
5658
run: |
5759
./tools/fake_tty.py ./tools/sanity_checks.py
5860
59-
Ubuntu:
60-
name: Ubuntu (${{ matrix.platform }})
61-
runs-on: ${{ matrix.runner }}
62-
needs: prelude
63-
strategy:
64-
fail-fast: false
65-
matrix:
66-
include:
61+
- name: Build Ubuntu matrix
62+
id: ubuntu
63+
shell: $GITHUB_WORKSPACE/tools/filter_matrix.py {0}
64+
run: |
65+
- platform: aarch64
66+
runner: ubuntu-24.04-arm
67+
- platform: ppc64le
68+
runner: ubuntu-24.04-ppc64le
69+
selfhosted: true
70+
- platform: s390x
71+
runner: ubuntu-24.04-s390x
72+
selfhosted: true
73+
- platform: x86_64
74+
runner: ubuntu-latest
75+
76+
- name: Build Alpine matrix
77+
id: alpine
78+
shell: $GITHUB_WORKSPACE/tools/filter_matrix.py {0}
79+
run: |
6780
- platform: aarch64
6881
runner: ubuntu-24.04-arm
82+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
83+
- platform: armv7
84+
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'
6986
- platform: ppc64le
7087
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
90+
- platform: riscv64
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'
7193
- platform: s390x
7294
runner: ubuntu-24.04-s390x
95+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
96+
selfhosted: true
97+
- platform: x86
98+
runner: ubuntu-latest
99+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
73100
- platform: x86_64
74101
runner: ubuntu-latest
102+
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
103+
104+
Ubuntu:
105+
name: Ubuntu (${{ matrix.platform }})
106+
runs-on: ${{ matrix.runner }}
107+
needs: prelude
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
include: ${{ fromJson(needs.prelude.outputs.matrix-ubuntu) }}
75112
steps:
76113
- uses: actions/checkout@v4
77114
with:
@@ -112,28 +149,7 @@ jobs:
112149
strategy:
113150
fail-fast: false
114151
matrix:
115-
include:
116-
- platform: aarch64
117-
runner: ubuntu-24.04-arm
118-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
119-
- platform: armv7
120-
runner: ubuntu-24.04-arm
121-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
122-
- platform: ppc64le
123-
runner: ubuntu-24.04-ppc64le
124-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/ppc64le/apk.static#!sha256!96ba92b49c8cc97fad06f0dfe3c50ec25c3344890e479999ded8752bf9e80d7f'
125-
- platform: riscv64
126-
runner: ubuntu-24.04-arm
127-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/aarch64/apk.static#!sha256!27a975638ddc95a411c9f17c63383e335da9edf6bb7de2281d950c291a11f878'
128-
- platform: s390x
129-
runner: ubuntu-24.04-s390x
130-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/s390x/apk.static#!sha256!368996f2908ec8f10f1de500bc97a9bd1c3b0b46ce0bd44983ac09862cbab6d5'
131-
- platform: x86
132-
runner: ubuntu-latest
133-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
134-
- platform: x86_64
135-
runner: ubuntu-latest
136-
apk-tools-url: 'https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.7/x86_64/apk.static#!sha256!bdd044e0fd6cc388c5e571e1093efa5f35f7767cc5aa338b0a2576a429009a62'
152+
include: ${{ fromJson(needs.prelude.outputs.matrix-alpine) }}
137153
steps:
138154
- uses: actions/checkout@v4
139155
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)