Skip to content

Commit

Permalink
[ci] add multiple top support for emulator tests
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin authored and sequencer committed Oct 14, 2024
1 parent c8c22e4 commit fda80cf
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 52 deletions.
22 changes: 22 additions & 0 deletions .github/readme.md
Original file line number Diff line number Diff line change
@@ -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
```
34 changes: 19 additions & 15 deletions .github/workflows/t1rocket.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: T1 Rocket VCS Emulator Test
name: T1RocketEmu VCS Test
on:
pull_request:
types:
Expand All @@ -9,6 +9,7 @@ on:
- labeled
env:
USER: runner
EMU_TOP: t1rocketemu

# Cancel the current workflow when new commit pushed
concurrency:
Expand All @@ -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:
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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 )
Expand All @@ -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 [email protected]
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"
Expand Down
43 changes: 35 additions & 8 deletions .github/workflows/trace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
18 changes: 10 additions & 8 deletions .github/workflows/vcs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: T1 VCS Emulator Test
name: T1Emu VCS Test
on:
pull_request:
types:
Expand All @@ -9,6 +9,7 @@ on:
- labeled
env:
USER: runner
EMU_TOP: t1emu

# Cancel the current workflow when new commit pushed
concurrency:
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -114,7 +116,7 @@ jobs:
run: |
git config user.name github-actions
git config user.email [email protected]
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"
Expand Down
33 changes: 12 additions & 21 deletions .github/workflows/verilator.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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 [email protected]
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

0 comments on commit fda80cf

Please sign in to comment.