From 674f440c47eb24d58cdbc2625740fd2d41dc85e8 Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Sat, 20 Jan 2024 01:03:52 +0100 Subject: [PATCH] test coverage and other test requirements --- .github/workflows/ci.yml | 11 ++++++++--- .gitignore | 13 ++++++++----- Dockerfile-test | 5 +++-- README.org => README.md | 0 docker-compose.yml | 6 +++++- pyproject.toml | 24 ++++++++++++------------ requirements-test.txt | 4 ++++ 7 files changed, 40 insertions(+), 23 deletions(-) rename README.org => README.md (100%) create mode 100644 requirements-test.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef455d8c..a4e300bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index ef6172a3..96f52764 100644 --- a/.gitignore +++ b/.gitignore @@ -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__/ \ No newline at end of file +.idea +.coverage diff --git a/Dockerfile-test b/Dockerfile-test index b8a5039c..b99ff064 100644 --- a/Dockerfile-test +++ b/Dockerfile-test @@ -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 \ No newline at end of file diff --git a/README.org b/README.md similarity index 100% rename from README.org rename to README.md diff --git a/docker-compose.yml b/docker-compose.yml index 5532b82e..5fd1fa30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 6c3f5c65..bf8fffaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -27,13 +26,9 @@ exclude = [ "**/qgissettingmanager", "**/test", ] - reportMissingImports = false useLibraryCodeForTypes = true -[tool.setuptools] -package-dir = { "" = "comptages" } - [tool.isort] profile = "black" src_paths = ["comptages"] @@ -46,3 +41,8 @@ extend-exclude = ''' | qgissettingmanager )/ ''' + +[tool.qgis-plugin-ci] +plugin_path = "comptages" +github_organization_slug = "opengisch" +project_slug = "OpenComptage" diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..522129af --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,4 @@ +pyright>=1.1.36 +black>=23.11.0 +qgis-plugin-ci>=2.8.1 +coverage>=7.4.0 \ No newline at end of file