Skip to content

Commit 7d03ece

Browse files
committed
Idk
1 parent 5865615 commit 7d03ece

File tree

1 file changed

+59
-12
lines changed

1 file changed

+59
-12
lines changed
Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,81 @@
1-
name: Run Unit Tests
1+
name: Run Tests
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- staging
5+
branches: [main, staging]
86
pull_request:
9-
branches:
10-
- main
11-
- staging
7+
branches: [main, staging]
8+
workflow_dispatch:
129

1310
jobs:
14-
run-tests:
11+
find-tests:
1512
runs-on: ubuntu-latest
1613
steps:
17-
- name: Check out repository
14+
- name: Check-out repository
15+
uses: actions/checkout@v4
16+
17+
- name: Find test files
18+
id: get-tests
19+
run: |
20+
test_files=$(find tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
21+
echo "::set-output name=test-files::$test_files"
22+
23+
pull-docker-image:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Log in to GitHub Container Registry
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
28+
29+
- name: Pull Docker Image
30+
run: docker pull ghcr.io/opentensor/subtensor-localnet:devnet-ready
31+
32+
- name: Save Docker Image to Cache
33+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:devnet-ready
34+
35+
- name: Upload Docker Image as Artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: subtensor-localnet
39+
path: subtensor-localnet.tar
40+
41+
run-unit-tests:
42+
name: ${{ matrix.test-file }} / Python ${{ matrix.python-version }}
43+
needs:
44+
- find-tests
45+
- pull-docker-image
46+
runs-on: ubuntu-latest
47+
timeout-minutes: 30
48+
strategy:
49+
fail-fast: false
50+
max-parallel: 32
51+
matrix:
52+
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
53+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
54+
55+
steps:
56+
- name: Check-out repository
1857
uses: actions/checkout@v4
1958

2059
- name: Install uv
2160
uses: astral-sh/setup-uv@v4
2261
with:
23-
python-version: 3.13
62+
python-version: ${{ matrix.python-version }}
2463

25-
- name: install dependencies
64+
- name: Install dependencies
2665
run: |
2766
uv venv .venv
2867
source .venv/bin/activate
2968
uv pip install .[dev]
3069
70+
- name: Download Docker Image
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: subtensor-localnet
74+
75+
- name: Load Docker Image
76+
run: docker load -i subtensor-localnet.tar
77+
3178
- name: Run pytest
3279
run: |
3380
source .venv/bin/activate
34-
pytest tests
81+
uv run pytest ${{ matrix.test-file }} -v -s

0 commit comments

Comments
 (0)