Skip to content

Commit 5904a24

Browse files
committed
Merge remote-tracking branch 'origin/devnet' into testnet
2 parents 9adf24f + 77f93b6 commit 5904a24

File tree

8 files changed

+383
-715
lines changed

8 files changed

+383
-715
lines changed

Diff for: .github/workflows/check-btcli-tests.yml

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
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+
- 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_cli: ${{ steps.check.outputs.should_continue_cli }}
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_cli=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "should_continue_cli=false" >> $GITHUB_OUTPUT
40+
fi
41+
shell: bash
42+
43+
- name: Add label
44+
if: steps.check.outputs.should_continue_cli == 'true'
45+
uses: actions-ecosystem/action-add-labels@v1
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
labels: run-bittensor-cli-tests
49+
50+
check-labels:
51+
needs: apply-label-to-new-pr
52+
runs-on: ubuntu-latest
53+
if: always()
54+
outputs:
55+
run-cli-tests: ${{ steps.get-labels.outputs.run-cli-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-cli-tests"; then
66+
echo "run-cli-tests=true" >> $GITHUB_ENV
67+
echo "::set-output name=run-cli-tests::true"
68+
else
69+
echo "run-cli-tests=false" >> $GITHUB_ENV
70+
echo "::set-output name=run-cli-tests::false"
71+
fi
72+
env:
73+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
find-e2e-tests:
76+
needs: check-labels
77+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
78+
runs-on: ubuntu-latest
79+
outputs:
80+
test-files: ${{ steps.get-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-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+
pull-docker-image:
101+
needs: check-labels
102+
runs-on: ubuntu-latest
103+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
104+
steps:
105+
- name: Log in to GitHub Container Registry
106+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
107+
108+
- name: Pull Docker Image
109+
run: docker pull ghcr.io/opentensor/subtensor-localnet:latest
110+
111+
- name: Save Docker Image to Cache
112+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest
113+
114+
- name: Upload Docker Image as Artifact
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: subtensor-localnet
118+
path: subtensor-localnet.tar
119+
120+
# main job
121+
run-e2e-tests:
122+
needs:
123+
- check-labels
124+
- find-e2e-tests
125+
- pull-docker-image
126+
127+
if: always() && needs.check-labels.outputs.run-cli-tests == 'true'
128+
runs-on: ubuntu-latest
129+
strategy:
130+
fail-fast: false
131+
max-parallel: 16
132+
matrix:
133+
rust-branch:
134+
- stable
135+
rust-target:
136+
- x86_64-unknown-linux-gnu
137+
os:
138+
- ubuntu-latest
139+
test-file: ${{ fromJson(needs.find-e2e-tests.outputs.test-files) }}
140+
141+
env:
142+
RELEASE_NAME: development
143+
RUSTV: ${{ matrix.rust-branch }}
144+
RUST_BACKTRACE: full
145+
RUST_BIN_DIR: target/${{ matrix.rust-target }}
146+
TARGET: ${{ matrix.rust-target }}
147+
148+
timeout-minutes: 60
149+
name: "cli: ${{ matrix.test-file }}"
150+
steps:
151+
- name: Check-out repository
152+
uses: actions/checkout@v4
153+
154+
- name: Install uv
155+
uses: astral-sh/setup-uv@v5
156+
157+
- name: Create Python virtual environment
158+
working-directory: ${{ github.workspace }}
159+
run: uv venv ${{ github.workspace }}/venv
160+
161+
- name: Clone Bittensor CLI repo
162+
working-directory: ${{ github.workspace }}
163+
run: git clone https://github.com/opentensor/btcli.git
164+
165+
- name: Setup Bittensor-cli from cloned repo
166+
working-directory: ${{ github.workspace }}/btcli
167+
run: |
168+
source ${{ github.workspace }}/venv/bin/activate
169+
git checkout staging
170+
git fetch origin staging
171+
uv run --active pip install --upgrade pip
172+
uv run --active pip install '.[dev]'
173+
uv run --active pip install pytest
174+
175+
- name: Install uv dependencies
176+
working-directory: ${{ github.workspace }}/btcli
177+
run: uv sync --all-extras --dev
178+
179+
- name: Download Cached Docker Image
180+
uses: actions/download-artifact@v4
181+
with:
182+
name: subtensor-localnet
183+
184+
- name: Load Docker Image
185+
run: docker load -i subtensor-localnet.tar
186+
187+
- name: Run tests
188+
working-directory: ${{ github.workspace }}/btcli
189+
run: |
190+
source ${{ github.workspace }}/venv/bin/activate
191+
uv run pytest ${{ matrix.test-file }} -s

Diff for: .github/workflows/check-sdk-tests.yml

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: Bittensor SDK Test
2+
3+
permissions:
4+
pull-requests: write
5+
contents: read
6+
7+
concurrency:
8+
group: e2e-sdk-${{ 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_sdk: ${{ steps.check.outputs.should_continue_sdk }}
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_sdk=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "should_continue_sdk=false" >> $GITHUB_OUTPUT
40+
fi
41+
shell: bash
42+
43+
- name: Add label
44+
if: steps.check.outputs.should_continue_sdk == 'true'
45+
uses: actions-ecosystem/action-add-labels@v1
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
labels: run-bittensor-sdk-tests
49+
50+
check-labels:
51+
needs: apply-label-to-new-pr
52+
runs-on: ubuntu-latest
53+
if: always()
54+
outputs:
55+
run-sdk-tests: ${{ steps.get-labels.outputs.run-sdk-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+
sleep 5
64+
LABELS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')
65+
echo "Current labels: $LABELS"
66+
if echo "$LABELS" | grep -q "run-bittensor-sdk-tests"; then
67+
echo "run-sdk-tests=true" >> $GITHUB_OUTPUT
68+
else
69+
echo "run-sdk-tests=false" >> $GITHUB_OUTPUT
70+
fi
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
find-e2e-tests:
75+
needs: check-labels
76+
if: always() && needs.check-labels.outputs.run-sdk-tests == 'true'
77+
runs-on: ubuntu-latest
78+
outputs:
79+
test-files: ${{ steps.get-tests.outputs.test-files }}
80+
steps:
81+
- name: Research preparation
82+
working-directory: ${{ github.workspace }}
83+
run: git clone https://github.com/opentensor/bittensor.git
84+
85+
- name: Checkout
86+
working-directory: ${{ github.workspace }}/bittensor
87+
run: git checkout staging
88+
89+
- name: Install dependencies
90+
run: sudo apt-get install -y jq
91+
92+
- name: Find e2e test files
93+
id: get-tests
94+
run: |
95+
test_files=$(find ${{ github.workspace }}/bittensor/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
96+
echo "::set-output name=test-files::$test_files"
97+
shell: bash
98+
99+
pull-docker-image:
100+
needs: check-labels
101+
runs-on: ubuntu-latest
102+
if: always() && needs.check-labels.outputs.run-sdk-tests == 'true'
103+
steps:
104+
- name: Log in to GitHub Container Registry
105+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
106+
107+
- name: Pull Docker Image
108+
run: docker pull ghcr.io/opentensor/subtensor-localnet:devnet-ready
109+
110+
- name: Save Docker Image to Cache
111+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:devnet-ready
112+
113+
- name: Upload Docker Image as Artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: subtensor-localnet
117+
path: subtensor-localnet.tar
118+
119+
# main job
120+
run-e2e-tests:
121+
needs:
122+
- check-labels
123+
- find-e2e-tests
124+
- pull-docker-image
125+
126+
if: always() && needs.check-labels.outputs.run-sdk-tests == 'true'
127+
runs-on: ubuntu-latest
128+
strategy:
129+
fail-fast: false
130+
max-parallel: 16
131+
matrix:
132+
rust-branch:
133+
- stable
134+
rust-target:
135+
- x86_64-unknown-linux-gnu
136+
os:
137+
- ubuntu-latest
138+
test-file: ${{ fromJson(needs.find-e2e-tests.outputs.test-files) }}
139+
140+
env:
141+
RELEASE_NAME: development
142+
RUSTV: ${{ matrix.rust-branch }}
143+
RUST_BACKTRACE: full
144+
RUST_BIN_DIR: target/${{ matrix.rust-target }}
145+
TARGET: ${{ matrix.rust-target }}
146+
147+
timeout-minutes: 60
148+
name: "sdk: ${{ matrix.test-file }}"
149+
steps:
150+
- name: Check-out repository
151+
uses: actions/checkout@v4
152+
153+
- name: Install uv
154+
uses: astral-sh/setup-uv@v5
155+
156+
- name: Create Python virtual environment
157+
working-directory: ${{ github.workspace }}
158+
run: uv venv ${{ github.workspace }}/venv
159+
160+
- name: Clone Bittensor SDK repo
161+
working-directory: ${{ github.workspace }}
162+
run: git clone https://github.com/opentensor/bittensor.git
163+
164+
- name: Setup Bittensor SDK from cloned repo
165+
working-directory: ${{ github.workspace }}/bittensor
166+
run: |
167+
source ${{ github.workspace }}/venv/bin/activate
168+
git checkout staging
169+
git fetch origin staging
170+
uv run --active pip install --upgrade pip
171+
uv run --active pip install '.[dev]'
172+
uv run --active pip install pytest
173+
174+
- name: Install uv dependencies
175+
working-directory: ${{ github.workspace }}/bittensor
176+
run: uv sync --all-extras --dev
177+
178+
- name: Download Cached Docker Image
179+
uses: actions/download-artifact@v4
180+
with:
181+
name: subtensor-localnet
182+
183+
- name: Load Docker Image
184+
run: docker load -i subtensor-localnet.tar
185+
186+
- name: Run tests
187+
working-directory: ${{ github.workspace }}/bittensor
188+
run: |
189+
source ${{ github.workspace }}/venv/bin/activate
190+
uv run pytest ${{ matrix.test-file }} -s

0 commit comments

Comments
 (0)