1
+ name : Bittensor BTCLI Test
2
+
3
+ concurrency :
4
+ group : e2e-sdk-${{ github.ref }}
5
+ cancel-in-progress : true
6
+
7
+ on :
8
+ pull_request :
9
+ branches :
10
+ - master
11
+ - staging
12
+ types : [opened, synchronize, reopened, labeled, unlabeled]
13
+
14
+ env :
15
+ CARGO_TERM_COLOR : always
16
+ VERBOSE : ${{ github.event.inputs.verbose }}
17
+
18
+ jobs :
19
+ check-labels :
20
+ runs-on : ubuntu-latest
21
+ if : ${{ github.event.pull_request.draft == false }}
22
+ outputs :
23
+ run-sdk-tests : ${{ contains(github.event.pull_request.labels.*.name, 'run-bittensor-sdk-tests') }}
24
+ steps :
25
+ - name : Check out repository
26
+ uses : actions/checkout@v4
27
+
28
+ find-e2e-tests :
29
+ needs : check-labels
30
+ if : always() && needs.check-labels.outputs.run-sdk-tests == 'true'
31
+ runs-on : ubuntu-latest
32
+ outputs :
33
+ test-files : ${{ steps.get-tests.outputs.test-files }}
34
+ steps :
35
+ - name : Research preparation
36
+ working-directory : ${{ github.workspace }}
37
+ run : git clone https://github.com/opentensor/btcli.git
38
+
39
+ - name : Checkout
40
+ working-directory : ${{ github.workspace }}/btcli
41
+ run : git checkout staging
42
+
43
+ - name : Install dependencies
44
+ run : sudo apt-get install -y jq
45
+
46
+ - name : Find e2e test files
47
+ id : get-tests
48
+ run : |
49
+ test_files=$(find ${{ github.workspace }}/bittensor/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
50
+ echo "::set-output name=test-files::$test_files"
51
+ shell : bash
52
+
53
+ pull-docker-image :
54
+ needs : check-labels
55
+ runs-on : ubuntu-latest
56
+ if : always() && needs.check-labels.outputs.run-sdk-tests == 'true'
57
+ steps :
58
+ - name : Log in to GitHub Container Registry
59
+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
60
+
61
+ - name : Pull Docker Image
62
+ run : docker pull ghcr.io/opentensor/subtensor-localnet:latest
63
+
64
+ - name : Save Docker Image to Cache
65
+ run : docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest
66
+
67
+ - name : Upload Docker Image as Artifact
68
+ uses : actions/upload-artifact@v4
69
+ with :
70
+ name : subtensor-localnet
71
+ path : subtensor-localnet.tar
72
+
73
+ run-e2e-tests :
74
+ needs :
75
+ - check-labels
76
+ - find-e2e-tests
77
+ - pull-docker-image
78
+
79
+ if : always() && needs.check-labels.outputs.run-sdk-tests == 'true'
80
+ runs-on : ubuntu-latest
81
+ strategy :
82
+ fail-fast : false
83
+ max-parallel : 32
84
+ matrix :
85
+ rust-branch :
86
+ - stable
87
+ rust-target :
88
+ - x86_64-unknown-linux-gnu
89
+ os :
90
+ - ubuntu-latest
91
+ test-file : ${{ fromJson(needs.find-e2e-tests.outputs.test-files) }}
92
+
93
+ env :
94
+ RELEASE_NAME : development
95
+ RUSTV : ${{ matrix.rust-branch }}
96
+ RUST_BACKTRACE : full
97
+ RUST_BIN_DIR : target/${{ matrix.rust-target }}
98
+ TARGET : ${{ matrix.rust-target }}
99
+
100
+ timeout-minutes : 60
101
+ name : " e2e tests: ${{ matrix.test-file }}"
102
+ steps :
103
+ - name : Check-out repository
104
+ uses : actions/checkout@v4
105
+
106
+ - name : Install Rust stable
107
+ uses : actions-rs/toolchain@v1.0.6
108
+ with :
109
+ toolchain : ${{ matrix.rust-branch }}
110
+ components : rustfmt
111
+ profile : minimal
112
+
113
+ - name : Install rust/cargo dependencies
114
+ run : |
115
+ sudo apt-get update &&
116
+ sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler jq
117
+
118
+ - name : Add wasm32-unknown-unknown target
119
+ run : |
120
+ rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
121
+ rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu
122
+
123
+ - name : Install uv
124
+ uses : astral-sh/setup-uv@v5
125
+
126
+ - name : Create Python virtual environment
127
+ working-directory : ${{ github.workspace }}
128
+ run : uv venv ${{ github.workspace }}/venv
129
+
130
+ - name : Clone Bittensor SDK repo
131
+ working-directory : ${{ github.workspace }}
132
+ run : git clone https://github.com/opentensor/btcli.git
133
+
134
+ - name : Setup Bittensor-cli from cloned repo
135
+ working-directory : ${{ github.workspace }}/btcli
136
+ run : |
137
+ source ${{ github.workspace }}/venv/bin/activate
138
+ git checkout staging
139
+ uv run --active pip install --upgrade pip
140
+ uv run --acrive pip install pytest
141
+ uv run --active pip install maturin
142
+
143
+ - name : Install uv dependencies
144
+ working-directory : ${{ github.workspace }}
145
+ run : uv sync --all-extras --dev
146
+
147
+ - name : Clone Bittensor Wallet repo
148
+ run : git clone https://github.com/opentensor/btwallet.git
149
+
150
+ - name : Checkout PR branch in Wallet repo
151
+ working-directory : ${{ github.workspace }}/btwallet
152
+ run : |
153
+ git fetch origin ${{ github.event.pull_request.head.ref }}
154
+ git checkout ${{ github.event.pull_request.head.ref }}
155
+ echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
156
+
157
+ - name : Build and install Rust Bittensor Wallet package
158
+ working-directory : ${{ github.workspace }}
159
+ run : |
160
+ source ${{ github.workspace }}/venv/bin/activate
161
+ uv run --active maturin develop
162
+
163
+ - name : Download Cached Docker Image
164
+ uses : actions/download-artifact@v4
165
+ with :
166
+ name : subtensor-localnet
167
+
168
+ - name : Load Docker Image
169
+ run : docker load -i subtensor-localnet.tar
170
+
171
+ - name : Run tests
172
+ working-directory : ${{ github.workspace }}
173
+ run : |
174
+ source ${{ github.workspace }}/venv/bin/activate
175
+ uv run pytest ${{ matrix.test-file }} -s
176
+
177
+
178
+ run-unit-test :
179
+ needs :
180
+ - check-labels
181
+ if : always() && needs.check-labels.outputs.run-sdk-tests == 'true'
182
+ runs-on : ubuntu-latest
183
+ steps :
184
+ - name : Check-out repository
185
+ uses : actions/checkout@v4
186
+
187
+ - name : Install dependencies
188
+ run : |
189
+ sudo apt-get update &&
190
+ sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
191
+
192
+ - name : Create Python virtual environment
193
+ working-directory : ${{ github.workspace }}
194
+ run : python3 -m venv venv
195
+
196
+ - name : Clone Bittensor SDK repo
197
+ working-directory : ${{ github.workspace }}
198
+ run : git clone https://github.com/opentensor/btcli.git
199
+
200
+ - name : Setup Bittensor SDK from cloned repo
201
+ working-directory : ${{ github.workspace }}/btcli
202
+ run : |
203
+ source ${{ github.workspace }}/venv/bin/activate
204
+ git checkout staging
205
+ python3 -m pip install --upgrade pip
206
+ python3 -m pip install '.[dev]'
207
+ python3 -m pip install maturin
208
+
209
+ - name : Clone Bittensor Wallet repo
210
+ run : git clone https://github.com/opentensor/btwallet.git
211
+
212
+ - name : Checkout PR branch in Wallet repo
213
+ working-directory : ${{ github.workspace }}/btwallet
214
+ run : |
215
+ git fetch origin ${{ github.event.pull_request.head.ref }}
216
+ git checkout ${{ github.event.pull_request.head.ref }}
217
+ echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
218
+
219
+ - name : Build and install Rust Bittensor Wallet package
220
+ working-directory : ${{ github.workspace }}
221
+ run : |
222
+ source ${{ github.workspace }}/venv/bin/activate
223
+ maturin develop
224
+
225
+ - name : Run SDK integration tests
226
+ working-directory : ${{ github.workspace }}
227
+ run : |
228
+ source ${{ github.workspace }}/venv/bin/activate
229
+ pytest ${{ github.workspace }}/bittensor/tests/integration_tests
230
+
231
+ - name : Run SDK unit tests
232
+ working-directory : ${{ github.workspace }}
233
+ run : |
234
+ source ${{ github.workspace }}/venv/bin/activate
235
+ pytest ${{ github.workspace }}/bittensor/tests/unit_tests
0 commit comments