From 99ba57319e0a1331a032643990add86667b2d32d Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Thu, 15 Feb 2024 22:51:27 -0500 Subject: [PATCH] automatically collect tests --- .github/workflows/bin/collect_tests.py | 16 ++++++++++++++++ .github/workflows/ci.yml | 25 +++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/bin/collect_tests.py diff --git a/.github/workflows/bin/collect_tests.py b/.github/workflows/bin/collect_tests.py new file mode 100644 index 0000000..74946cc --- /dev/null +++ b/.github/workflows/bin/collect_tests.py @@ -0,0 +1,16 @@ +import json +import os + + +if __name__ == "__main__": + script_dir = os.path.dirname(os.path.abspath(__file__)) + repo_dir = os.path.abspath(os.path.join(script_dir, '..', '..', '..')) + tests = [] + for dirpath, dirnames, filenames in os.walk(repo_dir): + for f in filenames: + if f.startswith("test_"): + tests.append(os.path.join(dirpath, f)) + + tests_rel = [os.path.relpath(p, repo_dir) for p in tests] + + print(json.dumps({"testbench": tests_rel})) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7530f0f..daaf5fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,29 @@ on: workflow_dispatch: jobs: + get_testbenches: + name: 'Get testbenches' + + runs-on: ubuntu-latest + + outputs: + testbenches: ${{ steps.tests.outputs.tests }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Collect testbenches + id: tests + run: | + echo "tests=$(python3 .github/workflows/bin/collect_tests.py)" >> $GITHUB_OUTPUT + testbench: + needs: get_testbenches strategy: fail-fast: false - matrix: - testbench: [lumi/testbench/test_lumi.py, lumi/testbench/test_lumi_rnd.py, umi/testbench/test_crossbar.py, umi/testbench/test_fifo_flex.py, umi/testbench/test_fifo.py, umi/testbench/test_mem_agent.py, umi/testbench/test_regif.py, utils/testbench/test_umi_address_remap.py, utils/testbench/test_umi_packet_merge_greedy.py, utils/testbench/test_umi2tl_np.py] - + matrix: ${{ fromJson(needs.get_testbenches.outputs.testbenches) }} + timeout-minutes: 10 runs-on: ubuntu-latest container: @@ -23,7 +40,7 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - + - name: Install requirements run: | python3 -m venv .venv