diff --git a/CHANGELOG.md b/CHANGELOG.md index 93dbf5c..e33c7ea 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-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 diff --git a/templates/python/.github/workflows/README.md b/templates/python/.github/workflows/README.md index 834c387..294840b 100644 --- a/templates/python/.github/workflows/README.md +++ b/templates/python/.github/workflows/README.md @@ -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. @@ -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`. diff --git a/templates/python/.github/workflows/lint.yml b/templates/python/.github/workflows/lint.yml index 6ad6007..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.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. @@ -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..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.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. @@ -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: