Skip to content

[build system] allow using pre-built emulator to run tests #872

[build system] allow using pre-built emulator to run tests

[build system] allow using pre-built emulator to run tests #872

Workflow file for this run

name: PR
on: [pull_request]
env:
USER: runner
jobs:
gen-matrix:
name: Generate test matrix
runs-on: [self-hosted, linux]
env:
RUNNERS: 16
outputs:
ci-tests: ${{ steps.ci-tests.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- run: sudo -E .github/setup-actions.sh
env:
AWS_CREDENTIALS: ${{secrets.AWS_CREDENTIALS}}
CACHE_PRIV_KEY: ${{secrets.CACHE_PRIV_KEY}}
CACHE_DOMAIN: ${{secrets.CACHE_DOMAIN}}
ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY: ${{secrets.ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY}}
ROCKETCHIP_NIX_REMOTE_HOST: ${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}
- uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
post-build-hook = /etc/nix/upload-to-cache.sh
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= minio.inner.fi.c-3.moe:gDg5SOIH65O0tTV89dUawME5BTmduWWaA7as/cqvevM=
extra-substituters = https://${{secrets.CACHE_DOMAIN}}/nix
max-jobs = 0
builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key
builders-use-substitutes = true
- id: ci-tests
run: |
nix develop '.#ci' --show-trace -c make ci-passed-tests DEFAULT_PASSED=.github/passed/default.txt
ci:
name: "CI"
needs: [gen-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-matrix.outputs.ci-tests) }}
runs-on: [self-hosted, linux]
outputs:
result: ${{ steps.ci-run.outputs.result }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: sudo -E .github/setup-actions.sh
env:
AWS_CREDENTIALS: ${{secrets.AWS_CREDENTIALS}}
CACHE_PRIV_KEY: ${{secrets.CACHE_PRIV_KEY}}
CACHE_DOMAIN: ${{secrets.CACHE_DOMAIN}}
ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY: ${{secrets.ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY}}
ROCKETCHIP_NIX_REMOTE_HOST: ${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}
- uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
post-build-hook = /etc/nix/upload-to-cache.sh
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= minio.inner.fi.c-3.moe:gDg5SOIH65O0tTV89dUawME5BTmduWWaA7as/cqvevM=
extra-substituters = https://${{secrets.CACHE_DOMAIN}}/nix
sandbox = relaxed
max-jobs = 0
builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key
builders-use-substitutes = true
- id: ci-run
run: |
nix develop '.#ci' -c make ci-run "NAME=${{ matrix.name }}"
- uses: actions/upload-artifact@v3
if: always()
with:
name: results
path: |
test-log/**/fail-test-*.md
test-log/result-*
- uses: actions/upload-artifact@v3
if: failure()
with:
name: fail-log
path: ./test-log/fail/*
- uses: actions/upload-artifact@v3
if: always()
with:
name: nix-post-build-hook-log
path: /tmp/nix-post-build-hook.log
gen-fail-wave:
name: "Generate wave for failing test"
if: always()
needs: [ci]
runs-on: [self-hosted, linux]
outputs:
generate_wave: ${{ steps.filter-fail-jobs.outputs.generate_wave }}
retry_tasks: ${{ steps.filter-fail-jobs.outputs.retry_tasks }}
steps:
- uses: actions/download-artifact@v3
with:
name: results
- id: filter-fail-jobs
name: fileter-fail-jobs
run: |
touch all-fail-tests.txt
find . -name 'fail-test-*.md' -exec bash -c 'cat {} >> all-fail-tests.txt' \;
retry=$(sed 's/\* //' all-fail-tests.txt | tail -n3)
[[ -n "$retry" ]] \
&& echo "generate_wave=true" >> "$GITHUB_OUTPUT" \
&& echo "$retry" | jq -n --indent 0 "{include:[{name: inputs}]}"
build-fail-wave:
name: "Generate wave for failing tests"
needs: [gen-fail-wave]
if: ${{ needs.gen-fail-wave.outputs.generate_wave == 'true' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.gen-fail-wave.outputs.retry_tasks) }}
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: sudo -E .github/setup-actions.sh
env:
AWS_CREDENTIALS: ${{secrets.AWS_CREDENTIALS}}
CACHE_PRIV_KEY: ${{secrets.CACHE_PRIV_KEY}}
CACHE_DOMAIN: ${{secrets.CACHE_DOMAIN}}
ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY: ${{secrets.ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY}}
ROCKETCHIP_NIX_REMOTE_HOST: ${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}
- uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
post-build-hook = /etc/nix/upload-to-cache.sh
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= minio.inner.fi.c-3.moe:gDg5SOIH65O0tTV89dUawME5BTmduWWaA7as/cqvevM=
extra-substituters = https://${{secrets.CACHE_DOMAIN}}/nix
sandbox = relaxed
max-jobs = 0
builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key
builders-use-substitutes = true
- run: |
millTask=$(echo ${{ matrix.name }} | sed 's/v1024l8b2-test/v1024l8b2-test-trace/')
nix develop '.#ci' -c mill -i "$millTask"
waveFile=$(find out -name 'wave.fst')
hierFile=$(find out -name 'wave.hier')
if [[ -z "$waveFile" || -n "$hierFile" ]]; then
echo "Verilator doesn't generate wave correctly"
exit 1
fi
mv "$waveFile" ./wave-"$millTask".fst
- uses: actions/upload-artifact@v3
with:
name: fail-test-wave
path: './*.fst'
report:
name: "Report CI result"
if: always()
needs: [ci]
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: cachix/install-nix-action@v19
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-unstable
- uses: actions/download-artifact@v3
with:
name: results
- run: |
echo -e "\n## Fail tests\n" >> $GITHUB_STEP_SUMMARY
find . -name 'fail-test-*.md' -exec bash -c 'cat {} >> $GITHUB_STEP_SUMMARY' \;
- run: |
echo -e "\n## Cycle update\n" >> $GITHUB_STEP_SUMMARY
find . -name 'result.md' -exec bash -c 'cat {} >> $GITHUB_STEP_SUMMARY' \;
- run: |
nix-shell -p ammonite --run 'amm .github/scripts/ci.sc mergeCycleData .'
git config user.name github-actions
git config user.email [email protected]
git diff -s --exit-code '.github/passed/**/passed.json' \
|| (git add '.github/passed/**/passed.json' \
&& git commit -m "[ci] update test case cycle data" \
&& git push origin ${{ github.head_ref }})