-
Notifications
You must be signed in to change notification settings - Fork 66
225 lines (203 loc) · 9.97 KB
/
committer_ci.yml
File metadata and controls
225 lines (203 loc) · 9.97 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Committer-CI
on:
pull_request:
types:
- opened
- reopened
- synchronize
- edited
paths:
- ".github/workflows/committer_ci.yml"
- "Cargo.toml"
- "Cargo.lock"
- "crates/starknet_committer_and_os_cli/**"
- "crates/starknet_api/**"
- "crates/starknet_committer/**"
- "crates/starknet_patricia/**"
- "crates/starknet_patricia_storage/**"
push:
branches:
- main
- "main-v*"
- "release-*"
paths:
- ".github/workflows/committer_ci.yml"
- "Cargo.toml"
- "Cargo.lock"
- "crates/starknet_committer_and_os_cli/**"
- "crates/starknet_api/**"
- "crates/starknet_committer/**"
- "crates/starknet_patricia/**"
- "crates/starknet_patricia_storage/**"
workflow_dispatch:
inputs:
branch:
description: "Branch to benchmark (leave empty for current)"
required: false
type: string
env:
RUSTFLAGS: "-D warnings"
FULL_COMMITTER_FLOW_TIME_LIMIT_NS: "1000000000"
TREE_COMPUTATION_FLOW_TIME_LIMIT_NS: "1800000000"
BENCHMARK_REGRESSION_LIMIT_PERCENT: "20"
# On PR events, cancel existing CI runs on this same PR.
# On push events, group by branch to avoid gh-pages conflicts (no cancellation).
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
run-regression-tests:
runs-on: namespace-profile-medium-ubuntu-24-04-amd64
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
# Setup pypy and link to the location expected by .cargo/config.toml.
# Python + requirements are needed to compile the OS.
- uses: actions/setup-python@v5
id: setup-pypy
with:
python-version: "pypy3.9"
cache: "pip"
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- run: pip install -r scripts/requirements.txt
- uses: ./.github/actions/bootstrap
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- id: auth
uses: "google-github-actions/auth@v2"
with:
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }}
- uses: "google-github-actions/setup-gcloud@v2"
- run: echo "BENCH_INPUT_FILES_PREFIX=$(cat ./crates/starknet_committer_and_os_cli/src/committer_cli/tests/flow_test_files_prefix)" >> $GITHUB_ENV
- run: gcloud storage cp -r gs://committer-testing-artifacts/$BENCH_INPUT_FILES_PREFIX/* ./crates/starknet_committer_and_os_cli/test_inputs
- run: cargo test -p starknet_committer_and_os_cli --release -- --include-ignored test_regression
# Benchmarking job - behavior depends on event type:
#
# ┌─────────────────────┬───────────────────────────────────────────────────────┐
# │ Event │ Behavior │
# ├─────────────────────┼───────────────────────────────────────────────────────┤
# │ pull_request │ Benchmark base branch, then head branch, compare. │
# │ │ Enforces regression limits and absolute time limits. │
# ├─────────────────────┼───────────────────────────────────────────────────────┤
# │ push (main branches)│ Benchmark current branch, publish results to gh-pages │
# │ workflow_dispatch │ for historical tracking and visualization. │
# └─────────────────────┴───────────────────────────────────────────────────────┘
benchmarking:
runs-on: namespace-profile-medium-ubuntu-24-04-amd64
permissions:
contents: write # Required for pushing to gh-pages on push events.
steps:
# PR-only: Checkout the base branch to benchmark the old code.
- name: Checkout base branch (PR only)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
# Push/dispatch: Checkout the specified or current branch.
- name: Checkout repository (push/dispatch)
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
# Setup pypy and link to the location expected by .cargo/config.toml.
# Python + requirements are needed to compile the OS.
- uses: actions/setup-python@v5
id: setup-pypy
with:
python-version: "pypy3.9"
cache: "pip"
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- run: pip install -r scripts/requirements.txt
- uses: ./.github/actions/bootstrap
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Auth with GCS for bench_tools to download inputs.
- id: auth
uses: "google-github-actions/auth@v2"
with:
credentials_json: ${{ secrets.COMMITER_PRODUCTS_EXT_WRITER_JSON }}
- uses: "google-github-actions/setup-gcloud@v2"
# PR-only: Benchmark the base branch code.
- name: Benchmark base branch (PR only)
if: github.event_name == 'pull_request'
run: cargo run -p bench_tools -- run --package starknet_committer_and_os_cli --out /tmp/base_results
# PR-only: Save the input files from the base branch to use in the second benchmark.
- name: Save test inputs (PR only)
if: github.event_name == 'pull_request'
run: cp -r crates/starknet_committer_and_os_cli/test_inputs /tmp/test_inputs
# PR-only: Checkout the current branch to benchmark the new code.
- name: Checkout current branch (PR only)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
clean: false
# PR-only: Re-install pip requirements in case they changed between branches.
- name: Re-install pip requirements (PR only)
if: github.event_name == 'pull_request'
run: pip install -r scripts/requirements.txt
# PR-only: Benchmark the current branch and compare to the previous run.
# Use the saved inputs and enforce absolute time limits and regression limit.
- name: Benchmark and compare (PR only)
if: github.event_name == 'pull_request'
run: |
cargo run -p bench_tools -- run-and-compare \
--package starknet_committer_and_os_cli \
--out /tmp/new_results \
--regression-limit ${BENCHMARK_REGRESSION_LIMIT_PERCENT} \
--input-dir /tmp/test_inputs \
--set-absolute-time-ns-limit full_committer_flow ${FULL_COMMITTER_FLOW_TIME_LIMIT_NS} \
--set-absolute-time-ns-limit tree_computation_flow ${TREE_COMPUTATION_FLOW_TIME_LIMIT_NS}
# Push/dispatch: Run benchmarks and publish to GitHub Pages.
- name: Run benchmarks (push/dispatch)
if: github.event_name != 'pull_request'
run: |
cargo run -p bench_tools -- run \
--package starknet_committer_and_os_cli \
--out /tmp/benchmark_results \
--github-action-benchmark-output-file benchmark_output.json
# Push/dispatch: Sanitize branch name and compute alert threshold.
- name: Prepare publish variables (push/dispatch)
if: github.event_name != 'pull_request'
id: branch
env:
BRANCH_NAME: ${{ inputs.branch || github.ref_name }}
run: |
SANITIZED="${BRANCH_NAME//\//-}"
echo "name=${SANITIZED}" >> $GITHUB_OUTPUT
echo "alert_threshold=$((100 + BENCHMARK_REGRESSION_LIMIT_PERCENT))%" >> $GITHUB_OUTPUT
echo "Branch: ${BRANCH_NAME} -> Directory: ${SANITIZED}"
# Push/dispatch: Clean up downloaded test inputs to avoid conflicts when switching to gh-pages.
- name: Clean up test inputs (push/dispatch)
if: github.event_name != 'pull_request'
run: git checkout -- crates/starknet_committer_and_os_cli/test_inputs/
# Push/dispatch: Store benchmark results to GitHub Pages.
- name: Store benchmark results (push/dispatch)
if: github.event_name != 'pull_request'
uses: starkware-libs/github-action-benchmark@v1
with:
tool: "customSmallerIsBetter"
output-file-path: benchmark_output.json
benchmark-data-dir-path: dev/bench/${{ steps.branch.outputs.name }}
gh-pages-branch: gh-pages
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Alert if performance regresses by more than the threshold.
alert-threshold: ${{ steps.branch.outputs.alert_threshold }}
# Comment on commit if threshold exceeded.
comment-on-alert: true
fail-on-alert: false
# Push/dispatch: Upload raw benchmark results as artifact for debugging.
# always() ensures artifacts are uploaded even if benchmarks fail, to help diagnose issues.
- name: Upload benchmark artifacts (push/dispatch)
if: github.event_name != 'pull_request' && always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results-${{ steps.branch.outputs.name }}-${{ github.sha }}
path: target/criterion/*/new/estimates.json
retention-days: 30