|
| 1 | +name: PR performance |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [master] |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + pull_request: |
| 10 | + description: Pull request number to compare with its current base |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + runtime: |
| 14 | + description: Target runtime |
| 15 | + type: choice |
| 16 | + options: [net10.0, net8.0, both] |
| 17 | + default: net10.0 |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: read |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: performance-${{ github.event.pull_request.number || inputs.pull_request }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + revisions: |
| 29 | + runs-on: ubuntu-24.04 |
| 30 | + outputs: |
| 31 | + number: ${{ steps.pr.outputs.number }} |
| 32 | + base: ${{ steps.pr.outputs.base }} |
| 33 | + head: ${{ steps.pr.outputs.head }} |
| 34 | + head-repo: ${{ steps.pr.outputs.head-repo }} |
| 35 | + runtimes: ${{ steps.pr.outputs.runtimes }} |
| 36 | + steps: |
| 37 | + - uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 |
| 38 | + id: pr |
| 39 | + env: |
| 40 | + REQUESTED_PR: ${{ inputs.pull_request }} |
| 41 | + REQUESTED_RUNTIME: ${{ inputs.runtime }} |
| 42 | + with: |
| 43 | + script: | |
| 44 | + const text = process.env.REQUESTED_PR; |
| 45 | + if (context.eventName === 'workflow_dispatch' && !/^[1-9][0-9]*$/.test(text)) throw new Error('Invalid PR number'); |
| 46 | + const pr = context.eventName === 'pull_request' ? context.payload.pull_request : |
| 47 | + (await github.rest.pulls.get({...context.repo, pull_number: Number(text)})).data; |
| 48 | + if (pr.base.ref !== 'master' || pr.base.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`) throw new Error('Expected a PR targeting master in this repository'); |
| 49 | + core.setOutput('number', pr.number); |
| 50 | + core.setOutput('base', pr.base.sha); |
| 51 | + core.setOutput('head', pr.head.sha); |
| 52 | + core.setOutput('head-repo', pr.head.repo.full_name); |
| 53 | + const runtime = process.env.REQUESTED_RUNTIME || 'net10.0'; |
| 54 | + if (!['net10.0', 'net8.0', 'both'].includes(runtime)) throw new Error('Invalid runtime'); |
| 55 | + core.setOutput('runtimes', JSON.stringify(runtime === 'both' ? ['net8.0', 'net10.0'] : [runtime])); |
| 56 | +
|
| 57 | + benchmark: |
| 58 | + needs: revisions |
| 59 | + runs-on: ubuntu-24.04 |
| 60 | + timeout-minutes: 30 |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + runtime: ${{ fromJSON(needs.revisions.outputs.runtimes) }} |
| 65 | + env: |
| 66 | + PR_NUMBER: ${{ needs.revisions.outputs.number }} |
| 67 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 68 | + DOTNET_NOLOGO: 1 |
| 69 | + DOTNET_TieredCompilation: 0 |
| 70 | + DOTNET_ReadyToRun: 0 |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 73 | + with: |
| 74 | + ref: ${{ needs.revisions.outputs.base }} |
| 75 | + path: baseline |
| 76 | + persist-credentials: false |
| 77 | + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 78 | + with: |
| 79 | + repository: ${{ needs.revisions.outputs.head-repo }} |
| 80 | + ref: ${{ needs.revisions.outputs.head }} |
| 81 | + path: candidate |
| 82 | + persist-credentials: false |
| 83 | + - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4 |
| 84 | + with: |
| 85 | + dotnet-version: 10.0.301 |
| 86 | + # The extended .NET 8 pass needs the runtime as well as the pinned SDK. |
| 87 | + - if: matrix.runtime == 'net8.0' |
| 88 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4 |
| 89 | + with: |
| 90 | + dotnet-version: 8.0.422 |
| 91 | + - name: Select one frozen harness |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + suite=test/FastExpressionCompiler.Benchmarks/Regression |
| 95 | + harness="baseline/$suite" |
| 96 | + if [ ! -f "$harness/run.py" ]; then harness="candidate/$suite"; fi |
| 97 | + echo "PERFORMANCE_HARNESS=$harness" >> "$GITHUB_ENV" |
| 98 | + - name: Harness and policy tests |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + python3 -m unittest discover -s "$PERFORMANCE_HARNESS/tests" -v |
| 102 | + node --test "$PERFORMANCE_HARNESS/tests/publish.test.cjs" |
| 103 | + - name: Benchmark exact base and PR head in both orders |
| 104 | + id: measure |
| 105 | + continue-on-error: true |
| 106 | + env: |
| 107 | + RUNTIME: ${{ matrix.runtime }} |
| 108 | + shell: bash |
| 109 | + run: python3 "$PERFORMANCE_HARNESS/run.py" --baseline baseline --candidate candidate --runtime "$RUNTIME" --output results |
| 110 | + - name: Compare (reporting only) |
| 111 | + if: always() && steps.measure.outcome != 'skipped' |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + status=0 |
| 115 | + python3 "$PERFORMANCE_HARNESS/compare.py" --input results || status=$? |
| 116 | + if [ -f results/report.md ]; then cat results/report.md >> "$GITHUB_STEP_SUMMARY"; fi |
| 117 | + exit "$status" |
| 118 | + - name: Upload comment data |
| 119 | + if: always() |
| 120 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 121 | + with: |
| 122 | + name: performance-report-${{ matrix.runtime }}-${{ github.run_attempt }} |
| 123 | + path: results/report.json |
| 124 | + if-no-files-found: warn |
| 125 | + retention-days: 14 |
| 126 | + - name: Upload complete benchmark evidence |
| 127 | + if: always() |
| 128 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 129 | + with: |
| 130 | + name: performance-data-${{ matrix.runtime }}-${{ github.run_attempt }} |
| 131 | + path: | |
| 132 | + results/context.json |
| 133 | + results/sources.json |
| 134 | + results/report.md |
| 135 | + results/logs |
| 136 | + results/runs |
| 137 | + if-no-files-found: warn |
| 138 | + retention-days: 14 |
0 commit comments