From fda80cf1a3cbf3a681f18cf01454e0fcfefdfa1b Mon Sep 17 00:00:00 2001 From: Avimitin Date: Mon, 14 Oct 2024 15:09:41 +0800 Subject: [PATCH] [ci] add multiple top support for emulator tests Signed-off-by: Avimitin --- .github/readme.md | 22 +++++++++++++++++ .github/workflows/t1rocket.yml | 34 ++++++++++++++------------ .github/workflows/trace.yml | 43 +++++++++++++++++++++++++++------ .github/workflows/vcs.yml | 18 ++++++++------ .github/workflows/verilator.yml | 33 +++++++++---------------- 5 files changed, 98 insertions(+), 52 deletions(-) create mode 100644 .github/readme.md diff --git a/.github/readme.md b/.github/readme.md new file mode 100644 index 000000000..54cb10074 --- /dev/null +++ b/.github/readme.md @@ -0,0 +1,22 @@ +Current test flow +----------------- + +```mermaid +stateDiagram-v2 + state "GitHub CI Action" as github_ci + state generateTestPlan { + state "read .github/designs/**/*.json" as read_config + state "parse config info" as parse_config + read_config --> parse_config + } + parse_config --> github_ci + state "Build emulator before test" as prebuild_emulator + github_ci --> prebuild_emulator + state "Generate test matrix" as generate_matrix + prebuild_emulator --> generate_matrix + generate_matrix --> github_ci + state "Dispatch tests to machine" as run_test + github_ci --> run_test + state "Collect results" as report + run_test --> report +``` diff --git a/.github/workflows/t1rocket.yml b/.github/workflows/t1rocket.yml index 92945dfdd..bb510c03f 100644 --- a/.github/workflows/t1rocket.yml +++ b/.github/workflows/t1rocket.yml @@ -1,4 +1,4 @@ -name: T1 Rocket VCS Emulator Test +name: T1RocketEmu VCS Test on: pull_request: types: @@ -9,6 +9,7 @@ on: - labeled env: USER: runner + EMU_TOP: t1rocketemu # Cancel the current workflow when new commit pushed concurrency: @@ -27,10 +28,10 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - id: "get-all-configs" - run: echo "out=$(nix run .#ci-helper -- generateTestPlan)" > $GITHUB_OUTPUT + run: echo "out=$(nix run .#ci-helper -- generateTestPlan --top ${{ env.EMU_TOP }})" > $GITHUB_OUTPUT build-emulators: - name: "Build VCS Emulators w/ Rocket" + name: "Build VCS Emulators" needs: [gen-test-plan] runs-on: [self-hosted, linux, nixos, BIGRAM] strategy: @@ -42,10 +43,10 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Build vcs emulator" run: | - nix build '.#t1.${{ matrix.config }}.t1rocketemu.vcs-emu' --impure --no-link + nix build '.#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.vcs-emu' --impure --no-link - name: "Build all testcases" run: | - nix build ".#t1.${{ matrix.config }}.t1rocketemu.cases._all" --max-jobs auto --no-link --cores 64 + nix build ".#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.cases._all" --max-jobs auto --no-link --cores 64 gen-matrix: name: "Prepare for running testcases" @@ -66,10 +67,10 @@ jobs: name: "Generate test matrix" run: | echo -n matrix= >> "$GITHUB_OUTPUT" - nix run ".#ci-helper" -- generateCiMatrix --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" + nix run ".#ci-helper" -- generateCiMatrix --top ${{ env.EMU_TOP }} --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" run-testcases: - name: "Run VCS w/ Rocket" + name: "Run VCS" needs: [gen-matrix] strategy: fail-fast: false @@ -81,10 +82,10 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Run testcases" run: | - nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --testType "vcs" --testIp "t1rocketemu" + nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --emuLib "vcs" --top ${{ env.EMU_TOP }} report: - name: "Report VCS (w/ Rocket) CI result" + name: "Report VCS CI result" # Don't run report when: # - user cancel ( we don't need report at this case ) # - PR from outside repository ( we don't have permission to push commit into fork repository ) @@ -101,23 +102,26 @@ jobs: - name: "Print step summary" run: | nix run ".#ci-helper" -- postCI \ - --case-dir t1rocket-cases \ - --failed-tests-file-path ./failed-tests.md \ + --urg-report-file-path ./urg-report.md \ --cycle-update-file-path ./cycle-update.md \ - --emu-type vcs - cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY + --failed-tests-file-path ./failed-tests.md \ + --emu-lib "vcs" \ + --top ${{ env.EMU_TOP }} + cat ./urg-report.md >> $GITHUB_STEP_SUMMARY echo >> $GITHUB_STEP_SUMMARY cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY + echo >> $GITHUB_STEP_SUMMARY + cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY - name: "Commit cycle updates" run: | git config user.name github-actions git config user.email github-actions@github.com - changed_cases=$(git diff --name-only '.github/**/default.json') + changed_cases=$(git diff --name-only '.github/designs/**/*.json') if [ -n "$changed_cases" ]; then echo "changed cases: $changed_cases" git add '.github/**/default.json' - git commit -m "[ci] update t1rocket test case cycle data" + git commit -m "[ci] update t1 test case cycle data" git push origin ${{ github.head_ref }} else echo "No cycle change detect" diff --git a/.github/workflows/trace.yml b/.github/workflows/trace.yml index f153aeba5..27d9fd627 100644 --- a/.github/workflows/trace.yml +++ b/.github/workflows/trace.yml @@ -16,9 +16,9 @@ concurrency: cancel-in-progress: true jobs: - gen-test-plan: + gen-test-plan-for-t1emu: if: '! github.event.pull_request.draft' - name: "Generate test plan" + name: "[T1EMU] Generate test plan" runs-on: [self-hosted, linux, nixos] outputs: testplan: ${{ steps.get-all-configs.outputs.out }} @@ -27,20 +27,47 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - id: "get-all-configs" - run: echo "out=$(nix run .#ci-helper generateTestPlan)" > $GITHUB_OUTPUT + run: echo "out=$(nix run .#ci-helper -- generateTestPlan --top t1emu)" > $GITHUB_OUTPUT - build-vcs-emulators: - name: "Build VCS trace emulators" - needs: [gen-test-plan] + build-t1emu-vcs-emulators: + name: "[T1EMU] Build VCS trace emulators" + needs: [gen-test-plan-for-t1emu] runs-on: [self-hosted, linux, nixos, BIGRAM] strategy: fail-fast: false - matrix: ${{ fromJSON(needs.gen-test-plan.outputs.testplan) }} + matrix: ${{ fromJSON(needs.gen-test-plan-for-t1emu.outputs.testplan) }} steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - - name: "Build vcs emulator" + - name: "Build T1Emu vcs emulator" run: | nix build '.#t1.${{ matrix.config }}.t1emu.vcs-emu-trace' --impure --no-link --cores 64 + + gen-test-plan-for-t1rocketemu: + if: '! github.event.pull_request.draft' + name: "[T1ROCKETEMU] Generate test plan" + runs-on: [self-hosted, linux, nixos] + outputs: + testplan: ${{ steps.get-all-configs.outputs.out }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - id: "get-all-configs" + run: echo "out=$(nix run .#ci-helper -- generateTestPlan --top t1rocketemu)" > $GITHUB_OUTPUT + + build-t1rocketemu-vcs-emulators: + name: "[T1EMU] Build VCS trace emulators" + needs: [gen-test-plan-for-t1rocketemu] + runs-on: [self-hosted, linux, nixos, BIGRAM] + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.gen-test-plan-for-t1rocketemu.outputs.testplan) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Build T1RocketEmu vcs emulator" + run: | nix build '.#t1.${{ matrix.config }}.t1rocketemu.vcs-emu-trace' --impure --no-link --cores 64 diff --git a/.github/workflows/vcs.yml b/.github/workflows/vcs.yml index 52ca5d0af..5a8da0c62 100644 --- a/.github/workflows/vcs.yml +++ b/.github/workflows/vcs.yml @@ -1,4 +1,4 @@ -name: T1 VCS Emulator Test +name: T1Emu VCS Test on: pull_request: types: @@ -9,6 +9,7 @@ on: - labeled env: USER: runner + EMU_TOP: t1emu # Cancel the current workflow when new commit pushed concurrency: @@ -27,7 +28,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - id: "get-all-configs" - run: echo "out=$(nix run .#ci-helper generateTestPlan)" > $GITHUB_OUTPUT + run: echo "out=$(nix run .#ci-helper -- generateTestPlan --top ${{ env.EMU_TOP }})" > $GITHUB_OUTPUT build-emulators: name: "Build VCS Emulators" @@ -42,10 +43,10 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Build vcs emulator" run: | - nix build '.#t1.${{ matrix.config }}.t1emu.vcs-emu' --impure --no-link + nix build '.#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.vcs-emu' --impure --no-link - name: "Build all testcases" run: | - nix build ".#t1.${{ matrix.config }}.t1emu.cases._all" --max-jobs auto --no-link --cores 64 + nix build ".#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.cases._all" --max-jobs auto --no-link --cores 64 gen-matrix: name: "Prepare for running testcases" @@ -66,7 +67,7 @@ jobs: name: "Generate test matrix" run: | echo -n matrix= >> "$GITHUB_OUTPUT" - nix run ".#ci-helper" -- generateCiMatrix --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" + nix run ".#ci-helper" -- generateCiMatrix --top ${{ env.EMU_TOP }} --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" run-testcases: name: "Run VCS" @@ -81,7 +82,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Run testcases" run: | - nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --testType "vcs" --testIp "t1emu" + nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --emuLib "vcs" --top ${{ env.EMU_TOP }} report: name: "Report VCS CI result" @@ -104,7 +105,8 @@ jobs: --urg-report-file-path ./urg-report.md \ --cycle-update-file-path ./cycle-update.md \ --failed-tests-file-path ./failed-tests.md \ - --emu-type vcs + --emu-lib "vcs" \ + --top ${{ env.EMU_TOP }} cat ./urg-report.md >> $GITHUB_STEP_SUMMARY echo >> $GITHUB_STEP_SUMMARY cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY @@ -114,7 +116,7 @@ jobs: run: | git config user.name github-actions git config user.email github-actions@github.com - changed_cases=$(git diff --name-only '.github/**/default.json') + changed_cases=$(git diff --name-only '.github/designs/**/*.json') if [ -n "$changed_cases" ]; then echo "changed cases: $changed_cases" diff --git a/.github/workflows/verilator.yml b/.github/workflows/verilator.yml index 18362566c..19089533c 100644 --- a/.github/workflows/verilator.yml +++ b/.github/workflows/verilator.yml @@ -1,9 +1,12 @@ -name: Verilator Daily Regression +name: T1Emu Verilator Daily Regression on: schedule: # Run this job everyday at 6:30 AM UTC+8 - cron: '30 22 * * *' +env: + EMU_TOP: t1emu + jobs: gen-test-plan: name: "Generate test plan" @@ -15,7 +18,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - id: "get-all-configs" - run: echo "out=$(nix run .#ci-helper generateTestPlan)" > $GITHUB_OUTPUT + run: echo "out=$(nix run .#ci-helper -- generateTestPlan --top ${{ env.EMU_TOP }})" > $GITHUB_OUTPUT build-verilator-emulators: name: "Build Verilator Emulators" @@ -30,11 +33,11 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Build verilator emulator" run: | - nix build '.#t1.${{ matrix.config }}.t1emu.verilator-emu' -L --no-link --cores 64 + nix build '.#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.verilator-emu' -L --no-link --cores 64 - name: "Build all testcases" run: | # Build testcases with vlen 1024 and vlen 4096 - nix build ".#t1.${{ matrix.config }}.t1emu.cases._all" --max-jobs auto -L --no-link --cores 64 + nix build ".#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.cases._all" --max-jobs auto -L --no-link --cores 64 # In the future, we may choose Verdi for trace, and left verilator trace only for performance evaluation build-verilator-trace-emulators: @@ -49,7 +52,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: "Build verilator emulator with trace" - run: nix build '.#t1.${{ matrix.config }}.t1emu.verilator-emu-trace' -L --no-link --cores 64 + run: nix build '.#t1.${{ matrix.config }}.${{ env.EMU_TOP }}.verilator-emu-trace' -L --no-link --cores 64 gen-matrix: name: "Prepare for running testcases" @@ -70,7 +73,7 @@ jobs: name: "Generate test matrix" run: | echo -n matrix= >> "$GITHUB_OUTPUT" - nix run ".#ci-helper" -- generateCiMatrix --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" + nix run ".#ci-helper" -- generateCiMatrix --top ${{ env.EMU_TOP }} --runnersAmount "$RUNNERS" >> "$GITHUB_OUTPUT" run-testcases: name: "Run testcases" @@ -85,7 +88,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: "Run testcases" run: | - nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --testType "verilator" --testIp "t1emu" + nix run ".#ci-helper" -- runTests --jobs "${{ matrix.jobs }}" --emuLib "verilator" --top ${{ env.EMU_TOP }} report: name: "Report CI result" @@ -107,20 +110,8 @@ jobs: nix run ".#ci-helper" -- postCI \ --failed-tests-file-path ./failed-tests.md \ --cycle-update-file-path ./cycle-update.md + --emu-lib "verilator" \ + --top ${{ env.EMU_TOP }} cat ./failed-tests.md >> $GITHUB_STEP_SUMMARY echo >> $GITHUB_STEP_SUMMARY cat ./cycle-update.md >> $GITHUB_STEP_SUMMARY - - name: "Commit cycle updates" - run: | - git config user.name github-actions - git config user.email github-actions@github.com - changed_cases=$(git diff --name-only '.github/**/default.json') - - if [ -n "$changed_cases" ]; then - echo "changed cases: $changed_cases" - git add '.github/**/default.json' - git commit -m "[ci] update test case cycle data" - git push origin ${{ github.head_ref }} - else - echo "No cycle change detect" - fi