Test #458
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| # Run on pushes to the main branch | |
| push: | |
| branches: | |
| - main | |
| # Run on pull requests | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| # Run regularly at 12:00 UTC | |
| schedule: | |
| - cron: "0 12 * * *" | |
| # Run when triggered remotely from CIRCT | |
| workflow_dispatch: | |
| inputs: | |
| kind: { type: choice, options: [main, pr], required: true } | |
| sha: { type: string, required: true } | |
| repo: { type: string, required: false } | |
| pr_number: { type: number, required: false } | |
| jobs: | |
| run-tests: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ secrets.CIRCT_GITHUB_TOKEN }} | |
| container: | |
| image: ghcr.io/circt/images/circt-ci-build:20250515145637 | |
| steps: | |
| # Determine what triggered this build and under which category the results | |
| # should be archived. | |
| - name: Determine trigger | |
| id: trigger | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "kind=${{ inputs.kind }}" | |
| echo "ref=${{ inputs.sha }}" | |
| echo "repo=${{ inputs.repo || 'llvm/circt' }}" | |
| else | |
| echo "kind=main" | |
| echo "ref=main" | |
| echo "repo=llvm/circt" | |
| fi >> $GITHUB_OUTPUT | |
| # Checkout the repository. | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set git safe directory | |
| run: git config --global --add safe.directory $PWD | |
| # Checkout CIRCT. | |
| - name: Checkout CIRCT | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: ${{ steps.trigger.outputs.repo }} | |
| ref: ${{ steps.trigger.outputs.ref }} | |
| submodules: recursive | |
| path: circt | |
| fetch-depth: 200 | |
| # Install dependencies. | |
| - name: Install dependencies | |
| run: | | |
| apt-get update -qq | |
| apt install -y cpanminus gh | |
| pip3 install --user --break-system-packages termcolor | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| # Setup ccache to speed up builds. | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| max-size: 500M | |
| # Configure CIRCT. | |
| - name: Configure CIRCT | |
| run: | | |
| export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | |
| cmake -G Ninja circt/llvm/llvm -B circt/build \ | |
| -DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |
| -DCMAKE_C_COMPILER=clang \ | |
| -DCMAKE_CXX_COMPILER=clang++ \ | |
| -DLLVM_CCACHE_BUILD=ON \ | |
| -DLLVM_ENABLE_ASSERTIONS=ON \ | |
| -DLLVM_TARGETS_TO_BUILD=host \ | |
| -DLLVM_ENABLE_PROJECTS=mlir \ | |
| -DLLVM_EXTERNAL_PROJECTS=circt \ | |
| -DLLVM_EXTERNAL_CIRCT_SOURCE_DIR=$PWD/circt \ | |
| -DCIRCT_SLANG_FRONTEND_ENABLED=ON | |
| # Build and test CIRCT. | |
| - name: Build and Test CIRCT | |
| run: | | |
| ninja -C circt/build circt-verilog | |
| echo "$PWD/circt/build/bin" >> "$GITHUB_PATH" | |
| # Fetch all submodules needed to run the tests. Also clear any temporary | |
| # directories that happen to already exist. | |
| - name: Prepare for tests | |
| run: | | |
| utils/update-all.sh | |
| rm -rf build results | |
| # Run individual tests. | |
| - name: Compile Snitch | |
| run: verilog/snitch/compile.sh | |
| - name: Run sv-tests | |
| run: | | |
| verilog/sv-tests/install-deps.sh | |
| verilog/sv-tests/run.sh | |
| # Display some results. | |
| - name: Results for sv-tests | |
| run: cat results/sv-tests/errors.txt | |
| # Upload the results as an artifact. | |
| - name: Upload results artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: results | |
| compression-level: 9 | |
| path: results | |
| # Archive the `results` directory on the `results` branch. | |
| - name: Checkout results branch | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: results | |
| path: results-branch | |
| - name: Archive results | |
| id: archive | |
| run: | | |
| # Copy the results to the target location. | |
| COMMIT=$(git -C circt rev-parse --short HEAD) | |
| KIND="${{ steps.trigger.outputs.kind }}" | |
| if [ "$KIND" = "pr" ] && [ -n "${{ inputs.pr_number }}" ]; then | |
| KIND="pr${{ inputs.pr_number }}" | |
| fi | |
| TARGET="$(date -u +%Y/%m/%Y-%m-%d-%H%M%S)-$KIND-$COMMIT" | |
| mkdir -p results-branch/$(dirname $TARGET) | |
| cp -rv results results-branch/$TARGET | |
| echo "results=$TARGET" >> $GITHUB_OUTPUT | |
| # Commit the new results. | |
| cd results-branch | |
| git config --local \ | |
| user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local \ | |
| user.name "github-actions[bot]" | |
| git add . | |
| git commit -m "Results for $COMMIT" | |
| # Push the results. If the push fails, assume that it's because some | |
| # other job happened to push in the meantime. | |
| RETRY=0 | |
| while ! git push; do | |
| if (( ++RETRY == 10 )); then | |
| echo "Giving up after $RETRY failed attempts to push results" &>2 | |
| exit 1 | |
| fi | |
| git pull --rebase | |
| done | |
| # Find the previous baseline result and generate a summary report | |
| # comparing error deltas against the current run. | |
| - name: Find base commit | |
| run: | | |
| python3 utils/find-base.py \ | |
| --circt-repo circt \ | |
| --results-dir results-branch \ | |
| | tee base.txt | |
| - name: Generate summary | |
| run: | | |
| python3 utils/summarize.py \ | |
| --current-results "${{ steps.archive.outputs.results }}" \ | |
| --base-results "$(cat base.txt)" \ | |
| --results-dir results-branch \ | |
| --run-id "${{ github.run_id }}" \ | |
| | tee summary.md | |
| cat summary.md >> $GITHUB_STEP_SUMMARY | |
| # Post the summary as a comment on the CIRCT PR. | |
| - name: Comment on CIRCT PR | |
| if: env.GH_TOKEN != '' && inputs.pr_number != '' | |
| run: | | |
| gh api "repos/llvm/circt/issues/${{ inputs.pr_number }}/comments" \ | |
| -f body="$(cat summary.md)" | |
| echo "Posted comment on PR #${{ inputs.pr_number }}" |