|
| 1 | +# This workflow runs a Criterion benchmark on a PR and compares the results against the base branch. |
| 2 | +# It is triggered on a PR or a push to main. |
| 3 | +# |
| 4 | +# The workflow is gated on the presence of the "performance" label on the PR. |
| 5 | +# |
| 6 | +# The workflow runs on a self-hosted runner pool. We can't use the shared runners for this, |
| 7 | +# because they are only permitted to run on the default branch to preserve resources. |
| 8 | +# |
| 9 | +# In the future, we might like to consider using bencher.dev or the framework used by otel-golang here. |
| 10 | +on: |
| 11 | + pull_request: |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | +name: benchmark pull requests |
| 16 | +jobs: |
| 17 | + runBenchmark: |
| 18 | + name: run benchmark |
| 19 | + permissions: |
| 20 | + pull-requests: write |
| 21 | + |
| 22 | + # If we're running on a PR, use ubuntu-latest - a shared runner. We can't use the self-hosted |
| 23 | + # runners on arbitrary PRs, and we don't want to unleash that load on the pool anyway. |
| 24 | + # If we're running on main, use the OTEL self-hosted runner pool. |
| 25 | + runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }} |
| 26 | + if: | |
| 27 | + ${{ |
| 28 | + github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'performance') || |
| 29 | + github.event_name == 'push' |
| 30 | + }} |
| 31 | + env: |
| 32 | + # For PRs, compare against the base branch - e.g., 'main'. |
| 33 | + # For pushes to main, compare against the previous commit |
| 34 | + BRANCH_NAME: ${{ github.event_name == 'pull_request' && github.base_ref || github.event.before }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 10 # Fetch current commit and its parent |
| 39 | + - uses: arduino/setup-protoc@v3 |
| 40 | + with: |
| 41 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + - uses: dtolnay/rust-toolchain@master |
| 43 | + with: |
| 44 | + toolchain: stable |
| 45 | + - uses: boa-dev/criterion-compare-action@v3 |
| 46 | + with: |
| 47 | + cwd: opentelemetry |
| 48 | + branchName: ${{ env.BRANCH_NAME }} |
| 49 | + - uses: boa-dev/criterion-compare-action@v3 |
| 50 | + with: |
| 51 | + cwd: opentelemetry-appender-tracing |
| 52 | + features: spec_unstable_logs_enabled |
| 53 | + branchName: ${{ env.BRANCH_NAME }} |
| 54 | + - uses: boa-dev/criterion-compare-action@v3 |
| 55 | + with: |
| 56 | + cwd: opentelemetry-sdk |
| 57 | + features: rt-tokio,testing,metrics,logs,spec_unstable_metrics_views |
| 58 | + branchName: ${{ env.BRANCH_NAME }} |
0 commit comments