diff --git a/CHANGELOG.md b/CHANGELOG.md index 0733eb3f..29c8b2bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Changelog", this file is a reverse-chronological list of merged pull requests. ## Open PR's +- [PR-160](https://github.com/itk-dev/devops_itkdev-docker/pull/160) - 2026-10-28 - + Drupal site workflow checks that config exports unchanged, that update + hooks leave no unexported config, and (with `drupal/config_inspector`) + that config matches its schema - [PR-159](https://github.com/itk-dev/devops_itkdev-docker/pull/159) - 2026-10-26 - Switched the Drupal and Symfony templates to `nginx/nginx-unprivileged`, as `nginxinc/nginx-unprivileged` is no longer maintained diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index c462c63a..fd0f94fc 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -182,6 +182,21 @@ pull request). services. 3. The Drupal site can be installed from existing config. +#### Config checks + +1. Config is up to date: exporting config from a site installed from config + must not change anything in `config/`. +2. Config changed by update hooks is exported: after running database + updates (on pull request), the active config may only differ from the + config in code where the pull request itself changes config. +3. Config matches its schema (only if + [drupal/config_inspector](https://www.drupal.org/project/config_inspector) + is a dev requirement in `composer.json`): + + ``` shell + docker compose run --rm phpfpm composer require --dev drupal/config_inspector + ``` + --- [github/workflows/drupal/styles.yaml](github/workflows/drupal/styles.yaml) diff --git a/github/workflows/drupal/site.yaml b/github/workflows/drupal/site.yaml index c9447fc4..8ea415a1 100644 --- a/github/workflows/drupal/site.yaml +++ b/github/workflows/drupal/site.yaml @@ -15,6 +15,21 @@ ### services and the default settings match connection credentials for these ### services. ### 3. The Drupal site can be installed from existing config. +### +### #### Config checks +### +### 1. Config is up to date: exporting config from a site installed from config +### must not change anything in `config/`. +### 2. Config changed by update hooks is exported: after running database +### updates (on pull request), the active config may only differ from the +### config in code where the pull request itself changes config. +### 3. Config matches its schema (only if +### [drupal/config_inspector](https://www.drupal.org/project/config_inspector) +### is a dev requirement in `composer.json`): +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev drupal/config_inspector +### ``` name: Drupal @@ -54,11 +69,32 @@ jobs: /dev/null 2>&1; then + echo "::notice::drupal/config_inspector is not installed; skipping config schema check" + exit 0 + fi + docker compose exec phpfpm vendor/bin/drush pm:install config_inspector --yes + docker compose exec phpfpm vendor/bin/drush config:inspect --only-error --detail + - name: Show site URL run: | echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login) @@ -115,6 +151,8 @@ jobs: changed-by-pr.txt + docker compose exec -T phpfpm vendor/bin/drush config:status --format=json \ + | jq -r 'if type == "object" then keys[] else empty end' \ + | sed -E 's#^.*:##' | sort -u > changed-in-db.txt + comm -23 changed-in-db.txt changed-by-pr.txt > not-exported.txt + if [ -s not-exported.txt ]; then + echo "::error::Active config differs from config/sync (not changed by this pull request), e.g. config changed by update hooks that has not been exported:" + cat not-exported.txt + exit 1 + fi + - name: Update site run: | docker compose exec phpfpm vendor/bin/drush deploy --yes