-
Notifications
You must be signed in to change notification settings - Fork 43
188 lines (165 loc) · 5.88 KB
/
Copy pathperf-tests.yml
File metadata and controls
188 lines (165 loc) · 5.88 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Performance Tests
on:
pull_request:
branches:
- main
- release*
- release/*
- release-*
workflow_dispatch:
permissions:
actions: read
contents: read
pull-requests: write
jobs:
performance:
name: E2E Performance Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: Windows
comment_header: perf-windows
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
platform: Linux
comment_header: perf-linux
- os: macos-latest
target: x86_64-apple-darwin
platform: macOS
comment_header: perf-macos
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Post In-Progress Comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ matrix.comment_header }}
message: |
## Performance Report (${{ matrix.platform }}) :hourglass_flowing_sand:
Running performance tests against baseline `${{ github.event.pull_request.base.sha }}`.
- name: Set Python to PATH
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Validate Snapshot Comparator
run: python -m unittest discover -s scripts/tests -p 'test_*.py' -v
shell: bash
- name: Add Conda to PATH (Windows)
if: startsWith(matrix.os, 'windows')
run: |
$path = $env:PATH + ";" + $env:CONDA + "\condabin"
echo "PATH=$path" >> $env:GITHUB_ENV
- name: Add Conda to PATH (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: echo "PATH=$PATH:$CONDA/condabin" >> $GITHUB_ENV
shell: bash
- name: Install Conda + add to PATH (macOS)
if: startsWith(matrix.os, 'macos')
run: |
curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash ~/miniconda.sh -b -p ~/miniconda
echo "PATH=$PATH:$HOME/miniconda/bin" >> $GITHUB_ENV
echo "CONDA=$HOME/miniconda" >> $GITHUB_ENV
shell: bash
- name: Create test Conda environment
run: conda create -n perf-test-env python=3.12 -y
- name: Create test venv
run: python -m venv .venv
shell: bash
- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Cargo Fetch
run: cargo fetch
shell: bash
- name: Build Release
run: cargo build --release --target ${{ matrix.target }}
shell: bash
- name: Run Performance Tests
id: benchmark
run: |
set -o pipefail
cargo test --release --features ci-perf --target ${{ matrix.target }} --test e2e_performance test_performance_summary -- --nocapture 2>&1 | tee perf-output.txt
env:
RUST_BACKTRACE: 1
RUST_LOG: warn
shell: bash
- name: Extract Performance Metrics
if: steps.benchmark.outcome == 'success'
run: |
if ! grep -q "JSON metrics:" perf-output.txt; then
echo "Performance test produced no JSON metrics" >&2
exit 1
fi
sed -n '/JSON metrics:/,/^}/p' perf-output.txt | tail -n +2 > metrics.json
python -m json.tool metrics.json > /dev/null
cat metrics.json
shell: bash
- name: Upload PR Performance Results
if: always()
uses: actions/upload-artifact@v4
with:
name: perf-pr-${{ matrix.os }}
path: metrics.json
if-no-files-found: ignore
- name: Wait for Exact PR Base Performance
id: wait_for_base_performance
if: always() && github.event_name == 'pull_request'
run: >-
python scripts/wait_for_baseline.py
--repository "${{ github.repository }}"
--workflow perf-baseline.yml
--commit "${{ github.event.pull_request.base.sha }}"
--artifact "perf-baseline-${{ matrix.os }}"
--timeout-seconds 1200
--poll-seconds 20
env:
GITHUB_TOKEN: ${{ github.token }}
shell: bash
- name: Download Exact PR Base Performance
if: >-
always() && github.event_name == 'pull_request' &&
steps.wait_for_base_performance.outcome == 'success'
uses: dawidd6/action-download-artifact@v6
with:
workflow: perf-baseline.yml
commit: ${{ github.event.pull_request.base.sha }}
workflow_conclusion: success
name: perf-baseline-${{ matrix.os }}
path: baseline-perf
check_artifacts: true
search_artifacts: true
- name: Download Main Performance for Manual Run
if: always() && github.event_name == 'workflow_dispatch'
uses: dawidd6/action-download-artifact@v6
with:
workflow: perf-baseline.yml
branch: main
workflow_conclusion: success
name: perf-baseline-${{ matrix.os }}
path: baseline-perf
check_artifacts: true
search_artifacts: true
- name: Compare Performance Snapshot
if: always()
run: >-
python scripts/quality_snapshot.py performance
--current metrics.json
--baseline baseline-perf/metrics.json
--platform "${{ matrix.platform }}"
--report performance-report.md
--summary "$GITHUB_STEP_SUMMARY"
shell: bash
- name: Post Performance Comment
if: always() && github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ matrix.comment_header }}
path: performance-report.md