Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 34 additions & 47 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:

# job to run tests in parallel
jobs:
# Job to find all test files

find-tests:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
Expand All @@ -42,68 +42,55 @@ jobs:
echo "::set-output name=test-files::$test_files"
shell: bash

pull-docker-image:
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin

- name: Pull Docker Image
run: docker pull ghcr.io/opentensor/subtensor-localnet:latest

- name: Save Docker Image to Cache
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest

- name: Upload Docker Image as Artifact
uses: actions/upload-artifact@v4
with:
name: subtensor-localnet
path: subtensor-localnet.tar

# Job to run tests in parallel
run:
needs: find-tests
runs-on: SubtensorCI
needs:
- find-tests
- pull-docker-image
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false # Allow other matrix jobs to run even if this job fails
max-parallel: 8 # Set the maximum number of parallel jobs
max-parallel: 32 # Set the maximum number of parallel jobs (same as we have cores in SubtensorCI runner)
matrix:
rust-branch:
- stable
rust-target:
- x86_64-unknown-linux-gnu
os:
- ubuntu-latest
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
env:
RELEASE_NAME: development
RUSTV: ${{ matrix.rust-branch }}
RUST_BACKTRACE: full
RUST_BIN_DIR: target/${{ matrix.rust-target }}
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Install Rust ${{ matrix.rust-branch }}
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: ${{ matrix.rust-branch }}
components: rustfmt
profile: minimal

- name: Add wasm32-unknown-unknown target
run: |
rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu

- name: Clone subtensor repo
run: git clone https://github.com/opentensor/subtensor.git

- name: Setup subtensor repo
working-directory: ${{ github.workspace }}/subtensor
run: git checkout devnet-ready

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: install dependencies
run: uv sync --all-extras --dev

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

- name: Retry failed tests
if: failure()
run: |
sleep 10
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
- name: Load Docker Image
run: docker load -i subtensor-localnet.tar

- name: Run tests
run: uv run pytest ${{ matrix.test-file }} -s
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,49 @@ The Python interpreter output will look like below.
>>>
```

### Testing
You can run integration and unit tests in interactive mode of IDE or in terminal mode using the command:
```bash
pytest tests/integration_tests
pytest tests/unit_tests
```

#### E2E tests have 2 options for launching (legacy runner):
- using a compiler based on the substrait code
- using an already built docker image (docker runner)

#### Using `docker runner` (default for now):
- E2E tests with docker image do not require preliminary compilation
- are executed very quickly
- require docker installed in OS

Ho to use:
```bash
pytest tests/e2e_tests
```

#### TUsing `legacy runner`:
- Will start compilation of the collected code in your subtensor repository
- 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
- you can use the `BUILD_BINARY=0` variable, this will skip the copy step for each test.
- you can use the `USE_DOCKER=0` variable, this will run tests using the "legacy runner", even if docker is installed in your OS

#### Ho to use:
Regular e2e tests run
```bash
LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

If you want to skip re-build process for each e2e test
```bash
BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

If you want to use legacy runner even with installed Docker in your OS
```bash
USE_DOCKER=0 BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

---

## Release Guidelines
Expand Down
Loading
Loading