diff --git a/.circleci/check_pr_status.sh b/.circleci/check_pr_status.sh deleted file mode 100755 index 4b31a29698..0000000000 --- a/.circleci/check_pr_status.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Extract the repository owner -REPO_OWNER=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $(NF-3)}') - -# Extract the repository name -REPO_NAME=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $(NF-2)}') - -# Extract the pull request number -PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $NF}') - - -PR_DETAILS=$(curl -s \ - "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER") - - -IS_DRAFT=$(echo "$PR_DETAILS" | jq -r .draft) -echo $IS_DRAFT - -if [ "$IS_DRAFT" == "true" ]; then - echo "This PR is a draft. Skipping the workflow." - exit 1 -else - echo "This PR is not a draft. Proceeding with the workflow." - exit 0 -fi diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1c14c8730a..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,300 +0,0 @@ -version: 2.1 - -orbs: - python: circleci/python@2.1.1 - python-lib: dialogue/python-lib@0.1.55 - -jobs: - check-if-pr-is-draft: - docker: - - image: cimg/python:3.10 - steps: - - checkout - - run: - name: Install jq - command: sudo apt-get update && sudo apt-get install -y jq - - run: - name: Check if PR is a draft - command: .circleci/check_pr_status.sh - - ruff: - resource_class: small - parameters: - python-version: - type: string - docker: - - image: cimg/python:<< parameters.python-version >> - - steps: - - checkout - - - restore_cache: - name: Restore cached ruff venv - keys: - - v2-pypi-py-ruff-<< parameters.python-version >> - - - run: - name: Update & Activate ruff venv - command: | - python -m venv .venv - . .venv/bin/activate - python -m pip install --upgrade uv - uv pip install ruff==0.11.5 - - - save_cache: - name: Save cached ruff venv - paths: - - ".venv/" - key: v2-pypi-py-ruff-<< parameters.python-version >> - - - run: - name: Ruff format check - command: | - . .venv/bin/activate - ruff format --diff . - - check_compatibility: - parameters: - python_version: - type: string - docker: - - image: cimg/python:3.10 - steps: - - checkout - - run: - name: Check if requirements files have changed - command: ./scripts/check_requirements_changes.sh - - run: - name: Install dependencies and Check compatibility - command: | - if [ "$REQUIREMENTS_CHANGED" == "true" ]; then - python -m pip install ".[dev,cli]" --dry-run --python-version << parameters.python_version >> --no-deps - else - echo "Skipping compatibility checks..." - fi - - build-and-test: - resource_class: medium - parallelism: 2 - parameters: - python-version: - type: string - docker: - - image: cimg/python:<< parameters.python-version >> - - steps: - - checkout - - - run: - name: Update & Activate venv - command: | - python -m venv .venv - . .venv/bin/activate - python -m pip install --upgrade uv - uv sync --extra dev --dev - - - run: - name: Install Bittensor - command: | - . .venv/bin/activate - uv sync --extra dev --dev - - - run: - name: Instantiate Mock Wallet - command: | - . .venv/bin/activate - ./scripts/create_wallet.sh - - - run: - name: Unit Tests - no_output_timeout: 20m - command: | - . .venv/bin/activate - export PYTHONUNBUFFERED=1 - pytest -n2 --reruns 3 --durations=0 --verbose --junitxml=test-results/unit_tests.xml \ - --cov=. --cov-append --cov-config .coveragerc \ - --splits $CIRCLE_NODE_TOTAL --group $((CIRCLE_NODE_INDEX + 1)) \ - --splitting-algorithm duration_based_chunks --store-durations --durations-path .test_durations \ - tests/unit_tests/ - - - run: - name: Integration Tests - no_output_timeout: 30m - command: | - . .venv/bin/activate - export PYTHONUNBUFFERED=1 - pytest -n2 --reruns 3 --reruns-delay 15 --durations=0 --verbose --junitxml=test-results/integration_tests.xml \ - --cov=. --cov-append --cov-config .coveragerc \ - --splits $CIRCLE_NODE_TOTAL --group $((CIRCLE_NODE_INDEX + 1)) \ - --splitting-algorithm duration_based_chunks --store-durations --durations-path .test_durations \ - tests/integration_tests/ - - - store_test_results: - path: test-results - - store_artifacts: - path: test-results - - - #- when: - #condition: - #equal: ["3.10.5", << parameters.python-version >> ] - #steps: - #- run: - #name: Upload Coverage - #command: | - #. .venv/bin/activate && coveralls - #env: - #CI_NAME: circleci - #CI_BUILD_NUMBER: $CIRCLE_BUILD_NUM - #CI_BUILD_URL: $CIRCLE_BUILD_URL - #CI_BRANCH: $CIRCLE_BRANCH - #CI_JOB_ID: $CIRCLE_NODE_INDEX - #COVERALLS_PARALLEL: true - - - lint-and-type-check: - resource_class: medium - parallelism: 2 - parameters: - python-version: - type: string - docker: - - image: cimg/python:<< parameters.python-version >> - - steps: - - checkout - - - run: - name: Update & Activate venv - command: | - python -m venv .venv - . .venv/bin/activate - python -m pip install --upgrade uv - uv sync --extra dev --dev - uv pip install flake8 - - - run: - name: Install Bittensor - command: | - . .venv/bin/activate - uv sync --extra dev --dev - - - run: - name: Lint with flake8 - command: | - . .venv/bin/activate - python -m flake8 bittensor/ --count - - - run: - name: Type check with mypy - command: | - . .venv/bin/activate - python -m mypy --ignore-missing-imports bittensor/ - - unit-tests-all-python-versions: - docker: - - image: cimg/python:3.10 - steps: - - run: - name: Placeholder command - command: echo "Success, only runs if all python versions ran" - - coveralls: - docker: - - image: cimg/python:3.10 - steps: - - run: - name: Combine Coverage - command: | - uv pip install --upgrade coveralls - coveralls --finish --rcfile .coveragerc || echo "Failed to upload coverage" - - check-changelog-updated: - docker: - - image: cimg/python:3.10 - steps: - - checkout - - run: - name: File CHANGELOG.md is updated - command: | - [[ $(git diff-tree --no-commit-id --name-only -r HEAD..master | grep CHANGELOG.md | wc -l) == 1 ]] && echo "CHANGELOG.md has changed" - - check-version-not-released: - docker: - - image: cimg/python:3.10 - steps: - - checkout - - run: - name: Git tag does not exist for the current version - command: | - [[ $(git tag | grep `cat VERSION` | wc -l) == 0 ]] && echo "VERSION is not a tag" - - run: - name: Pypi package 'bittensor' does not exist for the current version - command: | - [[ $(pip index versions bittensor | grep `cat VERSION` | wc -l) == 0 ]] && echo "Pypi package 'bittensor' does not exist" - - run: - name: Docker image 'opentensorfdn/bittensor' does not exist for the current version - command: | - [[ $(docker manifest inspect opentensorfdn/bittensor:`cat VERSION` > /dev/null 2> /dev/null ; echo $?) == 1 ]] && echo "Docker image 'opentensorfdn/bittensor:`cat VERSION`' does not exist in dockerhub" - -workflows: - compatibility_checks: - jobs: - - check_compatibility: - python_version: "3.9" - name: check-compatibility-3.9 - - check_compatibility: - python_version: "3.10" - name: check-compatibility-3.10 - - check_compatibility: - python_version: "3.11" - name: check-compatibility-3.11 - - check_compatibility: - python_version: "3.12" - name: check-compatibility-3.12 - - check_compatibility: - python_version: "3.13" - name: check-compatibility-3.13 - - - pr-requirements: - jobs: - - check-if-pr-is-draft - - ruff: - python-version: "3.9.13" - requires: - - check-if-pr-is-draft - - build-and-test: - matrix: - parameters: - python-version: [ "3.9.13", "3.10.6", "3.11.4", "3.12.7", "3.13.1" ] - requires: - - check-if-pr-is-draft - - unit-tests-all-python-versions: - requires: - - build-and-test - - lint-and-type-check: - matrix: - parameters: - python-version: [ "3.9.13", "3.10.6", "3.11.4", "3.12.7", "3.13.1" ] - requires: - - check-if-pr-is-draft - #- coveralls: - #requires: - #- build-and-test - - release-branches-requirements: - jobs: - - check-changelog-updated: - filters: - branches: - only: - - /^(release|hotfix)/.*/ - - release-requirements: - jobs: - - check-version-not-released: - filters: - branches: - only: - - master diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml deleted file mode 100644 index 3a952f91b8..0000000000 --- a/.github/workflows/auto-assign.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Auto Assign Cortex to Pull Requests - -on: - pull_request: - types: [opened, reopened] - -jobs: - auto-assign: - runs-on: ubuntu-latest - steps: - - name: Auto-assign Cortex Team - uses: kentaro-m/auto-assign-action@v1.2.4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - configuration-path: .github/auto_assign.yml \ No newline at end of file diff --git a/.github/workflows/changelog-checker.yml b/.github/workflows/changelog-checker.yml new file mode 100644 index 0000000000..7407e21607 --- /dev/null +++ b/.github/workflows/changelog-checker.yml @@ -0,0 +1,25 @@ +name: Changelog guard (for release of hotfix) + +permissions: + contents: read + +on: + pull_request: + branches: + - 'release/**' + - 'Release/**' + - 'hotfix/**' + - 'Hotfix/**' + +jobs: + changelog: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: tj-actions/changed-files@v42 + id: changed + - name: Ensure CHANGELOG.md updated + if: contains(steps.changed.outputs.all_changed_files, 'CHANGELOG.md') == false + uses: actions/github-script@v7 + with: + script: core.setFailed('CHANGELOG.md must be updated.') diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml new file mode 100644 index 0000000000..2ef9a1b95f --- /dev/null +++ b/.github/workflows/compatibility.yml @@ -0,0 +1,27 @@ +name: Requirements compatibility for supported Python versions +permissions: + contents: read + +on: + pull_request: + paths: + - "pyproject.toml" + +jobs: + compatibility: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - run: | + python -m pip install --upgrade pip + python -m pip install ".[dev,cli]" --dry-run --no-deps diff --git a/.github/workflows/flake8-and-mypy.yml b/.github/workflows/flake8-and-mypy.yml new file mode 100644 index 0000000000..1fbe094728 --- /dev/null +++ b/.github/workflows/flake8-and-mypy.yml @@ -0,0 +1,56 @@ +name: Flake8 and Mypy - linters check +permissions: + contents: read + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + linters: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache venv + id: cache + uses: actions/cache@v4 + with: + path: venv + key: | + v3-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} + restore-keys: | + v3-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}- + + - name: Install deps (flake8 + mypy + project.dev) + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: | + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install uv + python -m uv sync --extra dev --active + + - name: Flake8 + run: | + source venv/bin/activate + python -m flake8 bittensor/ --count + + - name: mypy + run: | + source venv/bin/activate + python -m mypy --ignore-missing-imports bittensor/ diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000000..7dfaf2eda5 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,33 @@ +name: Ruff - formatter check +permissions: + contents: read + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + ruff: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Ruff in virtual environment + run: | + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install ruff==0.11.5 + + - name: Ruff format check + run: | + source venv/bin/activate + python -m ruff format --diff bittensor diff --git a/.github/workflows/unit-and-integration-tests.yml b/.github/workflows/unit-and-integration-tests.yml new file mode 100644 index 0000000000..7bc70ae030 --- /dev/null +++ b/.github/workflows/unit-and-integration-tests.yml @@ -0,0 +1,59 @@ +name: Unit and integration tests checker +permissions: + contents: read + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + unit-and-integration-tests: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Cache venv + id: cache + uses: actions/cache@v4 + with: + path: venv + key: v2-${{ runner.os }}-${{ hashFiles('pyproject.toml') }} + + - name: Install deps + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: | + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install uv + python -m uv sync --extra dev --active + + - name: Unit tests + timeout-minutes: 20 + env: + PYTHONUNBUFFERED: "1" + run: | + source venv/bin/activate + python -m uv run pytest -n 2 tests/unit_tests/ --reruns 3 + + - name: Integration tests + timeout-minutes: 20 + env: + PYTHONUNBUFFERED: "1" + run: | + source venv/bin/activate + python -m uv run pytest -n 2 tests/integration_tests/ --reruns 3