Skip to content

Commit 813b8dd

Browse files
committed
run each test separately (save a bunch of the time)
1 parent bb57491 commit 813b8dd

File tree

1 file changed

+78
-10
lines changed

1 file changed

+78
-10
lines changed

.github/workflows/check-bittensor-e2e-tests.yml

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,45 @@ jobs:
8181
working-directory: ${{ github.workspace }}/btcli
8282
run: git checkout staging
8383

84+
- name: Set up Python
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version: '3.10'
88+
89+
- name: Install uv
90+
uses: astral-sh/setup-uv@v5
91+
with:
92+
enable-cache: "false"
93+
94+
- name: Create Python virtual environment
95+
working-directory: ${{ github.workspace }}/btcli
96+
run: uv venv --seed
97+
98+
- name: Install dependencies
99+
working-directory: ${{ github.workspace }}/btcli
100+
run: |
101+
source .venv/bin/activate
102+
uv run --active pip install --upgrade pip
103+
uv run --active pip install '.[dev]'
104+
uv run --active pip install pytest
105+
84106
- name: Find e2e test files
85107
id: get-btcli-tests
108+
working-directory: ${{ github.workspace }}/btcli
86109
run: |
87-
test_files=$(find ${{ github.workspace }}/btcli/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
88-
echo "test-files=$test_files" >> $GITHUB_OUTPUT
110+
set -euo pipefail
111+
test_matrix=$(
112+
source .venv/bin/activate
113+
uv run pytest -q --collect-only tests/e2e_tests \
114+
| sed -n '/^tests\//p' \
115+
| jq -R -s -c '
116+
split("\n")
117+
| map(select(. != ""))
118+
| map({nodeid: ., label: (sub("^tests/e2e_tests/"; ""))})
119+
'
120+
)
121+
echo "Found tests: $test_matrix"
122+
echo "test-files=$test_matrix" >> "$GITHUB_OUTPUT"
89123
shell: bash
90124

91125
find-sdk-e2e-tests:
@@ -108,11 +142,45 @@ jobs:
108142
working-directory: ${{ github.workspace }}/bittensor
109143
run: git checkout staging
110144

145+
- name: Set up Python
146+
uses: actions/setup-python@v5
147+
with:
148+
python-version: '3.10'
149+
150+
- name: Install uv
151+
uses: astral-sh/setup-uv@v5
152+
with:
153+
enable-cache: "false"
154+
155+
- name: Create Python virtual environment
156+
working-directory: ${{ github.workspace }}/bittensor
157+
run: uv venv --seed
158+
159+
- name: Install dependencies
160+
working-directory: ${{ github.workspace }}/bittensor
161+
run: |
162+
source .venv/bin/activate
163+
uv run --active pip install --upgrade pip
164+
uv run --active pip install '.[dev]'
165+
uv run --active pip install pytest
166+
111167
- name: Find e2e test files
112168
id: get-sdk-tests
169+
working-directory: ${{ github.workspace }}/bittensor
113170
run: |
114-
test_files=$(find ${{ github.workspace }}/bittensor/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
115-
echo "test-files=$test_files" >> $GITHUB_OUTPUT
171+
set -euo pipefail
172+
test_matrix=$(
173+
source .venv/bin/activate
174+
uv run pytest -q --collect-only tests/e2e_tests \
175+
| sed -n '/^tests\//p' \
176+
| jq -R -s -c '
177+
split("\n")
178+
| map(select(. != ""))
179+
| map({nodeid: ., label: (sub("^tests/e2e_tests/"; ""))})
180+
'
181+
)
182+
echo "Found tests: $test_matrix"
183+
echo "test-files=$test_matrix" >> "$GITHUB_OUTPUT"
116184
shell: bash
117185

118186
# build artifacts for fast-runtime and non-fast-runtime
@@ -257,7 +325,7 @@ jobs:
257325
- x86_64-unknown-linux-gnu
258326
os:
259327
- ubuntu-latest
260-
test-file: ${{ fromJson(needs.find-btcli-e2e-tests.outputs.test-files) }}
328+
include: ${{ fromJson(needs.find-btcli-e2e-tests.outputs.test-files) }}
261329

262330
env:
263331
RELEASE_NAME: development
@@ -267,7 +335,7 @@ jobs:
267335
TARGET: ${{ matrix.rust-target }}
268336

269337
timeout-minutes: 60
270-
name: "cli: ${{ matrix.test-file }}"
338+
name: "cli: ${{ matrix.label }}"
271339
steps:
272340
- name: Check-out repository
273341
uses: actions/checkout@v4
@@ -317,7 +385,7 @@ jobs:
317385
set +e
318386
for i in 1 2; do
319387
echo "🔁 Attempt $i: Running tests"
320-
uv run pytest ${{ matrix.test-file }} -s
388+
uv run pytest "${{ matrix.nodeid }}" -s
321389
status=$?
322390
if [ $status -eq 0 ]; then
323391
echo "✅ Tests passed on attempt $i"
@@ -351,7 +419,7 @@ jobs:
351419
- x86_64-unknown-linux-gnu
352420
os:
353421
- ubuntu-latest
354-
test-file: ${{ fromJson(needs.find-sdk-e2e-tests.outputs.test-files) }}
422+
include: ${{ fromJson(needs.find-sdk-e2e-tests.outputs.test-files) }}
355423

356424
env:
357425
RELEASE_NAME: development
@@ -361,7 +429,7 @@ jobs:
361429
TARGET: ${{ matrix.rust-target }}
362430

363431
timeout-minutes: 60
364-
name: "sdk: ${{ matrix.test-file }}"
432+
name: "sdk: ${{ matrix.label }}"
365433
steps:
366434
- name: Check-out repository
367435
uses: actions/checkout@v4
@@ -411,7 +479,7 @@ jobs:
411479
set +e
412480
for i in 1 2; do
413481
echo "🔁 Attempt $i: Running tests"
414-
uv run pytest ${{ matrix.test-file }} -s
482+
uv run pytest "${{ matrix.nodeid }}" -s
415483
status=$?
416484
if [ $status -eq 0 ]; then
417485
echo "✅ Tests passed on attempt $i"

0 commit comments

Comments
 (0)