Skip to content

Commit

Permalink
ci: check performance regressions with CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kkebo committed Oct 11, 2024
1 parent 3f268f0 commit ac1f84f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: benchmark
on:
pull_request:
branches: ["main"]
jobs:
benchmark:
runs-on: ubuntu-latest
container: swiftlang/swift:nightly-6.0-jammy
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: apt-get update && apt-get install --no-install-recommends -y libjemalloc-dev
- name: Run benchmarks for PR branch
run: swift package --package-path Benchmarks benchmark baseline update pull_request --no-progress --quiet
- name: Switch to branch 'main'
uses: actions/checkout@v4
with:
ref: main
clean: false
- name: Run benchmarks for branch 'main'
run: swift package --package-path Benchmarks benchmark baseline update main --no-progress --quiet
- name: Compare PR and main
id: benchmark
run: |
echo '## Summary' >> "$GITHUB_STEP_SUMMARY"
echo "$(date)" >> "$GITHUB_STEP_SUMMARY"
echo "exitStatus=1" >> "$GITHUB_OUTPUT"
swift package --package-path Benchmarks benchmark baseline check main pull_request --format markdown >> "$GITHUB_STEP_SUMMARY"
echo '---' >> "$GITHUB_STEP_SUMMARY"
swift package --package-path Benchmarks benchmark baseline compare main pull_request --no-progress --quiet --format markdown >> "$GITHUB_STEP_SUMMARY"
echo "exitStatus=0" >> "$GITHUB_OUTPUT"
- name: Pull request comment text
id: prtest
env:
exitStatus: ${{ steps.benchmark.outputs.exitStatus }}
run: |
echo 'PRTEST<<EOF' >> "$GITHUB_OUTPUT"
echo "[Pull request benchmark comparison with 'main' run at $(date -Iseconds)](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> "$GITHUB_OUTPUT"
[[ $exitStatus == '1' ]] && echo "_Pull request had performance regressions_" >> "$GITHUB_OUTPUT"
echo 'EOF' >> "$GITHUB_OUTPUT"
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
with:
message: ${{ steps.prtest.outputs.PRTEST }}
comment_tag: execution
- name: Exit with correct status
run: |
exit ${{ steps.benchmark.outputs.exitStatus }}

0 comments on commit ac1f84f

Please sign in to comment.