Skip to content

Commit c167397

Browse files
committed
feat: parallelize build per (kernel_version, arch)
Generate the build matrix dynamically from kernel_versions.txt so each (version, arch) pair runs on its own runner. With N versions × 2 archs that's 2N parallel jobs (e.g. 2 versions -> 4 runners). build.sh already supports single-version mode, so no script changes; the matrix job emits a JSON include list that the build job fans out over.
1 parent 8eab674 commit c167397

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,44 @@ permissions:
99
id-token: write
1010

1111
jobs:
12+
matrix:
13+
runs-on: ubuntu-24.04
14+
outputs:
15+
build_matrix: ${{ steps.gen.outputs.matrix }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- id: gen
19+
run: |
20+
python3 - >> "$GITHUB_OUTPUT" <<'PY'
21+
import json
22+
versions = []
23+
for line in open("kernel_versions.txt").read().splitlines():
24+
v = line.split("#", 1)[0].strip()
25+
if v:
26+
versions.append(v)
27+
include = []
28+
for v in versions:
29+
include.append({"version": v, "arch": "amd64", "target_arch": "x86_64", "runner": "ubuntu-24.04"})
30+
include.append({"version": v, "arch": "arm64", "target_arch": "arm64", "runner": "ubuntu-24.04-arm"})
31+
print(f"matrix={json.dumps({'include': include})}")
32+
PY
33+
1234
build:
13-
name: Build kernels (${{ matrix.arch }})
35+
needs: matrix
36+
name: Build ${{ matrix.version }} (${{ matrix.arch }})
1437
strategy:
1538
fail-fast: false
16-
matrix:
17-
include:
18-
- arch: amd64
19-
target_arch: x86_64
20-
runner: ubuntu-24.04
21-
- arch: arm64
22-
target_arch: arm64
23-
runner: ubuntu-24.04-arm
39+
matrix: ${{ fromJson(needs.matrix.outputs.build_matrix) }}
2440
runs-on: ${{ matrix.runner }}
2541
steps:
2642
- uses: actions/checkout@v4
2743

28-
- name: Build kernels
29-
run: sudo TARGET_ARCH=${{ matrix.target_arch }} ./build.sh
44+
- name: Build kernel
45+
run: sudo ./build.sh "${{ matrix.version }}" "${{ matrix.target_arch }}"
3046

3147
- uses: actions/upload-artifact@v4
3248
with:
33-
name: kernels-${{ matrix.arch }}
49+
name: kernel-${{ matrix.version }}-${{ matrix.arch }}
3450
path: ./builds
3551
retention-days: 7
3652

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This project builds custom Linux kernels for Firecracker microVMs from the same
2929

3030
The **Build & Release** workflow runs in two modes:
3131

32-
- **On every pull request**: builds every kernel in `kernel_versions.txt` for `amd64` and `arm64` in parallel and uploads the binaries as workflow artifacts (downloadable from the PR's checks tab) so reviewers can inspect them. No release or GCS upload happens.
32+
- **On every pull request**: builds every (kernel version × arch) combination from `kernel_versions.txt` in parallel (one runner per pair) and uploads the binaries as workflow artifacts (downloadable from the PR's checks tab) so reviewers can inspect them. No release or GCS upload happens.
3333
- **Manually (workflow_dispatch)**: pick the branch in the GitHub UI and run. It does the same build as a PR and additionally creates a GitHub release tagged `YYYY.MM.DD` (with a `.N` suffix for additional runs the same day) containing every binary, and uploads them to GCS.
3434

3535
Release asset naming for that commit:

0 commit comments

Comments
 (0)