Release/v10.0.1 #4186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: E2E Subtensor Tests | |
| concurrency: | |
| group: e2e-subtensor-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| pull-requests: read | |
| contents: read | |
| on: | |
| pull_request: | |
| branches: | |
| - '**' | |
| types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ] | |
| workflow_dispatch: | |
| inputs: | |
| docker_image_tag: | |
| description: "Docker image tag" | |
| required: false | |
| type: choice | |
| default: "devnet-ready" | |
| options: | |
| - main | |
| - testnet | |
| - devnet | |
| - devnet-ready | |
| # job to run tests in parallel | |
| jobs: | |
| # Looking for e2e tests | |
| find-tests: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} | |
| outputs: | |
| test-files: ${{ steps.get-tests.outputs.test-files }} | |
| steps: | |
| - name: Check-out repository under $GITHUB_WORKSPACE | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: false | |
| cache-dependency-glob: '**/pyproject.toml' | |
| ignore-nothing-to-cache: true | |
| - name: Cache uv and venv | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: uv-${{ runner.os }}-py3.10-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: uv-${{ runner.os }}-py3.10- | |
| - name: Install dependencies (faster if cache hit) | |
| run: uv sync --extra dev --dev | |
| - name: Find test files | |
| id: get-tests | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| test_matrix=$( | |
| uv run pytest -q --collect-only tests/e2e_tests \ | |
| | sed -n '/^e2e_tests\//p' \ | |
| | sed 's|^|tests/|' \ | |
| | jq -R -s -c ' | |
| split("\n") | |
| | map(select(. != "")) | |
| | map({nodeid: ., label: (sub("^tests/e2e_tests/"; ""))}) | |
| ' | |
| ) | |
| echo "Found tests: $test_matrix" | |
| echo "test-files=$test_matrix" >> "$GITHUB_OUTPUT" | |
| # Read Python versions | |
| read-python-versions: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| python-versions: ${{ steps.read-versions.outputs.versions }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: read-versions | |
| run: | | |
| versions=$(cat .github/supported-python-versions.json) | |
| echo "versions=$versions" >> $GITHUB_OUTPUT | |
| # Pull docker image | |
| pull-docker-image: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image-name: ${{ steps.set-image.outputs.image }} | |
| steps: | |
| - name: Install GitHub CLI | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update | |
| sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh jq | |
| - name: Set Docker image tag based on label or branch | |
| id: set-image | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "Event: $GITHUB_EVENT_NAME" | |
| echo "Branch: $GITHUB_REF_NAME" | |
| # Check if docker_image_tag input is provided (for workflow_dispatch) | |
| if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then | |
| docker_tag_input="${{ github.event.inputs.docker_image_tag }}" | |
| if [[ -n "$docker_tag_input" ]]; then | |
| image="ghcr.io/opentensor/subtensor-localnet:${docker_tag_input}" | |
| echo "Using Docker image tag from workflow_dispatch input: ${docker_tag_input}" | |
| echo "✅ Final selected image: $image" | |
| echo "image=$image" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| fi | |
| echo "Reading labels ..." | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| # Use GitHub CLI to read labels (works for forks too) | |
| labels=$(gh pr view ${{ github.event.pull_request.number }} -R ${{ github.repository }} --json labels --jq '.labels[].name' || echo "") | |
| echo "Found labels: $labels" | |
| else | |
| labels="" | |
| fi | |
| image="" | |
| for label in $labels; do | |
| echo "Found label: $label" | |
| case "$label" in | |
| "subtensor-localnet:main") | |
| image="ghcr.io/opentensor/subtensor-localnet:main" | |
| break | |
| ;; | |
| "subtensor-localnet:testnet") | |
| image="ghcr.io/opentensor/subtensor-localnet:testnet" | |
| break | |
| ;; | |
| "subtensor-localnet:devnet") | |
| image="ghcr.io/opentensor/subtensor-localnet:devnet" | |
| break | |
| ;; | |
| esac | |
| done | |
| if [[ -z "$image" ]]; then | |
| # fallback to default based on branch | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| # For PR, use base branch (target branch) | |
| base_branch="${{ github.event.pull_request.base.ref }}" | |
| if [[ "$base_branch" == "master" ]]; then | |
| image="ghcr.io/opentensor/subtensor-localnet:main" | |
| else | |
| image="ghcr.io/opentensor/subtensor-localnet:devnet-ready" | |
| fi | |
| else | |
| # For workflow_dispatch, use current branch | |
| if [[ "${GITHUB_REF_NAME}" == "master" ]]; then | |
| image="ghcr.io/opentensor/subtensor-localnet:main" | |
| else | |
| image="ghcr.io/opentensor/subtensor-localnet:devnet-ready" | |
| fi | |
| fi | |
| fi | |
| echo "✅ Final selected image: $image" | |
| echo "image=$image" >> "$GITHUB_OUTPUT" | |
| - 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 ${{ steps.set-image.outputs.image }} | |
| - name: Save Docker Image to Cache | |
| run: docker save -o subtensor-localnet.tar ${{ steps.set-image.outputs.image }} | |
| - name: Upload Docker Image as Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: subtensor-localnet | |
| path: subtensor-localnet.tar | |
| compression-level: 0 | |
| # Job to run tests in parallel | |
| # Since GH Actions matrix has a limit of 256 jobs, we need to split the tests into multiple jobs with different | |
| # Python versions. To reduce DRY we use reusable workflow. | |
| e2e-test: | |
| name: ${{ matrix.label }} | |
| needs: | |
| - find-tests | |
| - pull-docker-image | |
| - read-python-versions | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 64 | |
| matrix: | |
| include: ${{ fromJson(needs.find-tests.outputs.test-files) }} | |
| uses: ./.github/workflows/_run-e2e-single.yaml | |
| with: | |
| nodeid: ${{ matrix.nodeid }} | |
| image-name: ${{ needs.pull-docker-image.outputs.image-name }} | |
| python-versions: ${{ needs.read-python-versions.outputs.python-versions }} | |
| secrets: inherit |