Skip to content

Commit babde55

Browse files
committed
ci: reuse matrices
1 parent 983eee2 commit babde55

File tree

8 files changed

+182
-307
lines changed

8 files changed

+182
-307
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,17 @@ on:
88
required: false
99
type: string
1010
system:
11-
description: "System to build for (optional, builds all if not specified)"
12-
required: false
11+
description: "System to build for"
12+
required: true
13+
type: string
14+
runs-on:
15+
description: "Runner to use"
16+
required: true
1317
type: string
1418

1519
jobs:
1620
build:
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
systems: >-
21-
${{
22-
inputs.system && fromJSON(format('[{0}]',
23-
inputs.system == 'aarch64-linux' && '{"system": "aarch64-linux", "runs-on": ["self-hosted", "linux", "ARM64"]}' ||
24-
inputs.system == 'x86_64-linux' && '{"system": "x86_64-linux", "runs-on": ["self-hosted", "linux", "X64"]}' ||
25-
inputs.system == 'aarch64-darwin' && '{"system": "aarch64-darwin", "runs-on": ["self-hosted", "macOS", "ARM64"]}' ||
26-
inputs.system == 'x86_64-darwin' && '{"system": "x86_64-darwin", "runs-on": ["macos-13"]}' ||
27-
'{"system": "unknown", "runs-on": ["ubuntu-latest"]}'
28-
)) || fromJSON('[
29-
{"system": "aarch64-linux", "runs-on": ["self-hosted", "linux", "ARM64"]},
30-
{"system": "x86_64-linux", "runs-on": ["self-hosted", "linux", "X64"]},
31-
{"system": "aarch64-darwin", "runs-on": ["self-hosted", "macOS", "ARM64"]},
32-
{"system": "x86_64-darwin", "runs-on": ["macos-13"]}
33-
]')
34-
}}
35-
runs-on: ${{ matrix.systems.runs-on }}
21+
runs-on: ${{ fromJSON(inputs.runs-on) }}
3622
steps:
3723
- uses: actions/checkout@v5
3824
with:
@@ -49,11 +35,11 @@ jobs:
4935
name: devenv
5036
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
5137

52-
- name: Build devenv-${{ matrix.systems.system }}
38+
- name: Build devenv-${{ inputs.system }}
5339
run: |
54-
nix build -L --show-trace --print-out-paths --system ${{ matrix.systems.system }}
40+
nix build -L --show-trace --print-out-paths --system ${{ inputs.system }}
5541
5642
# Cache the devenv-tasks binary used by the module system
57-
- name: Build devenv-tasks-fast-${{ matrix.systems.system }}
43+
- name: Build devenv-tasks-fast-${{ inputs.system }}
5844
run: |
59-
nix build -L --show-trace --print-out-paths --system ${{ matrix.systems.system }} .#devenv-tasks-fast
45+
nix build -L --show-trace --print-out-paths --system ${{ inputs.system }} .#devenv-tasks-fast

.github/workflows/examples.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ on:
88
required: false
99
type: string
1010
system:
11-
description: "System to run examples on (optional, runs on all if not specified)"
12-
required: false
11+
description: "System to run examples on"
12+
required: true
13+
type: string
14+
runs-on:
15+
description: "Runner to use"
16+
required: true
1317
type: string
1418

1519
jobs:
@@ -30,28 +34,13 @@ jobs:
3034
echo "examples=$json" >> $GITHUB_OUTPUT
3135
3236
examples:
33-
name: ${{ matrix.example }} (${{ join(matrix.systems.runs-on) }})
37+
name: ${{ matrix.example }} (${{ inputs.system }})
3438
needs: [generate-examples]
3539
strategy:
3640
fail-fast: false
3741
matrix:
38-
systems: >-
39-
${{
40-
inputs.system && fromJSON(format('[{0}]',
41-
inputs.system == 'aarch64-linux' && '{"system": "aarch64-linux", "runs-on": ["self-hosted", "linux", "ARM64"]}' ||
42-
inputs.system == 'x86_64-linux' && '{"system": "x86_64-linux", "runs-on": ["self-hosted", "linux", "X64"]}' ||
43-
inputs.system == 'aarch64-darwin' && '{"system": "aarch64-darwin", "runs-on": ["self-hosted", "macOS", "ARM64"]}' ||
44-
inputs.system == 'x86_64-darwin' && '{"system": "x86_64-darwin", "runs-on": ["macos-13"]}' ||
45-
'{"system": "unknown", "runs-on": ["ubuntu-latest"]}'
46-
)) || fromJSON('[
47-
{"system": "aarch64-linux", "runs-on": ["self-hosted", "linux", "ARM64"]},
48-
{"system": "x86_64-linux", "runs-on": ["self-hosted", "linux", "X64"]},
49-
{"system": "aarch64-darwin", "runs-on": ["self-hosted", "macOS", "ARM64"]},
50-
{"system": "x86_64-darwin", "runs-on": ["macos-13"]}
51-
]')
52-
}}
5342
example: ${{ fromJSON(needs.generate-examples.outputs.examples) }}
54-
runs-on: ${{ matrix.systems.runs-on }}
43+
runs-on: ${{ fromJSON(inputs.runs-on) }}
5544
steps:
5645
- uses: actions/checkout@v5
5746
with:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Per-System Pipeline"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
system:
7+
description: "System to build, test, and run examples for"
8+
required: true
9+
type: string
10+
runs-on:
11+
description: "Runner to use for this system"
12+
required: true
13+
type: string
14+
ref:
15+
description: "Git ref to checkout"
16+
required: false
17+
type: string
18+
19+
jobs:
20+
build:
21+
uses: ./.github/workflows/build.yml
22+
secrets: inherit
23+
with:
24+
system: ${{ inputs.system }}
25+
runs-on: ${{ inputs.runs-on }}
26+
ref: ${{ inputs.ref }}
27+
28+
test:
29+
needs: build
30+
uses: ./.github/workflows/test.yml
31+
secrets: inherit
32+
with:
33+
system: ${{ inputs.system }}
34+
runs-on: ${{ inputs.runs-on }}
35+
ref: ${{ inputs.ref }}
36+
37+
examples:
38+
needs: test
39+
if: needs.test.result != 'skipped'
40+
uses: ./.github/workflows/examples.yml
41+
secrets: inherit
42+
with:
43+
system: ${{ inputs.system }}
44+
runs-on: ${{ inputs.runs-on }}
45+
ref: ${{ inputs.ref }}

.github/workflows/pin.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,22 @@ on:
1414
description: "Git ref to checkout"
1515
required: false
1616
type: string
17+
system:
18+
description: "System to pin for"
19+
required: true
20+
type: string
21+
runs-on:
22+
description: "Runner to use"
23+
required: true
24+
type: string
1725
secrets:
1826
CACHIX_AUTH_TOKEN:
1927
required: true
2028

2129
jobs:
2230
pin:
2331
if: startsWith(github.ref, 'refs/tags/v')
24-
25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
runs-on: [
29-
[self-hosted, linux, ARM64],
30-
[self-hosted, linux, X64],
31-
[self-hosted, macOS, ARM64],
32-
[self-hosted, macOS, X64],
33-
]
34-
35-
runs-on: ${{ matrix.runs-on }}
32+
runs-on: ${{ fromJSON(inputs.runs-on) }}
3633

3734
steps:
3835
- uses: actions/checkout@v5
@@ -52,4 +49,4 @@ jobs:
5249
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
5350

5451
- name: Pin release
55-
run: cachix pin devenv ${{ inputs.ref || github.ref_name }} $(nix build --accept-flake-config --print-out-paths)
52+
run: cachix pin devenv ${{ inputs.ref || github.ref_name }} $(nix build --accept-flake-config --print-out-paths --system ${{ inputs.system }})

.github/workflows/pr-test.yml

Lines changed: 19 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build & Test"
1+
name: "PR Test"
22

33
on:
44
pull_request:
@@ -13,87 +13,21 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
# Per-system job chains to avoid cross-system waiting
17-
build-aarch64-linux:
18-
uses: ./.github/workflows/build.yml
19-
secrets: inherit
20-
with:
21-
system: "aarch64-linux"
22-
23-
test-aarch64-linux:
24-
needs: build-aarch64-linux
25-
uses: ./.github/workflows/test.yml
26-
secrets: inherit
27-
with:
28-
system: "aarch64-linux"
29-
30-
examples-aarch64-linux:
31-
needs: test-aarch64-linux
32-
if: needs.test-aarch64-linux.result != 'skipped'
33-
uses: ./.github/workflows/examples.yml
34-
secrets: inherit
35-
with:
36-
system: "aarch64-linux"
37-
38-
build-x86_64-linux:
39-
uses: ./.github/workflows/build.yml
40-
secrets: inherit
41-
with:
42-
system: "x86_64-linux"
43-
44-
test-x86_64-linux:
45-
needs: build-x86_64-linux
46-
uses: ./.github/workflows/test.yml
47-
secrets: inherit
48-
with:
49-
system: "x86_64-linux"
50-
51-
examples-x86_64-linux:
52-
needs: test-x86_64-linux
53-
if: needs.test-x86_64-linux.result != 'skipped'
54-
uses: ./.github/workflows/examples.yml
55-
secrets: inherit
56-
with:
57-
system: "x86_64-linux"
58-
59-
build-aarch64-darwin:
60-
uses: ./.github/workflows/build.yml
61-
secrets: inherit
62-
with:
63-
system: "aarch64-darwin"
64-
65-
test-aarch64-darwin:
66-
needs: build-aarch64-darwin
67-
uses: ./.github/workflows/test.yml
68-
secrets: inherit
69-
with:
70-
system: "aarch64-darwin"
71-
72-
examples-aarch64-darwin:
73-
needs: test-aarch64-darwin
74-
if: needs.test-aarch64-darwin.result != 'skipped'
75-
uses: ./.github/workflows/examples.yml
76-
secrets: inherit
77-
with:
78-
system: "aarch64-darwin"
79-
80-
build-x86_64-darwin:
81-
uses: ./.github/workflows/build.yml
82-
secrets: inherit
83-
with:
84-
system: "x86_64-darwin"
85-
86-
test-x86_64-darwin:
87-
needs: build-x86_64-darwin
88-
uses: ./.github/workflows/test.yml
89-
secrets: inherit
90-
with:
91-
system: "x86_64-darwin"
92-
93-
examples-x86_64-darwin:
94-
needs: test-x86_64-darwin
95-
if: needs.test-x86_64-darwin.result != 'skipped'
96-
uses: ./.github/workflows/examples.yml
97-
secrets: inherit
98-
with:
99-
system: "x86_64-darwin"
16+
pipeline:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- system: aarch64-linux
22+
runs-on: '["self-hosted", "linux", "ARM64"]'
23+
- system: x86_64-linux
24+
runs-on: '["self-hosted", "linux", "X64"]'
25+
- system: aarch64-darwin
26+
runs-on: '["self-hosted", "macOS", "ARM64"]'
27+
- system: x86_64-darwin
28+
runs-on: '["macos-13"]'
29+
uses: ./.github/workflows/per-system-pipeline.yml
30+
secrets: inherit
31+
with:
32+
system: ${{ matrix.system }}
33+
runs-on: ${{ matrix.runs-on }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Release Per-System Pipeline"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
system:
7+
description: "System to build, test, and run examples for"
8+
required: true
9+
type: string
10+
runs-on:
11+
description: "Runner to use for this system"
12+
required: true
13+
type: string
14+
ref:
15+
description: "Git ref to checkout"
16+
required: false
17+
type: string
18+
19+
jobs:
20+
build:
21+
uses: ./.github/workflows/build.yml
22+
secrets: inherit
23+
with:
24+
system: ${{ inputs.system }}
25+
runs-on: ${{ inputs.runs-on }}
26+
ref: ${{ inputs.ref }}
27+
28+
pin:
29+
needs: build
30+
uses: ./.github/workflows/pin.yml
31+
secrets: inherit
32+
with:
33+
system: ${{ inputs.system }}
34+
runs-on: ${{ inputs.runs-on }}
35+
ref: ${{ inputs.ref }}
36+
37+
test:
38+
needs: build
39+
uses: ./.github/workflows/test.yml
40+
secrets: inherit
41+
with:
42+
system: ${{ inputs.system }}
43+
runs-on: ${{ inputs.runs-on }}
44+
ref: ${{ inputs.ref }}
45+
46+
examples:
47+
needs: test
48+
# Allow tests to fail
49+
if: needs.test.result != 'skipped'
50+
uses: ./.github/workflows/examples.yml
51+
secrets: inherit
52+
with:
53+
system: ${{ inputs.system }}
54+
runs-on: ${{ inputs.runs-on }}
55+
ref: ${{ inputs.ref }}

0 commit comments

Comments
 (0)