Skip to content

Commit c1d3695

Browse files
committed
Update check-sdk-tests.yml
1 parent 2a1e923 commit c1d3695

File tree

1 file changed

+53
-48
lines changed

1 file changed

+53
-48
lines changed

.github/workflows/check-sdk-tests.yml

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ jobs:
5757
runs-on: ubuntu-latest
5858
if: always()
5959
outputs:
60-
run-sdk-tests: ${{ steps.get-labels.outputs.run-sdk-tests }}
60+
run-sdk-tests: ${{ steps.check-manual.outputs.run-sdk-tests || steps.get-labels-pr.outputs.run-sdk-tests }}
6161
steps:
6262
- name: Check out repository
6363
uses: actions/checkout@v4
6464

6565
- name: Skip label check for manual runs
66-
id: get-labels
66+
id: check-manual
6767
if: ${{ github.event_name == 'workflow_dispatch' }}
6868
run: |
6969
echo "Manual workflow dispatch detected, skipping PR label check."
@@ -74,11 +74,13 @@ jobs:
7474
if: ${{ github.event_name == 'pull_request' }}
7575
run: |
7676
sleep 5
77-
LABELS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')
77+
LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
7878
echo "Current labels: $LABELS"
7979
if echo "$LABELS" | grep -q "run-bittensor-sdk-tests"; then
80+
echo "run-sdk-tests=true" >> $GITHUB_ENV
8081
echo "run-sdk-tests=true" >> $GITHUB_OUTPUT
8182
else
83+
echo "run-sdk-tests=false" >> $GITHUB_ENV
8284
echo "run-sdk-tests=false" >> $GITHUB_OUTPUT
8385
fi
8486
env:
@@ -171,48 +173,51 @@ jobs:
171173
- name: Check-out repository
172174
uses: actions/checkout@v4
173175

174-
- name: Install dependencies
176+
- name: Install system dependencies
175177
run: |
176178
sudo apt-get update &&
177179
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
178180
179-
- name: Create Python virtual environment
180-
working-directory: ${{ github.workspace }}
181-
run: python3 -m venv ${{ github.workspace }}/venv
181+
- name: Set up Python
182+
uses: actions/setup-python@v5
183+
with:
184+
python-version: '3.13'
185+
186+
- name: Install uv
187+
uses: astral-sh/setup-uv@v4
182188

183189
- name: Clone Bittensor SDK repo
184-
working-directory: ${{ github.workspace }}
185190
run: git clone https://github.com/opentensor/bittensor.git
186191

187-
- name: Setup Bittensor SDK from cloned repo
192+
- name: Checkout Bittensor branch
188193
working-directory: ${{ github.workspace }}/bittensor
189194
run: |
190-
source ${{ github.workspace }}/venv/bin/activate
191195
if ! git fetch origin $BITTENSOR_BRANCH; then
192196
echo "❌ Error: Branch '$BITTENSOR_BRANCH' does not exist in opentensor/bittensor."
193197
exit 1
194198
fi
195199
git checkout FETCH_HEAD
196200
echo "✅ Using Bittensor branch: $BITTENSOR_BRANCH"
197-
python3 -m pip install --upgrade pip uv
198-
uv pip install '.[dev]'
199201
200-
- name: Clone Bittensor async-substrate-interface repo
202+
- name: Install Bittensor SDK dependencies
203+
working-directory: ${{ github.workspace }}/bittensor
204+
run: uv pip install --system '.[dev]'
205+
206+
- name: Clone async-substrate-interface repo
201207
run: git clone https://github.com/opentensor/async-substrate-interface.git
202208

203-
- name: Checkout PR branch in async-substrate-interface repo
209+
- name: Checkout PR branch in async-substrate-interface
204210
working-directory: ${{ github.workspace }}/async-substrate-interface
205211
run: |
206212
git fetch origin ${{ github.event.pull_request.head.ref }}
207213
git checkout ${{ github.event.pull_request.head.ref }}
208214
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
209215
210-
- name: Install async-substrate-interface package
216+
- name: Install async-substrate-interface with dev dependencies
211217
working-directory: ${{ github.workspace }}/async-substrate-interface
212218
run: |
213-
source ${{ github.workspace }}/venv/bin/activate
214-
python3 -m pip uninstall async-substrate-interface -y
215-
uv pip install .
219+
uv pip uninstall --system async-substrate-interface || true
220+
uv pip install --system '.[dev]'
216221
217222
- name: Download Cached Docker Image
218223
uses: actions/download-artifact@v4
@@ -222,10 +227,8 @@ jobs:
222227
- name: Load Docker Image
223228
run: docker load -i subtensor-localnet.tar
224229

225-
- name: Run tests
226-
run: |
227-
source ${{ github.workspace }}/venv/bin/activate
228-
python3 -m pytest ${{ matrix.test-file }} -s
230+
- name: Run e2e tests
231+
run: pytest ${{ matrix.test-file }} -s
229232

230233

231234
run-integration-and-unit-test:
@@ -237,52 +240,54 @@ jobs:
237240
- name: Check-out repository
238241
uses: actions/checkout@v4
239242

240-
- name: Install dependencies
243+
- name: Install system dependencies
241244
run: |
242245
sudo apt-get update &&
243246
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
244247
245-
- name: Create Python virtual environment
246-
working-directory: ${{ github.workspace }}
247-
run: python3 -m venv venv
248+
- name: Set up Python
249+
uses: actions/setup-python@v5
250+
with:
251+
python-version: '3.13'
252+
253+
- name: Install uv
254+
uses: astral-sh/setup-uv@v4
248255

249256
- name: Clone Bittensor SDK repo
250-
working-directory: ${{ github.workspace }}
251257
run: git clone https://github.com/opentensor/bittensor.git
252258

253-
- name: Setup Bittensor SDK from cloned repo
259+
- name: Checkout Bittensor branch
254260
working-directory: ${{ github.workspace }}/bittensor
255261
run: |
256-
source ${{ github.workspace }}/venv/bin/activate
257262
if ! git fetch origin $BITTENSOR_BRANCH; then
258263
echo "❌ Error: Branch '$BITTENSOR_BRANCH' does not exist in opentensor/bittensor."
259264
exit 1
260265
fi
261266
git checkout FETCH_HEAD
262267
echo "✅ Using Bittensor branch: $BITTENSOR_BRANCH"
263-
python3 -m pip install --upgrade pip uv
264-
uv pip install '.[dev]'
265268
266-
- name: Checkout PR branch in async-substrate-interface repo
267-
uses: actions/checkout@v4
268-
with:
269-
repository: ${{ github.event.pull_request.head.repo.full_name }}
270-
ref: ${{ github.event.pull_request.head.ref }}
271-
path: async-substrate-interface
269+
- name: Install Bittensor SDK dependencies
270+
working-directory: ${{ github.workspace }}/bittensor
271+
run: uv pip install --system '.[dev]'
272272

273-
- name: Install /async-substrate-interface package
273+
- name: Clone async-substrate-interface repo
274+
run: git clone https://github.com/opentensor/async-substrate-interface.git
275+
276+
- name: Checkout PR branch in async-substrate-interface
274277
working-directory: ${{ github.workspace }}/async-substrate-interface
275278
run: |
276-
source ${{ github.workspace }}/venv/bin/activate
277-
pip uninstall async-substrate-interface -y
278-
uv pip install .
279+
git fetch origin ${{ github.event.pull_request.head.ref }}
280+
git checkout ${{ github.event.pull_request.head.ref }}
281+
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
279282
280-
- name: Run SDK integration tests
283+
- name: Install async-substrate-interface with dev dependencies
284+
working-directory: ${{ github.workspace }}/async-substrate-interface
281285
run: |
282-
source ${{ github.workspace }}/venv/bin/activate
283-
pytest ${{ github.workspace }}/bittensor/tests/integration_tests
286+
uv pip uninstall --system async-substrate-interface || true
287+
uv pip install --system '.[dev]'
284288
285-
- name: Run bittensor-sdk unit tests
286-
run: |
287-
source ${{ github.workspace }}/venv/bin/activate
288-
pytest ${{ github.workspace }}/bittensor/tests/unit_tests
289+
- name: Run SDK integration tests
290+
run: pytest ${{ github.workspace }}/bittensor/tests/integration_tests
291+
292+
- name: Run Bittensor SDK unit tests
293+
run: pytest ${{ github.workspace }}/bittensor/tests/unit_tests

0 commit comments

Comments
 (0)