Skip to content

Commit

Permalink
workflow: a reusable workflow to kick a build/test/veristat *PER* arc…
Browse files Browse the repository at this point in the history
…h/toolchain

matrix.py was modified to embed the tests in the build-matrics, this way
we can trigger all tests within 1 workflow without needing to do some filtering in the GH action side.
  • Loading branch information
chantra committed Oct 25, 2023
1 parent c75f8d4 commit bb192fa
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 33 deletions.
10 changes: 9 additions & 1 deletion .github/scripts/matrix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

from copy import deepcopy
from json import dumps
from enum import Enum
import os
Expand Down Expand Up @@ -122,7 +123,14 @@ def get_tests(config):
for idx in range(len(matrix) - 1, -1, -1):
matrix[idx]["runs_on"].extend(["self-hosted", matrix[idx]["arch"]])

build_matrix = {"include": matrix}
build_matrix = {"include": deepcopy(matrix)}
# include test configs directly with the build config
for config in build_matrix["include"]:
config["tests"] = {"include": [
generate_test_config(test)
for test in get_tests(config)
]}

set_output("build_matrix", dumps(build_matrix))

test_matrix = {
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/kernel-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Reusable Build/Test/Veristat workflow

on:
workflow_call:
inputs:
arch:
required: true
type: string
toolchain_full:
required: true
type: string
toolchain:
required: true
type: string
runs_on:
required: true
type: string
llvm-version:
required: true
type: string
kernel:
required: true
type: string
tests:
required: true
type: string
veristat_runs_on:
required: true
type: string
secrets:
AWS_ROLE_ARN:
required: true

jobs:
# Build kernel and selftest
build:
uses: ./.github/workflows/kernel-build.yml
with:
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
toolchain: ${{ inputs.toolchain }}
runs_on: ${{ inputs.runs_on }}
llvm-version: ${{ inputs.llvm-version }}
kernel: ${{ inputs.kernel }}

test:
uses: ./.github/workflows/kernel-test.yml
needs: [build]
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.tests) }}
with:
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
runs_on: ${{ inputs.runs_on }}
kernel: ${{ inputs.kernel }}
test: ${{ matrix.test }}
continue_on_error: ${{ toJSON(matrix.continue_on_error) }}
timeout_minutes: ${{ matrix.timeout_minutes }}

veristat:
if: ${{ inputs.arch == 'x86_64' && inputs.toolchain == 'gcc' }}
uses: ./.github/workflows/kernel-veristat.yml
needs: [build]
permissions:
id-token: write
contents: read
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
aws_region: ${{ vars.AWS_REGION }}
runs_on: ${{ inputs.veristat_runs_on }}
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
3 changes: 2 additions & 1 deletion .github/workflows/kernel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
REPO_ROOT: ${{ github.workspace }}
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
CONTINUE_ON_ERROR: ${{ inputs.continue_on_error }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
Expand All @@ -59,7 +60,7 @@ jobs:
uses: libbpf/ci/run-qemu@main
# https://github.com/actions/runner/issues/1483#issuecomment-1031671517
# booleans are weird in GH.
continue-on-error: ${{ fromJSON(inputs.continue_on_error) }}
continue-on-error: ${{ fromJSON(env.CONTINUE_ON_ERROR) }}
timeout-minutes: ${{ inputs.timeout_minutes }}
with:
arch: ${{ inputs.arch}}
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ jobs:
run: |
python3 .github/scripts/matrix.py
# Build kernel and selftest
build:
uses: ./.github/workflows/kernel-build.yml
needs: set-matrix
build-and-test:
uses: ./.github/workflows/kernel-build-test.yml
needs: [set-matrix]
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }}
Expand All @@ -50,32 +52,7 @@ jobs:
runs_on: ${{ toJSON(matrix.runs_on) }}
llvm-version: ${{ matrix.llvm-version }}
kernel: ${{ matrix.kernel }}

test:
uses: ./.github/workflows/kernel-test.yml
needs: [set-matrix, build]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }}
with:
arch: ${{ matrix.arch }}
toolchain_full: ${{ matrix.toolchain_full }}
runs_on: ${{ toJSON(matrix.runs_on) }}
kernel: ${{ matrix.kernel }}
test: ${{ matrix.test }}
continue_on_error: ${{ matrix.continue_on_error }}
timeout_minutes: ${{ matrix.timeout_minutes }}

veristat:
uses: ./.github/workflows/kernel-veristat.yml
needs: [set-matrix, build]
permissions:
id-token: write
contents: read
with:
arch: x86_64
toolchain: gcc
aws_region: ${{ vars.AWS_REGION }}
runs_on: ${{ fromJSON(needs.set-matrix.outputs.veristat-runs-on) }}
tests: ${{ toJSON(matrix.tests) }}
veristat_runs_on: ${{ needs.set-matrix.outputs.veristat-runs-on }}
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}

0 comments on commit bb192fa

Please sign in to comment.