Skip to content

Commit

Permalink
implement a test build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Nov 14, 2024
1 parent 7de487f commit 231dd0e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Kernel Build
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
packages: read
env:
TEST_MATRIX_SPEC: "only-latest:flavor=zone"
jobs:
test:
name: matrix
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive
- name: install dependencies
run: ./hack/build/install-matrix-deps.sh
- name: generate spec-new matrix
run: 'PATH="${HOME}/go/bin:${PATH}" KERNEL_BUILD_SPEC="new" ./hack/build/generate-matrix.sh'
- name: upload spec-new matrix
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: spec-new-matrix
path: "matrix.json"
compression-level: 0
- name: generate spec-rebuild matrix
run: 'PATH="${HOME}/go/bin:${PATH}" KERNEL_BUILD_SPEC="rebuild" ./hack/build/generate-matrix.sh'
- name: upload spec-rebuild matrix
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: spec-rebuild-matrix
path: "matrix.json"
compression-level: 0
- name: generate test matrix
run: 'PATH="${HOME}/go/bin:${PATH}" KERNEL_BUILD_SPEC="${TEST_MATRIX_SPEC}" ./hack/build/generate-matrix.sh'
- name: upload test matrix
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: test-matrix
path: "matrix.json"
compression-level: 0
- name: docker setup linux-kernel-oci
run: sudo python3 ./hack/build/docker-setup.py
- name: docker setup buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: docker login ghcr.io
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: "${{github.actor}}"
password: "${{secrets.GITHUB_TOKEN}}"
- name: generate docker script
run: './hack/build/generate-docker-script.sh matrix.json'
- name: upload docker script
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: "build-${{ matrix.builds.version }}-${{ matrix.builds.flavor }}.sh"
path: "docker.sh"
compression-level: 0
- name: run docker script
run: sh -x docker.sh
11 changes: 11 additions & 0 deletions hack/build/generate-matrix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import os

from packaging.version import Version

import matrix
from util import parse_text_constraint, maybe

Expand Down Expand Up @@ -53,6 +55,15 @@ def construct_manual_matrix(exact_versions):
apply_config_versions = False
elif build_spec_type == "stable":
first_matrix = construct_stable_matrix()
elif build_spec_type == "only-latest":
first_matrix = construct_stable_matrix()
apply_config_versions = False
first_matrix["builds"].sort(key=lambda build: Version(build["version"]))
last_version = first_matrix["builds"][-1]["version"]
last_version_builds = list(filter(lambda build: build["version"] == last_version, first_matrix["builds"]))
first_matrix = {
"builds": last_version_builds,
}
elif build_spec_type == "override":
first_matrix = construct_all_matrix()
apply_config_versions = False
Expand Down

0 comments on commit 231dd0e

Please sign in to comment.