2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-08 16:28:49 +00:00

feat(backend): record contexts for coverage (#9643)

* feat(backend): Record contexts for coverage

* add docs
This commit is contained in:
Matthias Mair 2025-05-07 22:28:06 +02:00 committed by GitHub
parent 34db1a2a49
commit 0b228761b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

@ -342,6 +342,12 @@ jobs:
run: python3 .github/scripts/check_migration_files.py
- name: Coverage Tests
run: invoke dev.test --coverage --translations
- name: Upload raw coverage to artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # pin@v4.6.2
with:
name: coverage
path: .coverage
retention-days: 14
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # pin@v5.4.2
if: always()

View File

@ -199,6 +199,15 @@ alter user myuser createdb;
!!! info "Devcontainer"
The default database container which is provided in the devcontainer is already setup with the required permissions
### Trace coverage to specific tests
Sometimes it is valuable to get insights how many tests cover a specific statement and which ones do. coverage.py calls this information contexts. Contexts are automatically captured by the invoke task test (with coverage enabled) and can be rendered with below command into a HTML report.
```bash
coverage html -i
```
The coverage database is also generated in the CI-pipeline and exposd for 14 days as a artifact named `coverage`.
## Code Style
Code style is automatically checked as part of the project's CI pipeline on GitHub. This means that any pull requests which do not conform to the style guidelines will fail CI checks.

View File

@ -102,6 +102,10 @@ generate-hashes=true
[tool.coverage.run]
source = ["src/backend/InvenTree", "InvenTree"]
dynamic_context = "test_function"
[tool.coverage.html]
show_contexts = true
[tool.djlint]
ignore = "D018,H006,H008,H020,H021,H023,H025,H030,H031,T002"