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 e62589b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,48 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: swift format lint -rs .
benchmark:
if: ${{ github.ref != 'refs/heads/main' }}
needs: test
runs-on: ubuntu-latest
container: swiftlang/swift:nightly-6.0-jammy
steps:
- uses: actions/checkout@v4
- run: apt-get update && apt-get install --no-install-recommends -y libjemalloc-dev
- 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
- run: swift package --package-path Benchmarks benchmark baseline update main --no-progress --quiet
- name: benchmark baseline check
id: benchmark
run: |
set +e
echo '## Summary' >> "$GITHUB_STEP_SUMMARY"
echo "$(date)" >> "$GITHUB_STEP_SUMMARY"
swift package --package-path Benchmarks benchmark baseline check main pull_request --format markdown >> "$GITHUB_STEP_SUMMARY"
exitStatus="$?"
[ $exitStatus = '0' ] || [ $exitStatus = '4' ] && echo "exitStatus=0" >> "$GITHUB_OUTPUT" || echo "exitStatus=1" >> "$GITHUB_OUTPUT"
- name: benchmark baseline compare
if: ${{ steps.benchmark.outputs.exitStatus == '0' }}
run: |
echo >> "$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"
- 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: benchmark
- run: exit ${{ steps.benchmark.outputs.exitStatus }}

0 comments on commit e62589b

Please sign in to comment.