-
-
Notifications
You must be signed in to change notification settings - Fork 32
75 lines (64 loc) · 2.35 KB
/
benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: "Benchmarks"
on:
pull_request:
branches:
- main
jobs:
benchmark:
name: Benchmark
runs-on: macos-14
continue-on-error: true
permissions:
issues: write
pull-requests: write
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
BENCHMARK_PACKAGE: true
BENCHMARK_DISABLE_JEMALLOC: true
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Benchmarks
run: swift package plugin benchmark list
- name: Benchmark Pull Request
run: swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update pull_request
- name: Switch Branches
run: |
git stash
git checkout main
git stash pop
- name: Benchmark Main
run: swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update main
- name: Compare Benchmarks
run: |
set +e
benchmarkDate="$(date)"
benchmarkCheckOutput="$(swift package benchmark baseline check main pull_request --format markdown)"
benchmarkExitStatus="$?"
benchmarkCompareOutput="$(swift package benchmark baseline compare main pull_request --no-progress --quiet --format markdown)"
echo "benchmarkDate=$benchmarkDate" >> $GITHUB_ENV
{ echo "benchmarkCheckOutput<<EOF"; echo "$benchmarkCheckOutput"; echo EOF; } >> "$GITHUB_ENV"
echo "benchmarkExitStatus=$benchmarkExitStatus" >> $GITHUB_ENV
{ echo "benchmarkCompareOutput<<EOF"; echo "$benchmarkCompareOutput"; echo EOF; } >> "$GITHUB_ENV"
if [[ $exitStatus -eq 0 ]]; then
echo "benchmarkStatusMessage=✅ Pull Request passed benchmark checks" >> $GITHUB_ENV
else
echo "benchmarkStatusMessage=⚠️ Pull Request may have performance regressions" >> $GITHUB_ENV
fi
- name: Comment
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: benchmark
message: |
${{ env.benchmarkStatusMessage }}
## Summary
${{ env.benchmarkDate }}
${{ env.benchmarkCheckOutput }}
---
${{ env.benchmarkCompareOutput }}
- name: Exit with correct status
run: |
exit ${{ env.benchmarkCompareOutput }}