refactor: same PR number to a file to access it when posting a benchmark comment (#1029)

This commit is contained in:
Juro Oravec 2025-03-17 13:03:30 +01:00 committed by GitHub
parent 99067c4b20
commit 439fcf68e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -86,6 +86,7 @@ jobs:
script: |
const fs = require('fs');
const results = fs.readFileSync('./benchmark_results.md', 'utf8');
const issue_number = Number.parseInt(fs.readFileSync('./pr_number.txt', 'utf8'));
const body = `## Performance Benchmark Results\n\nComparing PR changes against master branch:\n\n${results}`;
// See https://octokit.github.io/rest.js/v21/#issues-create-comment
@ -94,5 +95,5 @@ jobs:
// See https://github.com/actions/toolkit/blob/662b9d91f584bf29efbc41b86723e0e376010e41/packages/github/src/context.ts#L66
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.workflow_run.pull_requests[0].number,
issue_number: issue_number,
});

View file

@ -93,6 +93,10 @@ jobs:
echo "Comparing benchmarks..."
mkdir -p pr
asv compare upstream/master HEAD --factor 1.1 --split > ./pr/benchmark_results.md
# Save the PR number to a file, so that it can be used by the next step.
echo "${{ github.event.pull_request.number }}" > ./pr/pr_number.txt
echo "Benchmarks comparison DONE."
- name: Save benchmark results