diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2827333d..9bb29932 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,13 +69,17 @@ jobs: - name: Run mypy run: poetry run --no-interaction -- mypy --strict --python-version ${{ matrix.python-version }} . - tox: + pytest: if: github.event.pull_request.draft == false runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"] + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + COVERAGE_FILE: .coverage.${{ matrix.os }}-${{ matrix.python-version }} steps: - uses: actions/checkout@v4 @@ -85,69 +89,27 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - - name: Test with tox - run: tox - env: - PLATFORM: ${{ matrix.os }} - - - name: Upload coverage - uses: actions/upload-artifact@v4 + - name: Set up Poetry + uses: abatilo/actions-poetry@v3 with: - name: covdata-${{ matrix.os }}-${{ matrix.python-version }} - path: .coverage.* + poetry-version: ${{ env.POETRY_VERSION }} - combine-coverage-reports: - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - permissions: - contents: write - needs: tox - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Download coverage reports from all jobs - uses: actions/download-artifact@v4 + - name: Install dependencies + run: poetry install --no-interaction - - name: Flatten directory structure - run: | - shopt -s dotglob - for dir in ./covdata-*; do - if [ -d "$dir" ]; then - mv "$dir"/* ./ - rm -rf "$dir" - fi - done - shopt -u dotglob + - name: Run pytest + run: poetry run --no-interaction -- coverage run -m pytest ./tests --import-mode importlib - - name: Combine coverage reports + - name: Generate coverage report run: | - python -m pip install --upgrade pip - python -m pip install coverage genbadge[coverage] - coverage combine - coverage report -m - coverage xml -o coverage/coverage.xml - coverage html -d coverage/html - genbadge coverage -i coverage/coverage.xml -o coverage/badge.svg - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + poetry run --no-interaction -- coverage report -m + poetry run --no-interaction -- coverage xml -o ./coverage/coverage.xml - - name: Commit and push - if: github.event_name == 'pull_request' - uses: EndBug/add-and-commit@v9 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: - default_author: github_actions - message: "Update tox report" - push: "origin HEAD:${{ github.head_ref }} --force" + directory: ./coverage/ + file: coverage.xml + env_vars: OS,PYTHON + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 00e14c1c..00000000 --- a/tox.ini +++ /dev/null @@ -1,52 +0,0 @@ -[tox] -isolated_build = true -minversion = 4.6.4 -env_list =py{38,39,310,311,312}-{linux,darwin,win32},coverage - -[gh-actions] -python = - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 -[gh-actions:env] -PLATFORM = - ubuntu-latest: linux - macos-latest: darwin - windows-latest: win32 - -[testenv] -description = run the tests with pytest -deps = - pytest>=6 - coverage - tomli-w -commands = - coverage run --data-file .coverage.{envname} -m pytest tests/ --import-mode importlib - -[testenv:coverage] -basepython = - python3 -deps = - coverage - genbadge[coverage] -commands = - coverage combine - coverage report -m - coverage xml -o coverage/coverage.xml - coverage html --directory coverage/html - genbadge coverage -i coverage/coverage.xml -o coverage/badge.svg - -[coverage:run] -parallel = true -relative_files = true -source = - capsula - -[coverage:report] -exclude_lines = - pragma: no cover - raise NotImplementedError - if __name__ == .__main__.: - if TYPE_CHECKING: