Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-154](https://github.com/itk-dev/devops_itkdev-docker/pull/154) - 2026-10-05 -
Pass `github.base_ref` to the changelog workflow through `env` instead of
interpolating it into the shell command
Expand Down
20 changes: 18 additions & 2 deletions templates/python/.github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,25 @@ 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`).

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.

Expand All @@ -49,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`.
6 changes: 3 additions & 3 deletions templates/python/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 labeled dk.itkdev.language=python.
# The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"])
# overrides this.

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions templates/python/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 labeled dk.itkdev.language=python.
# The repository variable PYTHON_SERVICES (JSON list, e.g. ["api", "worker"])
# overrides this.

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/python/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading