1
- name : Run Unit Tests
1
+ name : Run Tests
2
2
3
3
on :
4
4
push :
5
- branches :
6
- - main
7
- - staging
5
+ branches : [main, staging]
8
6
pull_request :
9
- branches :
10
- - main
11
- - staging
7
+ branches : [main, staging]
8
+ workflow_dispatch :
12
9
13
10
jobs :
14
- run -tests :
11
+ find -tests :
15
12
runs-on : ubuntu-latest
16
13
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
18
57
uses : actions/checkout@v4
19
58
20
59
- name : Install uv
21
60
uses : astral-sh/setup-uv@v4
22
61
with :
23
- python-version : 3.13
62
+ python-version : ${{ matrix.python-version }}
24
63
25
- - name : install dependencies
64
+ - name : Install dependencies
26
65
run : |
27
66
uv venv .venv
28
67
source .venv/bin/activate
29
68
uv pip install .[dev]
30
69
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
+
31
78
- name : Run pytest
32
79
run : |
33
80
source .venv/bin/activate
34
- pytest tests
81
+ uv run pytest ${{ matrix.test-file }} -v -s
0 commit comments