-
Notifications
You must be signed in to change notification settings - Fork 51
109 lines (106 loc) · 3.99 KB
/
Copy pathpull_request.yml
File metadata and controls
109 lines (106 loc) · 3.99 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Pull request
permissions:
contents: read
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "6.0"}, {"swift_version": "6.1"}, {"swift_version": "6.2"}]'
enable_windows_checks: false
enable_macos_checks: false
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "Swift.org"
unacceptable_language_check_enabled: false
format_check_enabled: false
bench:
name: Benchmark
runs-on: ubuntu-latest
env:
BUILD_CMD: swift build -c release
BENCH_CMD: .build/release/RegexBenchmark
BASELINE_FILE: benchmark-baseline
MAIN_FILE: benchmark-main
COMPARE_FILE: benchmark-pr
COMPARE_OUT_FILE: benchmark-results.txt
steps:
- name: Check out baseline branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
fetch-depth: 0
- name: Build baseline branch
working-directory: base
run: |
set -euo pipefail
eval "$BUILD_CMD"
- name: Run baseline benchmark
working-directory: base
run: |
set -euo pipefail
eval "$BENCH_CMD --save $RUNNER_TEMP/$BASELINE_FILE"
test -s "$RUNNER_TEMP/$BASELINE_FILE" || { echo "Baseline not created at $BASELINE_FILE"; exit 1; }
- name: Check out main branch
if: ${{ github.event.pull_request.base.ref != 'main' }}
uses: actions/checkout@v6
with:
ref: main
path: main-branch
fetch-depth: 0
- name: Build main branch
if: ${{ github.event.pull_request.base.ref != 'main' }}
working-directory: main-branch
run: |
set -euo pipefail
eval "$BUILD_CMD"
- name: Run main benchmark
if: ${{ github.event.pull_request.base.ref != 'main' }}
working-directory: main-branch
run: |
set -euo pipefail
eval "$BENCH_CMD --save $RUNNER_TEMP/$MAIN_FILE"
test -s "$RUNNER_TEMP/$MAIN_FILE" || { echo "Baseline (main) not created at $MAIN_FILE"; exit 1; }
- name: Check out PR branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr
fetch-depth: 0
- name: Build PR branch
working-directory: pr
run: |
set -euo pipefail
eval "$BUILD_CMD"
- name: Run PR benchmark
working-directory: pr
run: |
set -euo pipefail
eval "$BENCH_CMD --save $RUNNER_TEMP/$COMPARE_FILE"
test -s "$RUNNER_TEMP/$COMPARE_FILE" || { echo "Comparison not created at $COMPARE_FILE"; exit 1; }
eval "$BENCH_CMD --compare $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
- name: 📊 Compare benchmarks with base
working-directory: pr
run: |
set -euo pipefail
eval "$BENCH_CMD --load $RUNNER_TEMP/$COMPARE_FILE --compare $RUNNER_TEMP/$BASELINE_FILE --compare-compile-time $RUNNER_TEMP/$BASELINE_FILE" | tee "$RUNNER_TEMP/$COMPARE_OUT_FILE"
- name: 📊 Compare benchmarks with `main`
if: ${{ github.event.pull_request.base.ref != 'main' }}
working-directory: pr
run: |
set -euo pipefail
eval "$BENCH_CMD --load $RUNNER_TEMP/$COMPARE_FILE --compare $RUNNER_TEMP/$MAIN_FILE --compare-compile-time $RUNNER_TEMP/$MAIN_FILE"
- name: Upload benchmark artifacts
uses: actions/upload-artifact@v7
with:
name: benchmark-results
path: |
${{ runner.temp }}/${{ env.BASELINE_FILE }}
${{ runner.temp }}/${{ env.COMPARE_FILE }}
${{ runner.temp }}/${{ env.COMPARE_OUT_FILE }}