Skip to content

Commit

Permalink
test coverage and other test requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Jan 20, 2024
1 parent f6491ab commit 674f440
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
run: |
pip install build
python -m build .
pip install ./dist/comptages-0.1-py3-none-any.whl[check]
# - name: Package
# run: qgis-plugin-ci package 'test'
pip install ./dist/comptages-0.1-py3-none-any.whl[test]
- name: Package
run: qgis-plugin-ci --no-validation package 'test'
- name: Lint
run: black . --check

Expand All @@ -40,3 +40,8 @@ jobs:
run: docker compose up db -d
- name: Running tests
run: docker compose run qgis_tester
- name: Upload test coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_report.txt
path: testoutputs/coverage_report.txt
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.idea
**/__pycache__/
**/coverage_report.txt
*.nix
*.log
.venv/
.vscode/
.docker/tests/
.docker/tests/screenshot.png
.env
.vscode/settings.json
*.nix
*.log
**/__pycache__/
.idea
.coverage
5 changes: 3 additions & 2 deletions Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM opengisch/qgis:3.28.0-jammy
RUN apt update && apt install iputils-ping glibc-tools libpq-dev python3-pip -y
COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY requirements.txt requirements-test.txt .
RUN pip3 install -r requirements.txt && \
pip3 install -r requirements-test.txt
WORKDIR /OpenComptage
File renamed without changes.
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ services:
dockerfile: ./Dockerfile-test
environment:
LOCAL_TEST: 1
command: sh -c 'xvfb-run python3 manage.py migrate && python3 manage.py test comptages.test -v2'
command: |
sh -c 'xvfb-run \
python3 manage.py migrate && \
coverage run --source='.' manage.py test comptages.test -v2 && \
coverage report > /OpenComptage/testoutputs/coverage_report.txt'
volumes:
- ${PWD}:/OpenComptage
- ${PWD}/testoutputs:/OpenComptage/testoutputs
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = { "" = "comptages" }

[project]
name = "comptages"
version = "0.1"
dynamic = ["dependencies"]

[project.optional-dependencies]
check = ["pyright>=1.1.36", "black>=23.11.0", "qgis-plugin-ci>=2.8.1"]
dynamic = ["dependencies", "optional-dependencies"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
optional-dependencies.test = { file = "requirements-test.txt" }

[tool.qgis-plugin-ci]
plugin_path = "comptages"
github_organization_slug = "opengisch"
project_slug = "OpenComptage"
[tool.coverage.run]
omit = ["*/migrations/*", "*/qgissettingmanager/*"]

[tool.pyright]
pythonVersion = "3.10"
Expand All @@ -27,13 +26,9 @@ exclude = [
"**/qgissettingmanager",
"**/test",
]

reportMissingImports = false
useLibraryCodeForTypes = true

[tool.setuptools]
package-dir = { "" = "comptages" }

[tool.isort]
profile = "black"
src_paths = ["comptages"]
Expand All @@ -46,3 +41,8 @@ extend-exclude = '''
| qgissettingmanager
)/
'''

[tool.qgis-plugin-ci]
plugin_path = "comptages"
github_organization_slug = "opengisch"
project_slug = "OpenComptage"
4 changes: 4 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyright>=1.1.36
black>=23.11.0
qgis-plugin-ci>=2.8.1
coverage>=7.4.0

0 comments on commit 674f440

Please sign in to comment.