Skip to content

Commit ed2b10a

Browse files
Merge pull request #89 from opentensor/release/1.0.9
Release/1.0.9
2 parents 94e40c4 + 52ea239 commit ed2b10a

File tree

5 files changed

+595
-53
lines changed

5 files changed

+595
-53
lines changed
+255
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
name: Bittensor BTCLI 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+
- main
15+
- staging
16+
types: [opened, synchronize, reopened, labeled, unlabeled]
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
VERBOSE: ${{ github.event.inputs.verbose }}
21+
22+
jobs:
23+
apply-label-to-new-pr:
24+
runs-on: ubuntu-latest
25+
if: ${{ github.event.pull_request.draft == false }}
26+
outputs:
27+
should_continue_cli: ${{ steps.check.outputs.should_continue_cli }}
28+
steps:
29+
- name: Check
30+
id: check
31+
run: |
32+
ACTION="${{ github.event.action }}"
33+
if [[ "$ACTION" == "opened" || "$ACTION" == "reopened" ]]; then
34+
echo "should_continue_cli=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "should_continue_cli=false" >> $GITHUB_OUTPUT
37+
fi
38+
shell: bash
39+
40+
- name: Add label
41+
if: steps.check.outputs.should_continue_cli == 'true'
42+
uses: actions-ecosystem/action-add-labels@v1
43+
with:
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
labels: run-bittensor-cli-tests
46+
47+
check-labels:
48+
needs: apply-label-to-new-pr
49+
runs-on: ubuntu-latest
50+
if: always()
51+
outputs:
52+
run-cli-tests: ${{ steps.get-labels.outputs.run-cli-tests }}
53+
steps:
54+
- name: Check out repository
55+
uses: actions/checkout@v4
56+
57+
- name: Get labels from PR
58+
id: get-labels
59+
run: |
60+
LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
61+
echo "Current labels: $LABELS"
62+
if echo "$LABELS" | grep -q "run-bittensor-cli-tests"; then
63+
echo "run-cli-tests=true" >> $GITHUB_ENV
64+
echo "::set-output name=run-cli-tests::true"
65+
else
66+
echo "run-cli-tests=false" >> $GITHUB_ENV
67+
echo "::set-output name=run-cli-tests::false"
68+
fi
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
find-e2e-tests:
73+
needs: check-labels
74+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
75+
runs-on: ubuntu-latest
76+
outputs:
77+
test-files: ${{ steps.get-tests.outputs.test-files }}
78+
steps:
79+
- name: Research preparation
80+
working-directory: ${{ github.workspace }}
81+
run: git clone https://github.com/opentensor/btcli.git
82+
83+
- name: Checkout
84+
working-directory: ${{ github.workspace }}/btcli
85+
run: git checkout staging
86+
87+
- name: Install dependencies
88+
run: sudo apt-get install -y jq
89+
90+
- name: Find e2e test files
91+
id: get-tests
92+
run: |
93+
test_files=$(find ${{ github.workspace }}/btcli/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
94+
echo "::set-output name=test-files::$test_files"
95+
shell: bash
96+
97+
pull-docker-image:
98+
needs: check-labels
99+
runs-on: ubuntu-latest
100+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
101+
steps:
102+
- name: Log in to GitHub Container Registry
103+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
104+
105+
- name: Pull Docker Image
106+
run: docker pull ghcr.io/opentensor/subtensor-localnet:devnet-ready
107+
108+
- name: Save Docker Image to Cache
109+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:devnet-ready
110+
111+
- name: Upload Docker Image as Artifact
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: subtensor-localnet
115+
path: subtensor-localnet.tar
116+
117+
run-e2e-tests:
118+
needs:
119+
- check-labels
120+
- find-e2e-tests
121+
- pull-docker-image
122+
123+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
124+
runs-on: ubuntu-latest
125+
strategy:
126+
fail-fast: false
127+
max-parallel: 16
128+
matrix:
129+
rust-branch:
130+
- stable
131+
rust-target:
132+
- x86_64-unknown-linux-gnu
133+
os:
134+
- ubuntu-latest
135+
test-file: ${{ fromJson(needs.find-e2e-tests.outputs.test-files) }}
136+
137+
env:
138+
RELEASE_NAME: development
139+
RUSTV: ${{ matrix.rust-branch }}
140+
RUST_BACKTRACE: full
141+
RUST_BIN_DIR: target/${{ matrix.rust-target }}
142+
TARGET: ${{ matrix.rust-target }}
143+
144+
timeout-minutes: 60
145+
name: "e2e tests: ${{ matrix.test-file }}"
146+
steps:
147+
- name: Check-out repository
148+
uses: actions/checkout@v4
149+
150+
- name: Install dependencies
151+
run: |
152+
sudo apt-get update &&
153+
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
154+
155+
- name: Create Python virtual environment
156+
working-directory: ${{ github.workspace }}
157+
run: python3 -m venv ${{ github.workspace }}/venv
158+
159+
- name: Clone Bittensor CLI repo
160+
working-directory: ${{ github.workspace }}
161+
run: git clone https://github.com/opentensor/btcli.git
162+
163+
- name: Setup Bittensor-cli from cloned repo
164+
working-directory: ${{ github.workspace }}/btcli
165+
run: |
166+
source ${{ github.workspace }}/venv/bin/activate
167+
git checkout staging
168+
git fetch origin staging
169+
python3 -m pip install --upgrade pip
170+
python3 -m pip install '.[dev]'
171+
python3 -m pip install pytest
172+
173+
- name: Clone async-substrate-interface repo
174+
run: git clone https://github.com/opentensor/async-substrate-interface.git
175+
176+
- name: Checkout PR async-substrate-interface repo
177+
working-directory: ${{ github.workspace }}/async-substrate-interface
178+
run: |
179+
git fetch origin ${{ github.event.pull_request.head.ref }}
180+
git checkout ${{ github.event.pull_request.head.ref }}
181+
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
182+
183+
- name: Install async-substrate-interface package
184+
working-directory: ${{ github.workspace }}/async-substrate-interface
185+
run: |
186+
source ${{ github.workspace }}/venv/bin/activate
187+
python3 -m pip uninstall async-substrate-interface -y
188+
python3 -m pip install .
189+
190+
- name: Download Cached Docker Image
191+
uses: actions/download-artifact@v4
192+
with:
193+
name: subtensor-localnet
194+
195+
- name: Load Docker Image
196+
run: docker load -i subtensor-localnet.tar
197+
198+
- name: Run tests
199+
run: |
200+
source ${{ github.workspace }}/venv/bin/activate
201+
pytest ${{ matrix.test-file }} -s
202+
203+
204+
run-unit-test:
205+
needs:
206+
- check-labels
207+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
208+
runs-on: ubuntu-latest
209+
steps:
210+
- name: Check-out repository
211+
uses: actions/checkout@v4
212+
213+
- name: Install dependencies
214+
run: |
215+
sudo apt-get update &&
216+
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
217+
218+
- name: Create Python virtual environment
219+
working-directory: ${{ github.workspace }}
220+
run: python3 -m venv venv
221+
222+
- name: Clone Bittensor CLI repo
223+
working-directory: ${{ github.workspace }}
224+
run: git clone https://github.com/opentensor/btcli.git
225+
226+
- name: Setup Bittensor SDK from cloned repo
227+
working-directory: ${{ github.workspace }}/btcli
228+
run: |
229+
source ${{ github.workspace }}/venv/bin/activate
230+
git checkout staging
231+
git fetch origin staging
232+
python3 -m pip install --upgrade pip
233+
python3 -m pip install '.[dev]'
234+
235+
- name: Clone async-substrate-interface repo
236+
run: git clone https://github.com/opentensor/async-substrate-interface.git
237+
238+
- name: Checkout PR branch in async-substrate-interface repo
239+
working-directory: ${{ github.workspace }}/async-substrate-interface
240+
run: |
241+
git fetch origin ${{ github.event.pull_request.head.ref }}
242+
git checkout ${{ github.event.pull_request.head.ref }}
243+
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
244+
245+
- name: Install /async-substrate-interface package
246+
working-directory: ${{ github.workspace }}/async-substrate-interface
247+
run: |
248+
source ${{ github.workspace }}/venv/bin/activate
249+
pip uninstall async-substrate-interface -y
250+
pip install .
251+
252+
- name: Run SDK unit tests
253+
run: |
254+
source ${{ github.workspace }}/venv/bin/activate
255+
pytest ${{ github.workspace }}/btcli/tests/unit_tests

0 commit comments

Comments
 (0)