|
1 | 1 | name: Track Fork PR Benchmarks |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: [CI] |
6 | | - types: [completed] |
| 4 | + workflow_run: |
| 5 | + workflows: [CI] |
| 6 | + types: [completed] |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - track_fork_pr_benchmarks: |
10 | | - name: Track Fork PR Benchmarks with Bencher |
11 | | - if: github.event.workflow_run.conclusion == 'success' |
12 | | - permissions: |
13 | | - pull-requests: write |
14 | | - runs-on: ubuntu-22.04 |
15 | | - env: |
16 | | - BENCHMARK_RESULTS: benchmark_results.txt |
17 | | - PR_EVENT: event.json |
18 | | - steps: |
19 | | - - name: Download Benchmark Results |
20 | | - id: download_results |
21 | | - uses: dawidd6/action-download-artifact@v6 |
22 | | - continue-on-error: true |
23 | | - with: |
24 | | - name: ${{ env.BENCHMARK_RESULTS }} |
25 | | - run_id: ${{ github.event.workflow_run.id }} |
26 | | - - name: Download PR Event |
27 | | - id: download_event |
28 | | - uses: dawidd6/action-download-artifact@v6 |
29 | | - continue-on-error: true |
30 | | - with: |
31 | | - name: ${{ env.PR_EVENT }} |
32 | | - run_id: ${{ github.event.workflow_run.id }} |
33 | | - - name: Check if Fork PR Benchmarks |
34 | | - id: check_fork |
35 | | - run: | |
36 | | - if [[ "${{ steps.download_results.outcome }}" == "success" && "${{ steps.download_event.outcome }}" == "success" ]]; then |
37 | | - echo "is_fork_pr=true" >> "$GITHUB_OUTPUT" |
38 | | - else |
39 | | - echo "is_fork_pr=false" >> "$GITHUB_OUTPUT" |
40 | | - fi |
41 | | - - name: Export PR Event Data |
42 | | - if: steps.check_fork.outputs.is_fork_pr == 'true' |
43 | | - uses: actions/github-script@v6 |
44 | | - with: |
45 | | - script: | |
46 | | - let fs = require('fs'); |
47 | | - let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'})); |
48 | | - core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref); |
49 | | - core.exportVariable("PR_HEAD_SHA", prEvent.pull_request.head.sha); |
50 | | - core.exportVariable("PR_BASE", prEvent.pull_request.base.ref); |
51 | | - core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha); |
52 | | - core.exportVariable("PR_NUMBER", prEvent.number); |
53 | | - - uses: bencherdev/bencher@main |
54 | | - if: steps.check_fork.outputs.is_fork_pr == 'true' |
55 | | - - name: Track Benchmarks with Bencher |
56 | | - if: steps.check_fork.outputs.is_fork_pr == 'true' |
57 | | - run: | |
58 | | - bencher run \ |
59 | | - --host https://api.bencher.dev \ |
60 | | - --project bencher \ |
61 | | - --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
62 | | - --branch "$PR_HEAD" \ |
63 | | - --hash "$PR_HEAD_SHA" \ |
64 | | - --start-point "$PR_BASE" \ |
65 | | - --start-point-hash "$PR_BASE_SHA" \ |
66 | | - --start-point-clone-thresholds \ |
67 | | - --start-point-reset \ |
68 | | - --testbed ubuntu-22.04 \ |
69 | | - --adapter rust_criterion \ |
70 | | - --err \ |
71 | | - --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
72 | | - --ci-number "$PR_NUMBER" \ |
73 | | - --file ./benchmark_results.txt |
| 9 | + track_fork_pr_benchmarks: |
| 10 | + name: Track Fork PR Benchmarks with Bencher |
| 11 | + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != 'main' }} |
| 12 | + permissions: |
| 13 | + pull-requests: write |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + env: |
| 16 | + BENCHMARK_RESULTS: benchmark_results.txt |
| 17 | + PR_EVENT: event.json |
| 18 | + steps: |
| 19 | + - name: Download Benchmark Results |
| 20 | + id: download_results |
| 21 | + uses: dawidd6/action-download-artifact@v6 |
| 22 | + continue-on-error: true |
| 23 | + with: |
| 24 | + name: ${{ env.BENCHMARK_RESULTS }} |
| 25 | + run_id: ${{ github.event.workflow_run.id }} |
| 26 | + - name: Download PR Event |
| 27 | + id: download_event |
| 28 | + uses: dawidd6/action-download-artifact@v6 |
| 29 | + continue-on-error: true |
| 30 | + with: |
| 31 | + name: ${{ env.PR_EVENT }} |
| 32 | + run_id: ${{ github.event.workflow_run.id }} |
| 33 | + - name: Check if Fork PR Benchmarks |
| 34 | + id: check_fork |
| 35 | + run: | |
| 36 | + if [[ "${{ steps.download_results.outcome }}" == "success" && "${{ steps.download_event.outcome }}" == "success" ]]; then |
| 37 | + echo "is_fork_pr=true" >> "$GITHUB_OUTPUT" |
| 38 | + else |
| 39 | + echo "is_fork_pr=false" >> "$GITHUB_OUTPUT" |
| 40 | + fi |
| 41 | + - name: Export PR Event Data |
| 42 | + if: steps.check_fork.outputs.is_fork_pr == 'true' |
| 43 | + uses: actions/github-script@v6 |
| 44 | + with: |
| 45 | + script: | |
| 46 | + let fs = require('fs'); |
| 47 | + let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'})); |
| 48 | + core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref); |
| 49 | + core.exportVariable("PR_HEAD_SHA", prEvent.pull_request.head.sha); |
| 50 | + core.exportVariable("PR_BASE", prEvent.pull_request.base.ref); |
| 51 | + core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha); |
| 52 | + core.exportVariable("PR_NUMBER", prEvent.number); |
| 53 | + - uses: bencherdev/bencher@main |
| 54 | + if: steps.check_fork.outputs.is_fork_pr == 'true' |
| 55 | + - name: Track Benchmarks with Bencher |
| 56 | + if: steps.check_fork.outputs.is_fork_pr == 'true' |
| 57 | + run: | |
| 58 | + bencher run \ |
| 59 | + --host https://api.bencher.dev \ |
| 60 | + --project bencher \ |
| 61 | + --token '${{ secrets.BENCHER_API_TOKEN }}' \ |
| 62 | + --branch "$PR_HEAD" \ |
| 63 | + --hash "$PR_HEAD_SHA" \ |
| 64 | + --start-point "$PR_BASE" \ |
| 65 | + --start-point-hash "$PR_BASE_SHA" \ |
| 66 | + --start-point-clone-thresholds \ |
| 67 | + --start-point-reset \ |
| 68 | + --testbed ubuntu-22.04 \ |
| 69 | + --adapter rust_criterion \ |
| 70 | + --err \ |
| 71 | + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ |
| 72 | + --ci-number "$PR_NUMBER" \ |
| 73 | + --file ./benchmark_results.txt |
0 commit comments