From 51be55d2a356324f01f85f7cfac2c585e80c777f Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Mon, 24 Apr 2023 21:32:37 +0200 Subject: [PATCH] Dynamic generation of the CI test matrix (#52) * Added a Python script for test name extraction Signed-off-by: Maciej Kurc * Added dynamic building of the CI regression test matrix Signed-off-by: Maciej Kurc * Changed rv32imac to rv32imc in the Makefile for tests Signed-off-by: Maciej Kurc --------- Signed-off-by: Maciej Kurc --- .github/scripts/build_tests_matrix.py | 30 ++++++++++++++++++++++ .github/workflows/build-test-verilator.yml | 24 ++++++++++++++++- tools/scripts/Makefile | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/build_tests_matrix.py diff --git a/.github/scripts/build_tests_matrix.py b/.github/scripts/build_tests_matrix.py new file mode 100644 index 000000000..a3bb3329e --- /dev/null +++ b/.github/scripts/build_tests_matrix.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +import yaml + +def main(): + + # Load and parse YAML description + file_name = "src/integration/stimulus/L0_regression.yml" + with open(file_name, "r") as fp: + yaml_root = yaml.safe_load(fp) + + # Get test list + content = yaml_root["contents"][0] + tests = content["tests"] + paths = tests["paths"] + + # Extract test names from paths + test_list = [] + for path in paths: + parts = path.split("/") + + for i, part in enumerate(parts): + if part == "test_suites" and i + 1 < len(parts): + test_list.append(parts[i+1]) + break + + # Output names + print(test_list) + +if __name__ == "__main__": + main() diff --git a/.github/workflows/build-test-verilator.yml b/.github/workflows/build-test-verilator.yml index b639a7f14..3eba0e845 100644 --- a/.github/workflows/build-test-verilator.yml +++ b/.github/workflows/build-test-verilator.yml @@ -10,9 +10,31 @@ on: workflow_dispatch: jobs: + build_matrix: + name: Build Smoke Test matrix + runs-on: ubuntu-22.04 + outputs: + test_names: ${{ steps.output-matrix.outputs.test_names }} + steps: + - uses: actions/checkout@v3 + - name: Install deps + run: | + sudo apt-get update -qy && sudo apt-get install -qy --no-install-recommends \ + python3-minimal python3-yaml + - name: Build matrix + id: output-matrix + run: | + echo "test_names=$(python3 .github/scripts/build_tests_matrix.py)" >> $GITHUB_OUTPUT + build_and_test: name: Verilator Smoke Test runs-on: ubuntu-22.04 + needs: build_matrix + + strategy: + fail-fast: false + matrix: + test_name: ${{fromJSON(needs.build_matrix.outputs.test_names)}} env: CARGO_INCREMENTAL: 0 @@ -123,4 +145,4 @@ jobs: # Running a simple test to make sure that there aren't any elaboration issues CALIPTRA_ROOT=$(pwd) cd tools/scripts - make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT TESTNAME=smoke_test_kv_uds_reset + make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT TESTNAME=${{ matrix.test_name }} diff --git a/tools/scripts/Makefile b/tools/scripts/Makefile index 6245042f8..21fdf8fbe 100755 --- a/tools/scripts/Makefile +++ b/tools/scripts/Makefile @@ -15,7 +15,7 @@ # TEST_CFLAGS = -g -O3 -ABI = -mabi=ilp32 -march=rv32imac +ABI = -mabi=ilp32 -march=rv32imc VERILATOR = verilator GCC_PREFIX = riscv64-unknown-elf