-
Notifications
You must be signed in to change notification settings - Fork 288
147 lines (129 loc) · 5.74 KB
/
run-benchmarks.yml
File metadata and controls
147 lines (129 loc) · 5.74 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
# .github/workflows/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: [self-hosted, type-ccx33]
env:
SKIP_BENCHMARKS: "0"
AUTO_COMMIT_WEIGHTS: "1"
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: Run & validate benchmarks
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: nick-fields/retry@v3
with:
timeout_minutes: 180
max_attempts: 3
retry_wait_seconds: 60
command: |
chmod +x scripts/benchmark_action.sh
scripts/benchmark_action.sh
# (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