ci(benchmark): Add help task configuration benchmark on PRs #1
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 help task configuration | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| benchmark-help-config: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| # Full history so gradle-profiler's git-checkout can reach both the | |
| # base and head commits of the PR. | |
| fetch-depth: 0 | |
| - name: Set up Java | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Install Gradle Profiler and benchmark the help task | |
| env: | |
| BASE_REF: ${{ github.event.pull_request.base.sha }} | |
| HEAD_REF: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| curl -s "https://get.sdkman.io" | bash | |
| source "$HOME/.sdkman/bin/sdkman-init.sh" | |
| sdk install gradleprofiler 0.24.0 | |
| gradle-profiler --benchmark \ | |
| --scenario-file scripts/benchmark/help-config-cache.scenarios \ | |
| --output-dir out/help-config | |
| - name: Upload results | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: help-config-benchmark | |
| path: out/help-config/ | |
| - name: Build PR comment | |
| run: python3 scripts/benchmark/help-config-comment.py out/help-config/benchmark.csv comment.md | |
| - name: Post comparison comment | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = '<!-- help-config-benchmark -->'; | |
| const body = fs.readFileSync('comment.md', 'utf8'); | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, repo, issue_number, | |
| }); | |
| const existing = comments.find((c) => c.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); | |
| } else { | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | |
| } |