User/celiac/minimatch update #170
Workflow file for this run
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: ForestRun Performance Benchmark | |
| on: | |
| pull_request: | |
| paths: | |
| - "packages/apollo-forest-run/**" | |
| - "packages/apollo-forest-run-benchmark/**" | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "yarn" | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Clone caches | |
| run: | | |
| cd packages/apollo-forest-run-benchmark | |
| yarn clone | |
| - name: Run benchmarks | |
| id: benchmark | |
| run: | | |
| cd packages/apollo-forest-run-benchmark | |
| output=$(yarn benchmark 2>&1) | |
| echo "$output" | |
| # Extract markdown report from output | |
| if echo "$output" | grep -q "::BEGIN_BENCHMARK_REPORT::"; then | |
| markdown=$(echo "$output" | sed -n '/::BEGIN_BENCHMARK_REPORT::/,/::END_BENCHMARK_REPORT::/p' | sed '1d;$d') | |
| echo "benchmark-report<<EOF" >> $GITHUB_OUTPUT | |
| echo "$markdown" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "No benchmark report found in output" | |
| fi | |
| env: | |
| CI: true | |
| - name: Comment benchmark results on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const markdownContent = `${{ steps.benchmark.outputs.benchmark-report }}`.trim(); | |
| if (!markdownContent || markdownContent === '') { | |
| console.log('No benchmark report generated'); | |
| return; | |
| } | |
| // Find existing benchmark comment on this PR to update or create new one | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('📊 Benchmark Analysis Report') | |
| ); | |
| const commentBody = `<!-- benchmark-report --> | |
| ${markdownContent} | |
| --- | |
| *Updated: ${new Date().toISOString()}*`; | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: commentBody | |
| }); | |
| console.log('Updated existing benchmark comment'); | |
| } else { | |
| // Create new comment on PR | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body: commentBody | |
| }); | |
| console.log('Created new benchmark comment on PR'); | |
| } |