|
| 1 | +# benchmark-pr-1p.yml: submit benchmarks to Bencher. |
| 2 | +# |
| 3 | +# This workflow covers "first party" pull requests specifically, |
| 4 | +# i.e. those created from branches within the same repository. |
| 5 | + |
| 6 | +name: Benchmark PRs (first-party) |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request: |
| 10 | + types: [opened, reopened, edited, synchronize] |
| 11 | + |
| 12 | +permissions: {} |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "benchmark-pr-1p-${{ github.event.pull_request.number }}" |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + benchmark-pr-1p: |
| 20 | + name: Continuous Benchmarking PRs with Bencher |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: >- |
| 23 | + ${{ |
| 24 | + github.event_name == 'pull_request' |
| 25 | + && github.event.pull_request.head.repo.full_name == github.repository |
| 26 | + && !contains(github.event.pull_request.labels.*.name, 'no-benchmark') |
| 27 | + }} |
| 28 | +
|
| 29 | + permissions: |
| 30 | + pull-requests: write |
| 31 | + |
| 32 | + environment: |
| 33 | + name: bencher |
| 34 | + url: https://bencher.dev/console/projects/zizmor |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 38 | + with: |
| 39 | + persist-credentials: false |
| 40 | + |
| 41 | + - name: Set up Bencher |
| 42 | + uses: bencherdev/bencher@f89d454e74a32a81b2eab29fe0afdb2316617342 # v0.5.3 |
| 43 | + |
| 44 | + - name: Installer hyperfine |
| 45 | + run: | |
| 46 | + sudo apt-get remove --purge man-db |
| 47 | + sudo apt install -y hyperfine |
| 48 | +
|
| 49 | + - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0 |
| 50 | + |
| 51 | + - uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1 |
| 52 | + |
| 53 | + # TODO: use actions/cache to cache the plan phase here. |
| 54 | + - name: Run benchmarks |
| 55 | + run: make bench |
| 56 | + |
| 57 | + - name: Upload benchmark results |
| 58 | + # Take each result file in bench/results/*.json and use |
| 59 | + # `bencher run` to upload it. |
| 60 | + run: | |
| 61 | + for file in bench/results/*.json; do |
| 62 | + bencher run \ |
| 63 | + --project zizmor \ |
| 64 | + --token "${BENCHER_API_TOKEN}" \ |
| 65 | + --branch "${GITHUB_HEAD_REF}" \ |
| 66 | + --start-point "${GITHUB_BASE_REF}" \ |
| 67 | + --start-point-hash "${PULL_REQUEST_BASE_SHA}" \ |
| 68 | + --start-point-clone-thresholds \ |
| 69 | + --start-point-reset \ |
| 70 | + --testbed ubuntu-latest \ |
| 71 | + --err \ |
| 72 | + --adapter shell_hyperfine \ |
| 73 | + --github-actions "${GITHUB_TOKEN}" \ |
| 74 | + --file "${file}" |
| 75 | + done |
| 76 | + env: |
| 77 | + BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }} |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }} |
0 commit comments