Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ jobs:
run: |
cp .env.example .env
make test-unit
- name: "Save the result of fast test suite"
run: |
echo "Nothing to save"
- name: "Upload coverage report to artifacts"
uses: actions/upload-artifact@v4
with:
name: coverage.xml
path: coverage.xml

test-lint:
name: "Linting"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,6 +91,10 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history is needed to improving relevancy of reporting
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage.xml
- name: "Perform static analysis"
uses: ./.github/actions/perform-static-analysis
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ lung_cancer_screening/assets/compiled/*
.devcontainer/ca.crt
tests/TEST-*.xml
node_modules
.coverage
coverage.xml
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
dockerfile: Dockerfile
target: development
command: python manage.py runserver 0.0.0.0:8000
user: "${UID}:${GID}"
ports:
- "8000:8000"
env_file:
Expand Down
289 changes: 188 additions & 101 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ playwright = "^1.57.0"
axe-playwright-python = "^0.1.7"
behave-django = "^1.8.0"
factory-boy = "^3.3.3"
coverage = "^7.12.0"

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.behave]
paths = ["tests/features"]

[tool.coverage.run]
omit = [
"*/migrations/*",
"*/tests/*",
"manage.py"
]
data_file = ".coverage"

[tool.coverage.xml]
output = "coverage.xml"
2 changes: 1 addition & 1 deletion scripts/config/sonar-scanner.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ sonar.qualitygate.wait=true
sonar.sourceEncoding=UTF-8
sonar.sources=.

#sonar.python.coverage.reportPaths=.coverage/coverage.xml
sonar.python.coverage.reportPaths=coverage.xml
#sonar.[javascript|typescript].lcov.reportPaths=.coverage/lcov.info
7 changes: 5 additions & 2 deletions scripts/reports/perform-static-analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ function run-sonar-scanner-in-docker() {
# shellcheck disable=SC1091
source ./scripts/docker/docker.lib.sh

ls -lah
# shellcheck disable=SC2155
local image=$(name=sonarsource/sonar-scanner-cli docker-get-image-version-and-pull)
docker run --rm --platform linux/amd64 \
--volume "$PWD":/usr/src \
--volume "$PWD":/app \
--workdir /app \
"$image" \
-Dproject.settings=/usr/src/scripts/config/sonar-scanner.properties \
-Dproject.settings=/app/scripts/config/sonar-scanner.properties \
-Dsonar.sources=/app \
-Dsonar.branch.name="${BRANCH_NAME:-$(git rev-parse --abbrev-ref HEAD)}" \
-Dsonar.organization="$SONAR_ORGANISATION_KEY" \
-Dsonar.projectKey="$SONAR_PROJECT_KEY" \
Expand Down
9 changes: 8 additions & 1 deletion scripts/tests/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@ else
TEST_MODULE=""
fi

docker compose run --rm --remove-orphans web poetry run python manage.py test $TEST_MODULE $TAG --settings=lung_cancer_screening.settings_test --exclude-tag=accessibility
UID=$(id -u) GID=$(id -u) docker compose run --rm --remove-orphans web sh -c \
"echo 'Running unit tests...' && \
poetry run coverage run manage.py test $TEST_MODULE $TAG \
--settings=lung_cancer_screening.settings_test \
--exclude-tag=accessibility && \
echo 'Generating coverage report...' && \
coverage xml && \
coverage report -m --skip-covered"