-
Notifications
You must be signed in to change notification settings - Fork 290
174 lines (152 loc) · 6.34 KB
/
run-benchmarks.yml
File metadata and controls
174 lines (152 loc) · 6.34 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
# .github/workflows/run-benchmarks.yml
name: Validate-Benchmarks
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: run-benchmarks-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-benchmarks:
runs-on: Benchmarking
env:
SKIP_BENCHMARKS: "0"
steps:
- name: Check out PR branch
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Install GitHub CLI
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
# (1) — first skip‑label check
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
- name: Install system dependencies
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" build-essential clang curl libssl-dev llvm libudev-dev protobuf-compiler pkg-config
# (2)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
- name: Install Rust toolchain
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
# (3)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
- name: Cache Rust build
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: Swatinem/rust-cache@v2
with:
key: bench-${{ hashFiles('**/Cargo.lock') }}
cache-on-failure: true
# (4)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
- name: Build node with benchmarks
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
cargo build --profile production -p node-subtensor --features runtime-benchmarks
# (5)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
- name: Ensure artifact folder exists
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: mkdir -p .bench_patch
- name: Run & validate benchmarks
if: ${{ env.SKIP_BENCHMARKS != '1' }}
timeout-minutes: 180
run: |
chmod +x scripts/benchmark_action.sh
scripts/benchmark_action.sh
- name: List artifact contents (for debugging)
if: ${{ always() }}
run: |
echo "Workspace: $GITHUB_WORKSPACE"
if [ -d ".bench_patch" ]; then
echo "== .bench_patch =="
ls -la .bench_patch || true
else
echo ".bench_patch directory is missing"
fi
- name: Archive bench patch
if: ${{ always() }}
run: |
if [ -d ".bench_patch" ]; then
tar -czf bench-patch.tgz .bench_patch
ls -lh bench-patch.tgz
else
echo "No .bench_patch directory to archive."
fi
- name: Upload patch artifact (if prepared)
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: bench-patch
path: bench-patch.tgz
if-no-files-found: warn
# (6) — final check after run
- name: Check skip label after run
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label was found — but benchmarks already ran."
fi