@@ -6,15 +6,13 @@ concurrency:
6
6
7
7
on :
8
8
push :
9
- branches : [master, development, staging]
10
-
9
+ branches :
10
+ - ' ** '
11
11
pull_request :
12
- branches : [master, development, staging]
12
+ branches :
13
+ - ' **'
13
14
types : [ opened, synchronize, reopened, ready_for_review ]
14
15
15
- schedule :
16
- - cron : ' 0 9 * * *' # Run every night at 2:00 PST
17
-
18
16
workflow_dispatch :
19
17
inputs :
20
18
verbose :
28
26
29
27
# job to run tests in parallel
30
28
jobs :
31
-
29
+ # Looking for e2e tests
32
30
find-tests :
33
31
runs-on : ubuntu-latest
34
32
if : ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
@@ -44,20 +42,36 @@ jobs:
44
42
test_files=$(find tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
45
43
# keep it here for future debug
46
44
# test_files=$(find tests/e2e_tests -type f -name "test*.py" | grep -E 'test_(hotkeys|staking)\.py$' | jq -R -s -c 'split("\n") | map(select(. != ""))')
45
+ echo "Found test files: $test_files"
47
46
echo "test-files=$test_files" >> "$GITHUB_OUTPUT"
48
47
shell : bash
49
48
49
+ # Pull docker image
50
50
pull-docker-image :
51
51
runs-on : ubuntu-latest
52
+ outputs :
53
+ image-name : ${{ steps.set-output.outputs.image-name }}
52
54
steps :
55
+ - name : Set Docker image tag based on branch
56
+ id : set-output
57
+ run : |
58
+ ref="${{ github.ref_name }}"
59
+ if [[ "$ref" == "master" ]]; then
60
+ image="ghcr.io/opentensor/subtensor-localnet:main"
61
+ else
62
+ image="ghcr.io/opentensor/subtensor-localnet:devnet-ready"
63
+ fi
64
+ echo "Using image: $image"
65
+ echo "image-name=$image" >> "$GITHUB_OUTPUT"
66
+
53
67
- name : Log in to GitHub Container Registry
54
68
run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
55
69
56
70
- name : Pull Docker Image
57
- run : docker pull ghcr.io/opentensor/subtensor-localnet:devnet-ready
71
+ run : docker pull ${{ steps.set-output.outputs.image-name }}
58
72
59
73
- name : Save Docker Image to Cache
60
- run : docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:devnet-ready
74
+ run : docker save -o subtensor-localnet.tar ${{ steps.set-output.outputs.image-name }}
61
75
62
76
- name : Upload Docker Image as Artifact
63
77
uses : actions/upload-artifact@v4
@@ -104,95 +118,9 @@ jobs:
104
118
- name : Load Docker Image
105
119
run : docker load -i subtensor-localnet.tar
106
120
107
- # - name: Run tests
108
- # run: uv run pytest ${{ matrix.test-file }} -s
109
-
110
121
- name : Run tests with retry
111
- run : |
112
- set +e
113
- for i in 1 2 3; do
114
- echo "🔁 Attempt $i: Running tests"
115
- uv run pytest ${{ matrix.test-file }} -s
116
- status=$?
117
- if [ $status -eq 0 ]; then
118
- echo "✅ Tests passed on attempt $i"
119
- break
120
- else
121
- echo "❌ Tests failed on attempt $i"
122
- if [ $i -eq 3 ]; then
123
- echo "Tests failed after 3 attempts"
124
- exit 1
125
- fi
126
- echo "Retrying..."
127
- sleep 5
128
- fi
129
- done
130
-
131
- # run non-fast-blocks only on Saturday and by cron schedule
132
- check-if-saturday :
133
- if : github.event_name == 'schedule'
134
- runs-on : ubuntu-latest
135
- outputs :
136
- is-saturday : ${{ steps.check.outputs.is-saturday }}
137
- steps :
138
- - id : check
139
- run : |
140
- day=$(date -u +%u)
141
- echo "Today is weekday $day"
142
- if [ "$day" -ne 6 ]; then
143
- echo "⏭️ Skipping: not Saturday"
144
- echo "is-saturday=false" >> "$GITHUB_OUTPUT"
145
- exit 0
146
- fi
147
- echo "is-saturday=true"
148
- echo "is-saturday=true" >> "$GITHUB_OUTPUT"
149
-
150
-
151
- cron-run-non-fast-blocks-e2e-test :
152
- if : github.event_name == 'schedule' && needs.check-if-saturday.outputs.is-saturday == 'true'
153
- name : " NFB: ${{ matrix.test-file }} / Python ${{ matrix.python-version }}"
154
- needs :
155
- - check-if-saturday
156
- - find-tests
157
- - pull-docker-image
158
- runs-on : ubuntu-latest
159
- timeout-minutes : 1440
160
-
161
- strategy :
162
- fail-fast : false # Allow other matrix jobs to run even if this job fails
163
- max-parallel : 32 # Set the maximum number of parallel jobs (same as we have cores in ubuntu-latest runner)
164
- matrix :
165
- os :
166
- - ubuntu-latest
167
- test-file : ${{ fromJson(needs.find-tests.outputs.test-files) }}
168
- python-version : ["3.9", "3.10", "3.11", "3.12", "3.13"]
169
-
170
- steps :
171
- - name : Check-out repository
172
- uses : actions/checkout@v4
173
-
174
- - name : Set up Python ${{ matrix.python-version }}
175
- uses : actions/setup-python@v5
176
- with :
177
- python-version : ${{ matrix.python-version }}
178
-
179
- - name : Install uv
180
- uses : astral-sh/setup-uv@v4
181
-
182
- - name : install dependencies
183
- run : uv sync --extra dev --dev
184
-
185
- - name : Download Cached Docker Image
186
- uses : actions/download-artifact@v4
187
- with :
188
- name : subtensor-localnet
189
-
190
- - name : Load Docker Image
191
- run : docker load -i subtensor-localnet.tar
192
-
193
- - name : Run patched E2E tests
194
122
env :
195
- FAST_BLOCKS : " 0 "
123
+ LOCALNET_IMAGE_NAME : ${{ needs.pull-docker-image.outputs.image-name }}
196
124
run : |
197
125
set +e
198
126
for i in 1 2 3; do
@@ -212,3 +140,4 @@ jobs:
212
140
sleep 5
213
141
fi
214
142
done
143
+
0 commit comments