Skip to content

Commit b61dd30

Browse files
authored
Merge pull request #1395 from opentensor/testnet
mainnet deploy 3/19/2025
2 parents 27de7d5 + 5904a24 commit b61dd30

File tree

147 files changed

+15183
-1887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+15183
-1887
lines changed
+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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Localnet Docker Image
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: SubtensorCI
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v2
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Build Docker Image
21+
run: docker build -f Dockerfile-localnet -t localnet .

0 commit comments

Comments
 (0)