Split CI into parallel unit, integration, and coverage report jobs #28
+39
-12
@@ -27,7 +27,18 @@ jobs:
|
||||
run: uv sync --all-extras
|
||||
|
||||
- name: Run unit tests
|
||||
run: uv run pytest tests/unit/ -m "not integration" -v
|
||||
run: |
|
||||
uv run pytest tests/unit/ -m "not integration" \
|
||||
--cov=python_repositories \
|
||||
--cov-report=
|
||||
|
||||
- name: Upload unit coverage
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: coverage-unit
|
||||
path: .coverage
|
||||
retention-days: 1
|
||||
compression-level: 0
|
||||
|
||||
integration-tests:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -52,7 +63,18 @@ jobs:
|
||||
run: docker info
|
||||
|
||||
- name: Run integration tests
|
||||
run: uv run pytest -m integration -v
|
||||
run: |
|
||||
uv run pytest -m integration \
|
||||
--cov=python_repositories \
|
||||
--cov-report=
|
||||
|
||||
- name: Upload integration coverage
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: coverage-integration
|
||||
path: .coverage
|
||||
retention-days: 1
|
||||
compression-level: 0
|
||||
|
||||
coverage-report:
|
||||
needs: [unit-tests, integration-tests]
|
||||
@@ -75,17 +97,22 @@ jobs:
|
||||
UV_LINK_MODE: copy
|
||||
run: uv sync --all-extras
|
||||
|
||||
# Gitea Actions lacks cross-job artifact download APIs; re-run tests here
|
||||
# with --cov-append on one runner for an accurate combined report.
|
||||
- name: Run tests with combined coverage
|
||||
- name: Download unit coverage
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: coverage-unit
|
||||
path: coverage-unit
|
||||
|
||||
- name: Download integration coverage
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: coverage-integration
|
||||
path: coverage-integration
|
||||
|
||||
- name: Combine coverage report
|
||||
run: |
|
||||
uv run pytest tests/unit/ -m "not integration" \
|
||||
--cov=python_repositories \
|
||||
--cov-report=
|
||||
uv run pytest -m integration \
|
||||
--cov=python_repositories \
|
||||
--cov-append \
|
||||
--cov-report=term-missing > coverage.txt
|
||||
uv run coverage combine coverage-unit/.coverage coverage-integration/.coverage
|
||||
uv run coverage report -m --include='python_repositories/*' > coverage.txt
|
||||
cat coverage.txt
|
||||
|
||||
- name: Post coverage summary to PR
|
||||
|
||||
@@ -148,7 +148,7 @@ uv run pytest -v # full suite (requires Doc
|
||||
|
||||
Integration tests are marked with `@pytest.mark.integration` and require Docker (testcontainers). Run unit tests alone for quick local feedback.
|
||||
|
||||
CI runs unit and integration tests in parallel for fast feedback; a follow-up job re-runs both suites with `--cov-append` to produce a combined coverage report (Gitea Actions does not support cross-job artifact download yet).
|
||||
CI runs unit and integration tests in parallel with coverage, then merges `.coverage` artifacts in a follow-up job (via [christopherhx/gitea-\*-artifact@v4](https://github.com/christopherHX/gitea-upload-artifact) for Gitea 1.26 compatibility).
|
||||
|
||||
`pre-commit` is included in the dev dependency group. `uv sync` installs the CLI, but git does not run hooks until you install them with `pre-commit install` (one time per clone). After that, commits run the checks defined in [`.pre-commit-config.yaml`](.pre-commit-config.yaml) (ruff, mypy, pyupgrade, prettier, and general file hygiene).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user