Skip to content

Commit d5a632f

Browse files
Merge branch 'staging' into feat/dynamic-stake-prices
2 parents 3a58d4a + 3d648df commit d5a632f

File tree

4 files changed

+244
-86
lines changed

4 files changed

+244
-86
lines changed

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

+34-47
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525

2626
# job to run tests in parallel
2727
jobs:
28-
# Job to find all test files
28+
2929
find-tests:
3030
runs-on: ubuntu-latest
3131
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
@@ -42,68 +42,55 @@ jobs:
4242
echo "::set-output name=test-files::$test_files"
4343
shell: bash
4444

45+
pull-docker-image:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Log in to GitHub Container Registry
49+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
50+
51+
- name: Pull Docker Image
52+
run: docker pull ghcr.io/opentensor/subtensor-localnet:latest
53+
54+
- name: Save Docker Image to Cache
55+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest
56+
57+
- name: Upload Docker Image as Artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: subtensor-localnet
61+
path: subtensor-localnet.tar
62+
4563
# Job to run tests in parallel
4664
run:
47-
needs: find-tests
48-
runs-on: SubtensorCI
65+
needs:
66+
- find-tests
67+
- pull-docker-image
68+
runs-on: ubuntu-latest
4969
timeout-minutes: 45
5070
strategy:
5171
fail-fast: false # Allow other matrix jobs to run even if this job fails
52-
max-parallel: 8 # Set the maximum number of parallel jobs
72+
max-parallel: 32 # Set the maximum number of parallel jobs (same as we have cores in SubtensorCI runner)
5373
matrix:
54-
rust-branch:
55-
- stable
56-
rust-target:
57-
- x86_64-unknown-linux-gnu
5874
os:
5975
- ubuntu-latest
6076
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
61-
env:
62-
RELEASE_NAME: development
63-
RUSTV: ${{ matrix.rust-branch }}
64-
RUST_BACKTRACE: full
65-
RUST_BIN_DIR: target/${{ matrix.rust-target }}
66-
TARGET: ${{ matrix.rust-target }}
6777
steps:
68-
- name: Check-out repository under $GITHUB_WORKSPACE
78+
- name: Check-out repository
6979
uses: actions/checkout@v4
7080

71-
- name: Install dependencies
72-
run: |
73-
sudo apt-get update &&
74-
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
75-
76-
- name: Install Rust ${{ matrix.rust-branch }}
77-
uses: actions-rs/toolchain@v1.0.6
78-
with:
79-
toolchain: ${{ matrix.rust-branch }}
80-
components: rustfmt
81-
profile: minimal
82-
83-
- name: Add wasm32-unknown-unknown target
84-
run: |
85-
rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
86-
rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu
87-
88-
- name: Clone subtensor repo
89-
run: git clone https://github.com/opentensor/subtensor.git
90-
91-
- name: Setup subtensor repo
92-
working-directory: ${{ github.workspace }}/subtensor
93-
run: git checkout devnet-ready
94-
9581
- name: Install uv
9682
uses: astral-sh/setup-uv@v4
9783

9884
- name: install dependencies
9985
run: uv sync --all-extras --dev
10086

101-
- name: Run tests
102-
run: |
103-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
87+
- name: Download Cached Docker Image
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: subtensor-localnet
10491

105-
- name: Retry failed tests
106-
if: failure()
107-
run: |
108-
sleep 10
109-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
92+
- name: Load Docker Image
93+
run: docker load -i subtensor-localnet.tar
94+
95+
- name: Run tests
96+
run: uv run pytest ${{ matrix.test-file }} -s

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,49 @@ The Python interpreter output will look like below.
221221
>>>
222222
```
223223

224+
### Testing
225+
You can run integration and unit tests in interactive mode of IDE or in terminal mode using the command:
226+
```bash
227+
pytest tests/integration_tests
228+
pytest tests/unit_tests
229+
```
230+
231+
#### E2E tests have 2 options for launching (legacy runner):
232+
- using a compiler based on the substrait code
233+
- using an already built docker image (docker runner)
234+
235+
#### Using `docker runner` (default for now):
236+
- E2E tests with docker image do not require preliminary compilation
237+
- are executed very quickly
238+
- require docker installed in OS
239+
240+
Ho to use:
241+
```bash
242+
pytest tests/e2e_tests
243+
```
244+
245+
#### TUsing `legacy runner`:
246+
- Will start compilation of the collected code in your subtensor repository
247+
- you must provide the `LOCALNET_SH_PATH` variable in the local environment with the path to the file `/scripts/localnet.sh` in the cloned repository within your OS
248+
- you can use the `BUILD_BINARY=0` variable, this will skip the copy step for each test.
249+
- you can use the `USE_DOCKER=0` variable, this will run tests using the "legacy runner", even if docker is installed in your OS
250+
251+
#### Ho to use:
252+
Regular e2e tests run
253+
```bash
254+
LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
255+
```
256+
257+
If you want to skip re-build process for each e2e test
258+
```bash
259+
BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
260+
```
261+
262+
If you want to use legacy runner even with installed Docker in your OS
263+
```bash
264+
USE_DOCKER=0 BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
265+
```
266+
224267
---
225268

226269
## Release Guidelines

0 commit comments

Comments
 (0)