-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip commenting memory/perf benches on draft PRs (#1694)
This should help reduce some of the comment noise until we have time to customize that action some more. I tested that this works on this PR -- the benches are not run when the PR is a draft. I had to pull the two relevant jobs out into a different workflow file, because the triggers are different. For the reporting benches stage (the memory and perf comments that show up on PRs), they'll only run if the PR is in a draft. But, and this is the different part that required them being in a separate file, they also need to trigger when a PR is marked "ready for review".
- Loading branch information
Showing
2 changed files
with
91 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Benchmark Reports | ||
|
||
on: | ||
pull_request: | ||
branches: "main" | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
merge_group: | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
NODE_VERSION: "18.17.1" | ||
PYTHON_VERSION: "3.11" | ||
RUST_TOOLCHAIN_VERSION: "1.78" | ||
RUST_TOOLCHAIN_COMPONENTS: rustfmt clippy | ||
|
||
jobs: | ||
runBenchmark: | ||
if: ${{ !github.event.pull_request.draft }} | ||
name: run benchmark | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: boa-dev/criterion-compare-action@v3 | ||
with: | ||
branchName: ${{ github.base_ref }} | ||
cwd: "compiler/qsc" | ||
if: ${{ github.base_ref != null }} | ||
|
||
runMemoryProfile: | ||
if: ${{ !github.event.pull_request.draft }} | ||
name: run memory profile | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: main | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: | | ||
MAIN_MEASUREMENT=$(cargo run --bin memtest) | ||
echo "MAIN_MEASUREMENT<<EOF" >> $GITHUB_ENV | ||
echo "$MAIN_MEASUREMENT" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- run: | | ||
echo "${{env.MAIN_MEASUREMENT}}" | ||
echo $MAIN_MEASUREMENT | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
BRANCH_MEASUREMENT=$(cargo run --bin memtest) | ||
echo "BRANCH_MEASUREMENT<<EOF" >> $GITHUB_ENV | ||
echo "$BRANCH_MEASUREMENT" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- run: | | ||
echo "${{env.BRANCH_MEASUREMENT}}" | ||
echo $BRANCH_MEASUREMENT | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
if (${{ env.BRANCH_MEASUREMENT }} !== ${{ env.MAIN_MEASUREMENT }}) { | ||
const difference = ${{ env.BRANCH_MEASUREMENT }} - ${{ env.MAIN_MEASUREMENT }}; | ||
try { | ||
await github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `_Change in memory usage detected by benchmark._ | ||
## Memory Report for ${{ github.sha }} | ||
| Test | This Branch | On Main | Difference | | ||
|-----------------------------|-------------|----------| ---------- | | ||
| compile core + standard lib | ${{ env.BRANCH_MEASUREMENT }} bytes | ${{ env.MAIN_MEASUREMENT }} bytes | ${difference} bytes` | ||
}) | ||
} catch (err) { | ||
core.warning(`Failed writing comment on GitHub issue: ${err}`) | ||
} | ||
} else { | ||
console.log("no change in memory usage detected by benchmark"); | ||
} | ||
if: ${{ github.base_ref != null }} |
This file contains 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