Skip to content

Commit 07952fc

Browse files
author
Roman
committed
cleanup and improve regular e2e tests workflow
1 parent dc48920 commit 07952fc

File tree

1 file changed

+23
-95
lines changed

1 file changed

+23
-95
lines changed

.github/workflows/e2e-subtensor-tests.yaml

Lines changed: 23 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ concurrency:
66

77
on:
88
push:
9-
branches: [master, development, staging]
9+
branches: *
1010

1111
pull_request:
12-
branches: [master, development, staging]
12+
branches: *
1313
types: [ opened, synchronize, reopened, ready_for_review ]
1414

15-
schedule:
16-
- cron: '0 9 * * *' # Run every night at 2:00 PST
17-
1815
workflow_dispatch:
1916
inputs:
2017
verbose:
@@ -28,7 +25,7 @@ env:
2825

2926
# job to run tests in parallel
3027
jobs:
31-
28+
# Looking for e2e tests
3229
find-tests:
3330
runs-on: ubuntu-latest
3431
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
@@ -44,20 +41,36 @@ jobs:
4441
test_files=$(find tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
4542
# keep it here for future debug
4643
# 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(. != ""))')
44+
echo "Found test files: $test_files"
4745
echo "test-files=$test_files" >> "$GITHUB_OUTPUT"
4846
shell: bash
4947

48+
# Pull docker image
5049
pull-docker-image:
5150
runs-on: ubuntu-latest
51+
outputs:
52+
image-name: ${{ steps.set-output.outputs.image-name }}
5253
steps:
54+
- name: Set Docker image tag based on branch
55+
id: set-output
56+
run: |
57+
ref="${{ github.ref_name }}"
58+
if [[ "$ref" == "master" ]]; then
59+
image="ghcr.io/opentensor/subtensor-localnet:main"
60+
else
61+
image="ghcr.io/opentensor/subtensor-localnet:devnet-ready"
62+
fi
63+
echo "Using image: $image"
64+
echo "image-name=$image" >> "$GITHUB_OUTPUT"
65+
5366
- name: Log in to GitHub Container Registry
5467
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
5568

5669
- name: Pull Docker Image
57-
run: docker pull ghcr.io/opentensor/subtensor-localnet:devnet-ready
70+
run: docker pull ${{ steps.set-output.outputs.image-name }}
5871

5972
- name: Save Docker Image to Cache
60-
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:devnet-ready
73+
run: docker save -o subtensor-localnet.tar ${{ steps.set-output.outputs.image-name }}
6174

6275
- name: Upload Docker Image as Artifact
6376
uses: actions/upload-artifact@v4
@@ -104,95 +117,9 @@ jobs:
104117
- name: Load Docker Image
105118
run: docker load -i subtensor-localnet.tar
106119

107-
# - name: Run tests
108-
# run: uv run pytest ${{ matrix.test-file }} -s
109-
110120
- 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
194121
env:
195-
FAST_BLOCKS: "0"
122+
LOCALNET_IMAGE_NAME: ${{ needs.pull-docker-image.outputs.image-name }}
196123
run: |
197124
set +e
198125
for i in 1 2 3; do
@@ -212,3 +139,4 @@ jobs:
212139
sleep 5
213140
fi
214141
done
142+

0 commit comments

Comments
 (0)