From 1ac463c36edfcbb37dae40d895e20c07700d712f Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Tue, 24 Oct 2023 23:26:03 -0700 Subject: [PATCH] workflow: a reusable workflow to kick a build/test/veristat *PER* arch/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. Signed-off-by: Manu Bretelle --- .github/scripts/matrix.py | 10 +++- .github/workflows/kernel-build-test.yml | 74 +++++++++++++++++++++++++ .github/workflows/kernel-test.yml | 5 +- .github/workflows/test.yml | 39 +++---------- 4 files changed, 95 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/kernel-build-test.yml diff --git a/.github/scripts/matrix.py b/.github/scripts/matrix.py index 4e8ef4c7..a3bbcf21 100644 --- a/.github/scripts/matrix.py +++ b/.github/scripts/matrix.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +from copy import deepcopy from json import dumps from enum import Enum import os @@ -120,7 +121,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 = { diff --git a/.github/workflows/kernel-build-test.yml b/.github/workflows/kernel-build-test.yml new file mode 100644 index 00000000..8fd89980 --- /dev/null +++ b/.github/workflows/kernel-build-test.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/kernel-test.yml b/.github/workflows/kernel-test.yml index 4a021244..e1af14a8 100644 --- a/.github/workflows/kernel-test.yml +++ b/.github/workflows/kernel-test.yml @@ -36,6 +36,9 @@ jobs: REPO_ROOT: ${{ github.workspace }} REPO_PATH: "" KBUILD_OUTPUT: kbuild-output/ + # https://github.com/actions/runner/issues/1483#issuecomment-1031671517 + # booleans are weird in GH. + CONTINUE_ON_ERROR: ${{ inputs.continue_on_error }} steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 @@ -59,7 +62,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}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fa4c17e..e677b22a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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) }} @@ -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 }}