@@ -3,11 +3,13 @@ name: Validate-Benchmarks
33
44on :
55 pull_request :
6- types :
7- - opened
8- - synchronize
6+ types : [opened, synchronize]
97 workflow_dispatch :
108
9+ permissions :
10+ contents : write
11+ pull-requests : write
12+
1113concurrency :
1214 group : run-benchmarks-${{ github.ref }}
1315 cancel-in-progress : true
@@ -17,104 +19,110 @@ jobs:
1719 runs-on : Benchmarking
1820
1921 env :
20- SKIP_BENCHMARKS : ' 0'
22+ SKIP_BENCHMARKS : ' 0'
23+ AUTO_COMMIT_WEIGHTS : ' 1'
2124
2225 steps :
23- - name : Check out PR branch
24- if : ${{ env.SKIP_BENCHMARKS != '1' }}
25- uses : actions/checkout@v4
26- with :
27- repository : ${{ github.event.pull_request.head.repo.full_name }}
28- ref : ${{ github.event.pull_request.head.ref }}
29- fetch-depth : 0
30-
31- - name : Install GitHub CLI
32- # We disallow skipping benchmarks for PRs from forks to avoid exposing secrets
33- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
34- run : |
35- sudo apt-get update
36- sudo apt-get install -y gh
37- echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
38-
39- - name : Check skip label
40- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
41- run : |
42- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
43- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
44- echo "skip-validate-benchmarks label found — skipping benchmarks."
45- echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
46- fi
47-
48- - name : Install system dependencies
49- if : ${{ env.SKIP_BENCHMARKS != '1' }}
50- run : |
51- sudo apt-get update
52- sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
53-
54- - name : Check skip label
55- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
56- run : |
57- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
58- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
59- echo "skip-validate-benchmarks label found — skipping benchmarks."
60- echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
61- fi
62-
63- - name : Install Rust toolchain
64- if : ${{ env.SKIP_BENCHMARKS != '1' }}
65- uses : actions-rs/toolchain@v1
66- with :
67- profile : minimal
68- toolchain : stable
69-
70- - name : Check skip label
71- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
72- run : |
73- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
74- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
75- echo "skip-validate-benchmarks label found — skipping benchmarks."
76- echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
77- fi
78-
79- - name : Cache Rust build
80- if : ${{ env.SKIP_BENCHMARKS != '1' }}
81- uses : Swatinem/rust-cache@v2
82- with :
83- key : bench-${{ hashFiles('**/Cargo.lock') }}
84-
85- - name : Check skip label
86- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
87- run : |
88- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
89- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
90- echo "skip-validate-benchmarks label found — skipping benchmarks."
91- echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
92- fi
93-
94- - name : Build node with benchmarks
95- if : ${{ env.SKIP_BENCHMARKS != '1' }}
96- run : |
97- cargo build --profile production -p node-subtensor --features runtime-benchmarks
98-
99- - name : Check skip label
100- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
101- run : |
102- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
103- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
104- echo "skip-validate-benchmarks label found — skipping benchmarks."
105- echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
106- fi
107-
108- - name : Run & validate benchmarks
109- if : ${{ env.SKIP_BENCHMARKS != '1' }}
110- run : |
111- chmod +x scripts/benchmark_action.sh
112- ./scripts/benchmark_action.sh
113-
114- - name : Check skip label after run
115- if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
116- run : |
117- labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
118- if echo "$labels" | grep -q "skip-validate-benchmarks"; then
119- echo "skip-validate-benchmarks label was found — but benchmarks already ran."
120- fi
26+ # ──────────────────────────────────────────────────────────────────
27+ - name : Check out PR branch
28+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
29+ uses : actions/checkout@v4
30+ with :
31+ ref : ${{ github.head_ref }}
32+ fetch-depth : 0
33+
34+ - name : Install GitHub CLI
35+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
36+ run : |
37+ sudo apt-get update
38+ sudo apt-get install -y gh
39+ echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
40+
41+ # (1) — original skip-label check
42+ - name : Check skip label
43+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
44+ run : |
45+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
46+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
47+ echo "skip-validate-benchmarks label found — skipping benchmarks."
48+ echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
49+ fi
50+
51+ - name : Install system dependencies
52+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
53+ run : |
54+ sudo apt-get update
55+ sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
56+
57+ # (2)
58+ - name : Check skip label
59+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
60+ run : |
61+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
62+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
63+ echo "skip-validate-benchmarks label found — skipping benchmarks."
64+ echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
65+ fi
66+
67+ - name : Install Rust toolchain
68+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
69+ uses : actions-rs/toolchain@v1
70+ with :
71+ profile : minimal
72+ toolchain : stable
73+
74+ # (3)
75+ - name : Check skip label
76+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
77+ run : |
78+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
79+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
80+ echo "skip-validate-benchmarks label found — skipping benchmarks."
81+ echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
82+ fi
83+
84+ - name : Cache Rust build
85+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
86+ uses : Swatinem/rust-cache@v2
87+ with :
88+ key : bench-${{ hashFiles('**/Cargo.lock') }}
89+
90+ # (4)
91+ - name : Check skip label
92+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
93+ run : |
94+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
95+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
96+ echo "skip-validate-benchmarks label found — skipping benchmarks."
97+ echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
98+ fi
99+
100+ - name : Build node with benchmarks
101+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
102+ run : |
103+ cargo build --profile production -p node-subtensor --features runtime-benchmarks
104+
105+ # (5)
106+ - name : Check skip label
107+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
108+ run : |
109+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
110+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
111+ echo "skip-validate-benchmarks label found — skipping benchmarks."
112+ echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
113+ fi
114+
115+ - name : Run & validate benchmarks
116+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
117+ run : |
118+ chmod +x scripts/benchmark_action.sh
119+ scripts/benchmark_action.sh
120+
121+ # (6) — final, unchanged
122+ - name : Check skip label after run
123+ if : ${{ env.SKIP_BENCHMARKS != '1' }}
124+ run : |
125+ labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
126+ if echo "$labels" | grep -q "skip-validate-benchmarks"; then
127+ echo "skip-validate-benchmarks label was found — but benchmarks already ran."
128+ fi
0 commit comments