1
+ name : Bittensor Bittensor E2E Test
2
+
3
+ permissions :
4
+ pull-requests : write
5
+ contents : read
6
+
7
+ concurrency :
8
+ group : e2e-cli-${{ github.ref }}
9
+ cancel-in-progress : true
10
+
11
+ on :
12
+ pull_request :
13
+ branches :
14
+ - devnet
15
+ - devnet-ready
16
+ - testnet
17
+ - testnet-ready
18
+ - main
19
+ types : [opened, synchronize, reopened, labeled, unlabeled]
20
+
21
+ env :
22
+ CARGO_TERM_COLOR : always
23
+ VERBOSE : ${{ github.event.inputs.verbose }}
24
+
25
+ jobs :
26
+ apply-label-to-new-pr :
27
+ runs-on : ubuntu-latest
28
+ if : ${{ github.event.pull_request.draft == false }}
29
+ outputs :
30
+ should_continue : ${{ steps.check.outputs.should_continue }}
31
+ steps :
32
+ - name : Check
33
+ id : check
34
+ run : |
35
+ ACTION="${{ github.event.action }}"
36
+ if [[ "$ACTION" == "opened" || "$ACTION" == "reopened" ]]; then
37
+ echo "should_continue=true" >> $GITHUB_OUTPUT
38
+ else
39
+ echo "should_continue=false" >> $GITHUB_OUTPUT
40
+ fi
41
+ shell : bash
42
+
43
+ - name : Add label
44
+ if : steps.check.outputs.should_continue == 'true'
45
+ uses : actions-ecosystem/action-add-labels@v1
46
+ with :
47
+ github_token : ${{ secrets.GITHUB_TOKEN }}
48
+ labels : run-bittensor-e2e-tests
49
+
50
+ check-label :
51
+ needs : apply-label-to-new-pr
52
+ runs-on : ubuntu-latest
53
+ if : always()
54
+ outputs :
55
+ run-bittensor-e2e-tests : ${{ steps.get-labels.outputs.run-bittensor-e2e-tests }}
56
+ steps :
57
+ - name : Check out repository
58
+ uses : actions/checkout@v4
59
+
60
+ - name : Get labels from PR
61
+ id : get-labels
62
+ run : |
63
+ LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
64
+ echo "Current labels: $LABELS"
65
+ if echo "$LABELS" | grep -q "run-bittensor-e2e-tests"; then
66
+ echo "run-bittensor-e2e-tests=true" >> $GITHUB_ENV
67
+ echo "::set-output name=run-bittensor-e2e-tests::true"
68
+ else
69
+ echo "run-bittensor-e2e-tests=false" >> $GITHUB_ENV
70
+ echo "::set-output name=run-bittensor-e2e-tests::false"
71
+ fi
72
+ env :
73
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74
+
75
+ find-btcli-e2e-tests :
76
+ needs : check-label
77
+ if : always() && needs.check-label.outputs.run-bittensor-e2e-tests == 'true'
78
+ runs-on : ubuntu-latest
79
+ outputs :
80
+ test-files : ${{ steps.get-btcli-tests.outputs.test-files }}
81
+ steps :
82
+ - name : Research preparation
83
+ working-directory : ${{ github.workspace }}
84
+ run : git clone https://github.com/opentensor/btcli.git
85
+
86
+ - name : Checkout
87
+ working-directory : ${{ github.workspace }}/btcli
88
+ run : git checkout staging
89
+
90
+ - name : Install dependencies
91
+ run : sudo apt-get install -y jq
92
+
93
+ - name : Find e2e test files
94
+ id : get-btcli-tests
95
+ run : |
96
+ test_files=$(find ${{ github.workspace }}/btcli/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
97
+ echo "::set-output name=test-files::$test_files"
98
+ shell : bash
99
+
100
+ find-sdk-e2e-tests :
101
+ needs : check-label
102
+ if : always() && needs.check-label.outputs.run-bittensor-e2e-tests == 'true'
103
+ runs-on : ubuntu-latest
104
+ outputs :
105
+ test-files : ${{ steps.get-sdk-tests.outputs.test-files }}
106
+ steps :
107
+ - name : Research preparation
108
+ working-directory : ${{ github.workspace }}
109
+ run : git clone https://github.com/opentensor/bittensor.git
110
+
111
+ - name : Checkout
112
+ working-directory : ${{ github.workspace }}/bittensor
113
+ run : git checkout staging
114
+
115
+ - name : Install dependencies
116
+ run : sudo apt-get install -y jq
117
+
118
+ - name : Find e2e test files
119
+ id : get-sdk-tests
120
+ run : |
121
+ test_files=$(find ${{ github.workspace }}/bittensor/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
122
+ echo "::set-output name=test-files::$test_files"
123
+ shell : bash
124
+
125
+ build-image-with-current-branch :
126
+ needs : check-label
127
+ runs-on : SubtensorCI
128
+ steps :
129
+ - name : Checkout code
130
+ uses : actions/checkout@v4
131
+
132
+ - name : Set up QEMU
133
+ uses : docker/setup-qemu-action@v3
134
+
135
+ - name : Set up Docker Buildx
136
+ uses : docker/setup-buildx-action@v3
137
+
138
+ - name : Build Docker Image
139
+ run : docker build -f Dockerfile-localnet -t localnet .
140
+
141
+ - name : Save Docker Image as Tar
142
+ run : docker save -o subtensor-localnet.tar localnet
143
+
144
+ - name : Upload Docker Image as Artifact
145
+ uses : actions/upload-artifact@v4
146
+ with :
147
+ name : subtensor-localnet
148
+ path : subtensor-localnet.tar
149
+
150
+ # main btcli job
151
+ run-btcli-e2e-tests :
152
+ needs :
153
+ - check-label
154
+ - find-btcli-e2e-tests
155
+ - build-image-with-current-branch
156
+ if : always() && needs.check-label.outputs.run-bittensor-e2e-tests == 'true'
157
+ runs-on : ubuntu-latest
158
+ strategy :
159
+ fail-fast : false
160
+ max-parallel : 16
161
+ matrix :
162
+ rust-branch :
163
+ - stable
164
+ rust-target :
165
+ - x86_64-unknown-linux-gnu
166
+ os :
167
+ - ubuntu-latest
168
+ test-file : ${{ fromJson(needs.find-btcli-e2e-tests.outputs.test-files) }}
169
+
170
+ env :
171
+ RELEASE_NAME : development
172
+ RUSTV : ${{ matrix.rust-branch }}
173
+ RUST_BACKTRACE : full
174
+ RUST_BIN_DIR : target/${{ matrix.rust-target }}
175
+ TARGET : ${{ matrix.rust-target }}
176
+
177
+ timeout-minutes : 60
178
+ name : " cli: ${{ matrix.test-file }}"
179
+ steps :
180
+ - name : Check-out repository
181
+ uses : actions/checkout@v4
182
+
183
+ - name : Install uv
184
+ uses : astral-sh/setup-uv@v5
185
+
186
+ - name : Create Python virtual environment
187
+ working-directory : ${{ github.workspace }}
188
+ run : uv venv ${{ github.workspace }}/venv
189
+
190
+ - name : Clone Bittensor CLI repo
191
+ working-directory : ${{ github.workspace }}
192
+ run : git clone https://github.com/opentensor/btcli.git
193
+
194
+ - name : Setup Bittensor-cli from cloned repo
195
+ working-directory : ${{ github.workspace }}/btcli
196
+ run : |
197
+ source ${{ github.workspace }}/venv/bin/activate
198
+ git checkout staging
199
+ git fetch origin staging
200
+ uv run --active pip install --upgrade pip
201
+ uv run --active pip install '.[dev]'
202
+ uv run --active pip install pytest
203
+
204
+ - name : Install uv dependencies
205
+ working-directory : ${{ github.workspace }}/btcli
206
+ run : uv sync --all-extras --dev
207
+
208
+ - name : Download Cached Docker Image
209
+ uses : actions/download-artifact@v4
210
+ with :
211
+ name : subtensor-localnet
212
+
213
+ - name : Load Docker Image
214
+ run : docker load -i subtensor-localnet.tar
215
+
216
+ - name : Run tests
217
+ working-directory : ${{ github.workspace }}/btcli
218
+ run : |
219
+ source ${{ github.workspace }}/venv/bin/activate
220
+ uv run pytest ${{ matrix.test-file }} -s
221
+
222
+ # main sdk job
223
+ run-sdk-e2e-tests :
224
+ needs :
225
+ - check-label
226
+ - find-sdk-e2e-tests
227
+ - build-image-with-current-branch
228
+ if : always() && needs.check-label.outputs.run-bittensor-e2e-tests == 'true'
229
+ runs-on : ubuntu-latest
230
+ strategy :
231
+ fail-fast : false
232
+ max-parallel : 16
233
+ matrix :
234
+ rust-branch :
235
+ - stable
236
+ rust-target :
237
+ - x86_64-unknown-linux-gnu
238
+ os :
239
+ - ubuntu-latest
240
+ test-file : ${{ fromJson(needs.find-sdk-e2e-tests.outputs.test-files) }}
241
+
242
+ env :
243
+ RELEASE_NAME : development
244
+ RUSTV : ${{ matrix.rust-branch }}
245
+ RUST_BACKTRACE : full
246
+ RUST_BIN_DIR : target/${{ matrix.rust-target }}
247
+ TARGET : ${{ matrix.rust-target }}
248
+
249
+ timeout-minutes : 60
250
+ name : " sdk: ${{ matrix.test-file }}"
251
+ steps :
252
+ - name : Check-out repository
253
+ uses : actions/checkout@v4
254
+
255
+ - name : Install uv
256
+ uses : astral-sh/setup-uv@v5
257
+
258
+ - name : Create Python virtual environment
259
+ working-directory : ${{ github.workspace }}
260
+ run : uv venv ${{ github.workspace }}/venv
261
+
262
+ - name : Clone Bittensor SDK repo
263
+ working-directory : ${{ github.workspace }}
264
+ run : git clone https://github.com/opentensor/bittensor.git
265
+
266
+ - name : Setup Bittensor SDK from cloned repo
267
+ working-directory : ${{ github.workspace }}/bittensor
268
+ run : |
269
+ source ${{ github.workspace }}/venv/bin/activate
270
+ git checkout staging
271
+ git fetch origin staging
272
+ uv run --active pip install --upgrade pip
273
+ uv run --active pip install '.[dev]'
274
+ uv run --active pip install pytest
275
+
276
+ - name : Install uv dependencies
277
+ working-directory : ${{ github.workspace }}/bittensor
278
+ run : uv sync --all-extras --dev
279
+
280
+ - name : Download Cached Docker Image
281
+ uses : actions/download-artifact@v4
282
+ with :
283
+ name : subtensor-localnet
284
+
285
+ - name : Load Docker Image
286
+ run : docker load -i subtensor-localnet.tar
287
+
288
+ - name : Run tests
289
+ working-directory : ${{ github.workspace }}/bittensor
290
+ run : |
291
+ source ${{ github.workspace }}/venv/bin/activate
292
+ uv run pytest ${{ matrix.test-file }} -s
0 commit comments