Implement lightweight syntax for component handling #3047
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: Benchmark | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| BASE_REF: main | |
| jobs: | |
| benchmark: | |
| name: Benchmarks | |
| runs-on: ubuntu-latest | |
| permissions: # required for caching | |
| actions: write | |
| contents: read | |
| strategy: | |
| matrix: | |
| repetition: [1, 2, 3] | |
| steps: | |
| - name: Cancel ongoing test runs for previous commits | |
| uses: styfle/cancel-workflow-action@0.13.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Julia | |
| uses: ./.github/actions/setup-julia | |
| with: | |
| julia-version: '1' | |
| project-file: 'benchmark/Project.toml' | |
| key-suffix: ${{ matrix.repetition }} | |
| - name: Install dependencies | |
| run: julia --project=benchmark -e 'using Pkg; Pkg.develop(path="."); Pkg.instantiate()' | |
| - name: Run benchmarks for current | |
| run: julia --project=benchmark benchmark/run_benchmarks.jl | |
| - name: Rename file | |
| run: mv bench.csv bench_current_${{ matrix.repetition }}.csv | |
| - name: Archive results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: bench_current_${{ matrix.repetition }} | |
| path: bench_current_${{ matrix.repetition }}.csv | |
| - name: Checkout code | |
| if: github.event_name == 'pull_request' | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Switch to base commit | |
| if: github.event_name == 'pull_request' | |
| run: git checkout ${{ env.BASE_REF }} | |
| - name: Install dependencies | |
| if: github.event_name == 'pull_request' | |
| run: julia --project=benchmark -e 'using Pkg; Pkg.develop(path="."); Pkg.instantiate()' | |
| - name: Run benchmarks for main | |
| if: github.event_name == 'pull_request' | |
| run: julia --project=benchmark benchmark/run_benchmarks.jl | |
| - name: Rename file | |
| if: github.event_name == 'pull_request' | |
| run: mv bench.csv bench_main_${{ matrix.repetition }}.csv | |
| - name: Archive results | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: bench_main_${{ matrix.repetition }} | |
| path: bench_main_${{ matrix.repetition }}.csv | |
| compare: | |
| name: Compare benchmarks | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: | |
| - benchmark | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_main_1 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_main_2 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_main_3 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_current_1 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_current_2 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: bench_current_3 | |
| - name: Set up Julia | |
| uses: ./.github/actions/setup-julia | |
| with: | |
| julia-version: '1' | |
| project-file: 'benchmark/Project.toml' | |
| - name: Run comparison | |
| run: julia benchmark/compare_benchmarks.jl | tee compare.md | |
| - name: Archive results CSV | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: compare | |
| path: compare.csv | |
| - name: Archive results MD | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: compare_md | |
| path: compare.md | |
| - name: Archive results HTML | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: compare_html | |
| path: compare.html | |
| comment: | |
| name: Comment on PR | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: | |
| - compare | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: compare_html | |
| path: . | |
| - name: Read benchmark results | |
| id: read_benchmark | |
| run: | | |
| echo 'comment<<EOF' >> $GITHUB_OUTPUT | |
| echo '<!-- benchmark-results -->' >> $GITHUB_OUTPUT | |
| cat compare.html >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| - name: Debug results | |
| run: cat compare.html | |
| - name: Find comment | |
| uses: peter-evans/find-comment@v4 | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-includes: '<!-- benchmark-results -->' | |
| - name: Comment on PR | |
| uses: peter-evans/create-or-update-comment@v5 | |
| with: | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: ${{ steps.read_benchmark.outputs.comment }} | |
| edit-mode: replace |