diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index f96def6..abed9ff 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -24,16 +24,153 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master + ruff: + runs-on: ubuntu-latest + name: Ruff check and force + steps: + - name: Check out committed code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install ruff -r requirements.txt -r requirements-test.txt + - name: Ruff (with fix) + run: | + . venv/bin/activate + ruff check airos/ tests/ + - name: If needed, commit ruff changes to the pull request + if: failure() + run: | + . venv/bin/activate + ruff format airos/ tests/ + git config --global user.name 'autoruff' + git config --global user.email 'airos@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.PAT_CT }}@github.com/$GITHUB_REPOSITORY + git checkout $GITHUB_HEAD_REF + git commit -am "fixup: ${GITHUB_REF##*/} Python code fixed using ruff" + git push origin ${GITHUB_REF##*/} + + commitcheck: + runs-on: ubuntu-latest + name: Check commit + needs: + - ruff + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install pre-commit -r requirements.txt -r requirements-test.txt + pre-commit install + pre-commit install-hooks + - name: Full pre-commit + run: | + . venv/bin/activate + pre-commit run --show-diff-on-failure --color=always --all-files + + pytest: + runs-on: ubuntu-latest + name: Run pytest using Python ${{ matrix.python-version }} + needs: + - ruff + - commitcheck + strategy: + matrix: + python-version: ["3.13"] + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install -r requirements.txt -r requirements-test.txt + - name: Run all tests + run: | + . venv/bin/activate + pytest --log-level info tests/*.py --cov='.' + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.python-version }} + path: .coverage + if-no-files-found: error + include-hidden-files: true + + mypy: + if: false # disables the job --> "Code is not up to par for mypy, skipping" + runs-on: ubuntu-latest + name: Run mypy + needs: + - ruff + - pytest + steps: + - name: Check out committed code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install -r requirements.txt -r requirements-test.txt + - name: Run mypy + run: | + . venv/bin/activate + pip list | grep -i mypy + mypy airos/ + + coverage: + name: Process test coverage + runs-on: ubuntu-latest + needs: + - ruff + - pytest + # - mypy + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install -r requirements.txt -r requirements-test.txt + - name: Download all coverage artifacts + uses: actions/download-artifact@v4 + - name: Combine coverage results + run: | + . venv/bin/activate + coverage combine coverage*/.coverage* + coverage report --fail-under=85 + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + test-publishing: name: Build and publish Python 🐍 distributions 📦 to TestPyPI runs-on: ubuntu-latest environment: testpypi permissions: id-token: write + needs: + - coverage + # - mypy steps: - name: Check out committed code uses: actions/checkout@v4 - - name: Prepare uv + - name: Prepare python run: | pip install uv uv venv --seed venv @@ -68,3 +205,24 @@ jobs: run: | . venv/bin/activate uv publish --publish-url https://test.pypi.org/legacy/ + + + complexity: + name: Process test complexity + runs-on: ubuntu-latest + needs: + - coverage + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Prepare python + run: | + pip install uv + uv venv --seed venv + . venv/bin/activate + uv pip install -r requirements.txt -r requirements-test.txt + - name: Run complexity report (click to view details) + run: | + . venv/bin/activate + echo "Showing complexity higher or equal to 'C'" + radon cc airos/ tests/ -s -nc --no-assert diff --git a/requirements-test.txt b/requirements-test.txt index e4eb679..ce7ffb7 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,9 @@ -pytest -pytest-asyncio -aiohttp +ruff==0.12.3 +pytest==8.4.1 +pytest-asyncio==1.0.0 +pytest-cov==6.2.1 +coverage==7.9.2 aioresponses +aioresponses==0.7.8 +aiofiles==24.1.0 +radon==6.0.1 diff --git a/requirements.txt b/requirements.txt index 71e5399..bb41ec2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -asyncio -aiohttp +aiohttp==3.12.14 +asyncio==3.4.3