From 314707a9f1b99f9ab91df3eedfc702905c265660 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Mon, 5 Oct 2026 13:47:43 +0200 Subject: [PATCH 1/3] feat: select Python services by dk.itkdev.language=python --- CHANGELOG.md | 3 +++ templates/python/.github/workflows/README.md | 5 ++++- templates/python/.github/workflows/lint.yml | 6 +++--- templates/python/.github/workflows/tests.yml | 6 +++--- templates/python/docker-compose.yml | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f0794f..a094554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ Changelog", this file is a reverse-chronological list of merged pull requests. ## Open PR's +- [PR-155](https://github.com/itk-dev/devops_itkdev-docker/pull/155) - 2026-10-05 - + Python template: select the services to lint and test by the label + `dk.itkdev.language: python` instead of `dk.itkdev.python: "true"` - [PR-153](https://github.com/itk-dev/devops_itkdev-docker/pull/153) - 2026-09-29 - Added basic template for python base projects - [PR-152](https://github.com/itk-dev/devops_itkdev-docker/pull/152) - 2026-09-15 - diff --git a/templates/python/.github/workflows/README.md b/templates/python/.github/workflows/README.md index 834c387..1e4399a 100644 --- a/templates/python/.github/workflows/README.md +++ b/templates/python/.github/workflows/README.md @@ -21,9 +21,12 @@ reading `docker-compose.yml` (`docker compose config`) and picking every service services: api: labels: - dk.itkdev.python: "true" + dk.itkdev.language: python ``` +The label names the language whose checks run in the service, not how the service runs (e.g. `uvicorn` or a CLI), +so templates for other languages can select their services the same way (`dk.itkdev.language: php`). + Every job runs once per service, and each service shows up as its own check, e.g. `Tests (api)`. If no service has the label, the workflows fail. diff --git a/templates/python/.github/workflows/lint.yml b/templates/python/.github/workflows/lint.yml index 6ad6007..fd7c354 100644 --- a/templates/python/.github/workflows/lint.yml +++ b/templates/python/.github/workflows/lint.yml @@ -1,6 +1,6 @@ name: Python linting -# Checks run in every docker compose service labelled dk.itkdev.python=true. +# Checks run in every docker compose service labelled dk.itkdev.language=python. # The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"]) # overrides this. @@ -34,8 +34,8 @@ jobs: - id: find run: | list=$(docker compose config --format json \ - | jq -c '[.services | to_entries[] | select(.value.labels["dk.itkdev.python"] == "true") | .key]') - [ "$list" != "[]" ] || { echo "::error::No service has the label dk.itkdev.python=true"; exit 1; } + | jq -c '[.services | to_entries[] | select(.value.labels["dk.itkdev.language"] == "python") | .key]') + [ "$list" != "[]" ] || { echo "::error::No service has the label dk.itkdev.language=python"; exit 1; } echo "list=$list" >> "$GITHUB_OUTPUT" lint: diff --git a/templates/python/.github/workflows/tests.yml b/templates/python/.github/workflows/tests.yml index 781392d..0998eee 100644 --- a/templates/python/.github/workflows/tests.yml +++ b/templates/python/.github/workflows/tests.yml @@ -1,6 +1,6 @@ name: Python tests -# Checks run in every docker compose service labelled dk.itkdev.python=true. +# Checks run in every docker compose service labelled dk.itkdev.language=python. # The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"]) # overrides this. @@ -34,8 +34,8 @@ jobs: - id: find run: | list=$(docker compose config --format json \ - | jq -c '[.services | to_entries[] | select(.value.labels["dk.itkdev.python"] == "true") | .key]') - [ "$list" != "[]" ] || { echo "::error::No service has the label dk.itkdev.python=true"; exit 1; } + | jq -c '[.services | to_entries[] | select(.value.labels["dk.itkdev.language"] == "python") | .key]') + [ "$list" != "[]" ] || { echo "::error::No service has the label dk.itkdev.language=python"; exit 1; } echo "list=$list" >> "$GITHUB_OUTPUT" lock: diff --git a/templates/python/docker-compose.yml b/templates/python/docker-compose.yml index d655540..25f40ce 100644 --- a/templates/python/docker-compose.yml +++ b/templates/python/docker-compose.yml @@ -12,7 +12,7 @@ services: target: ${ENV:-dev} labels: # Picked up by the lint and tests workflows. - dk.itkdev.python: "true" + dk.itkdev.language: python ports: - "8000" healthcheck: From 6267967e3617dbe081768fed49e7ea4d7a907d6c Mon Sep 17 00:00:00 2001 From: turegjorup Date: Mon, 5 Oct 2026 13:56:02 +0200 Subject: [PATCH 2/3] docs: suggest dk.itkdev.runtime for how a service runs --- templates/python/.github/workflows/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/templates/python/.github/workflows/README.md b/templates/python/.github/workflows/README.md index 1e4399a..b2293bf 100644 --- a/templates/python/.github/workflows/README.md +++ b/templates/python/.github/workflows/README.md @@ -27,6 +27,19 @@ services: The label names the language whose checks run in the service, not how the service runs (e.g. `uvicorn` or a CLI), so templates for other languages can select their services the same way (`dk.itkdev.language: php`). +How the service runs could later get a label of its own, `dk.itkdev.runtime`, once a template or tool needs to tell +runtimes apart, e.g. `php-fpm` and `frankenphp` for PHP, or `uvicorn` and `cli` for Python: + +```yaml +services: + app: + labels: + dk.itkdev.language: php + dk.itkdev.runtime: frankenphp +``` + +Nothing reads `dk.itkdev.runtime` yet. + Every job runs once per service, and each service shows up as its own check, e.g. `Tests (api)`. If no service has the label, the workflows fail. From 4ca554709d914a94020e663cd519b4f497b351db Mon Sep 17 00:00:00 2001 From: turegjorup Date: Mon, 5 Oct 2026 14:02:17 +0200 Subject: [PATCH 3/3] docs: spell labeled consistently --- templates/python/.github/workflows/README.md | 2 +- templates/python/.github/workflows/lint.yml | 2 +- templates/python/.github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/python/.github/workflows/README.md b/templates/python/.github/workflows/README.md index b2293bf..294840b 100644 --- a/templates/python/.github/workflows/README.md +++ b/templates/python/.github/workflows/README.md @@ -65,7 +65,7 @@ The value must be valid JSON (double quotes). The variable lives in GitHub, not 1. `.env.example` exists and contains every variable `docker-compose.yml` requires. The workflows copy it to `.env`. 2. `docker-compose.yml` uses `APP_UID`/`APP_GID` for the container user and an external network named `frontend`; both are set up by the workflows. -3. Each Python service (labelled, or listed in `PYTHON_SERVICES`) can run with `--no-deps` and has `uv`, `pytest` with +3. Each Python service (labeled, or listed in `PYTHON_SERVICES`) can run with `--no-deps` and has `uv`, `pytest` with [pytest-cov](https://pytest-cov.readthedocs.io/), `ruff` and `basedpyright` available. 4. Coverage is configured in `pyproject.toml` (`[tool.coverage.run] source = [...]`), since the workflow runs plain `pytest --cov`. diff --git a/templates/python/.github/workflows/lint.yml b/templates/python/.github/workflows/lint.yml index fd7c354..b710ade 100644 --- a/templates/python/.github/workflows/lint.yml +++ b/templates/python/.github/workflows/lint.yml @@ -1,6 +1,6 @@ name: Python linting -# Checks run in every docker compose service labelled dk.itkdev.language=python. +# Checks run in every docker compose service labeled dk.itkdev.language=python. # The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"]) # overrides this. diff --git a/templates/python/.github/workflows/tests.yml b/templates/python/.github/workflows/tests.yml index 0998eee..93a8de2 100644 --- a/templates/python/.github/workflows/tests.yml +++ b/templates/python/.github/workflows/tests.yml @@ -1,6 +1,6 @@ name: Python tests -# Checks run in every docker compose service labelled dk.itkdev.language=python. +# Checks run in every docker compose service labeled dk.itkdev.language=python. # The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"]) # overrides this.