From 8b55c911ea2b1795a18c1e4868483867248554ab Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 18 Mar 2025 11:30:31 +0100 Subject: [PATCH 01/34] Added GitHub Actions templates and tool configuration files --- .github/workflows/documentation.yaml | 26 ++++ .gitignore | 1 + README.md | 13 +- Taskfile.yml | 58 +++++++++ config/markdownlint-cli/.markdownlint.jsonc | 19 +++ config/markdownlint-cli/.markdownlintignore | 8 ++ docs/github-action-templates.md | 68 ++++++++++ github/workflows/changelog.yaml | 29 +++++ github/workflows/composer.yaml | 51 ++++++++ github/workflows/drupal.yaml | 116 ++++++++++++++++++ github/workflows/markdown.yaml | 25 ++++ scripts/itkdev-docker-compose | 4 +- .../.github/workflows/changelog.yaml | 1 + .../drupal-10/.github/workflows/composer.yaml | 1 + .../drupal-10/.github/workflows/drupal.yaml | 1 + .../drupal-10/.github/workflows/markdown.yaml | 1 + templates/drupal-10/.markdownlint.jsonc | 1 + templates/drupal-10/.markdownlintignore | 1 + .../.github/workflows/changelog.yaml | 1 + .../symfony-6/.github/workflows/composer.yaml | 1 + .../symfony-6/.github/workflows/markdown.yaml | 1 + 21 files changed, 422 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/documentation.yaml create mode 100644 .gitignore create mode 100644 Taskfile.yml create mode 100644 config/markdownlint-cli/.markdownlint.jsonc create mode 100644 config/markdownlint-cli/.markdownlintignore create mode 100644 docs/github-action-templates.md create mode 100644 github/workflows/changelog.yaml create mode 100644 github/workflows/composer.yaml create mode 100644 github/workflows/drupal.yaml create mode 100644 github/workflows/markdown.yaml create mode 120000 templates/drupal-10/.github/workflows/changelog.yaml create mode 120000 templates/drupal-10/.github/workflows/composer.yaml create mode 120000 templates/drupal-10/.github/workflows/drupal.yaml create mode 120000 templates/drupal-10/.github/workflows/markdown.yaml create mode 120000 templates/drupal-10/.markdownlint.jsonc create mode 120000 templates/drupal-10/.markdownlintignore create mode 120000 templates/symfony-6/.github/workflows/changelog.yaml create mode 120000 templates/symfony-6/.github/workflows/composer.yaml create mode 120000 templates/symfony-6/.github/workflows/markdown.yaml diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 00000000..3d5459c2 --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,26 @@ +on: pull_request +name: Review +jobs: + check-github-actions-documentation: + runs-on: ubuntu-latest + name: Check that Github Actions documentation is up to date + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + - run: | + task github-actions:documentation:update + # Check that documentation has not changed. + - run: | + git diff --exit-code docs/github-action-templates.md + + lint-markdown: + runs-on: ubuntu-latest + name: Lint Markdown + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + - run: | + task lint:markdown + # Check that nothing has changed. + - run: | + git diff --exit-code diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..26ba4790 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.task diff --git a/README.md b/README.md index 4b532d2b..6470e6e6 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ __Note__: You have to follow the instructions brew writes to get it working (use If you use the [Dory](https://github.com/FreedomBen/dory) revers proxy required to run DDF CMS unmodified you need to install dory. We only use dory for DPL/DDF shared projects (multi supplier projects). + ```sh brew install dory ``` @@ -112,13 +113,15 @@ LOCAL_PATH='sites/default/files' ## SSL certification support -This setup comes with self-signed wildcard certificates for *.local.itkdev.dk, but other certificates can be generated by using this openssl command on Mac, just change the two places where the domain is written. +This setup comes with self-signed wildcard certificates for *.local.itkdev.dk, but other certificates can be generated +by using this openssl command on Mac, just change the two places where the domain is written. ```sh openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:2048 -keyout docker.key -out docker.crt -subj "/CN=*.local.itkdev.dk" -reqexts SAN -extensions SAN -config <(cat /usr/local/etc/openssl/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.local.itkdev.dk')) ``` -To mac browser trust this certificate you need to open it with key-chain right click and select "Get info" and then open the "Trust" tab and select "Always trust". +To mac browser trust this certificate you need to open it with key-chain right click and select "Get info" and then open +the "Trust" tab and select "Always trust". The certificate is located in `./treafik/ssl/docker.crt` in this repository. @@ -158,17 +161,19 @@ The fuld list can be found at [https://hub.docker.com/search?q=itkdev&type=image](https://hub.docker.com/search?q=itkdev&type=image). ## More -For more details about usage see https://docs.itkdev.dk + +For more details about usage see ## Previous versions ### NFS mounts removed From version 3.0.0 the feature to use NFS mounted name-volumes has been removed -because it is no longer compatible with MacOS. (@see https://github.com/docker/for-mac/issues/6544) +because it is no longer compatible with MacOS. (@see ) If you have previously enabled NFS with `nfs:enable` you should clean up as follows: + ```shell sudo nano /etc/exports # Delete the line matching this pattern, and save you changes diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..4a2f11a3 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,58 @@ +# https://taskfile.dev + +version: '3' + +vars: + GITHUB_ACTIONS_TEMPLATES_HEADER: | + # Github Actions templates + + This repository contains a number of [GitHub + Actions](https://docs.github.com/en/actions) workflow template files that + are copied to a project when running `itkdev-docker-compose + template:install`. Any changes to the workflows should be made in [this + repository](%THIS_REPOSITORY%) and then the project template must be updated + to match the new templates. + + GITHUB_ACTIONS_TEMPLATES_FOOTER: | + +tasks: + github-actions:documentation:update: + desc: "Update GitHub Actions template documentation" + sources: + - github/workflows/*.yaml + generates: + - docs/github-action-templates.md + cmds: + - mkdir -p docs + - | + echo '{{.GITHUB_ACTIONS_TEMPLATES_HEADER}}' > docs/github-action-templates.md + - | + for f in github/workflows/*.yaml; do + echo "" >> docs/github-action-templates.md + echo "---" >> docs/github-action-templates.md + echo "" >> docs/github-action-templates.md + + echo "[$f]($f)" >> docs/github-action-templates.md + + cat "$f" | grep -E '^###( |$)' | sed -E -e 's/^### ?//' >> docs/github-action-templates.md + done + - | + echo "{{.GITHUB_ACTIONS_TEMPLATES_FOOTER}}" >> docs/github-action-templates.md + # Link to clean up. + - task lint:markdown -- docs/github-action-templates.md + + lint:markdown: + desc: "Lint Markdown" + cmds: + # itkdev/markdownlint does not support `--ignore-path` + - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint --config config/markdownlint-cli/.markdownlint.jsonc --ignore-path config/markdownlint-cli/.markdownlintignore {{.GLOB}} --fix + - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint --config config/markdownlint-cli/.markdownlint.jsonc --ignore-path config/markdownlint-cli/.markdownlintignore {{.GLOB}} + vars: + # We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier. + GLOB: >- + {{.CLI_ARGS | default "\\'**/*.md\\'"}} + + default: + cmds: + - task --list + silent: true diff --git a/config/markdownlint-cli/.markdownlint.jsonc b/config/markdownlint-cli/.markdownlint.jsonc new file mode 100644 index 00000000..37d8959c --- /dev/null +++ b/config/markdownlint-cli/.markdownlint.jsonc @@ -0,0 +1,19 @@ +// markdownlint-cli configuration file (cf. https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration) +{ + "default": true, + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md + "line-length": { + "line_length": 120, + "code_blocks": false, + "tables": false + }, + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md + "no-duplicate-heading": { + "siblings_only": true + }, + // https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md + "no-inline-html": { + "allowed_elements": ["details", "summary"] + } +} diff --git a/config/markdownlint-cli/.markdownlintignore b/config/markdownlint-cli/.markdownlintignore new file mode 100644 index 00000000..dc56f3d9 --- /dev/null +++ b/config/markdownlint-cli/.markdownlintignore @@ -0,0 +1,8 @@ +# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files +vendor/ +node_modules/ + +# Drupal +web/*.md +web/core/ +web/*/contrib/ diff --git a/docs/github-action-templates.md b/docs/github-action-templates.md new file mode 100644 index 00000000..5353c71b --- /dev/null +++ b/docs/github-action-templates.md @@ -0,0 +1,68 @@ +# Github Actions templates + +This repository contains a number of [GitHub +Actions](https://docs.github.com/en/actions) workflow template files that +are copied to a project when running `itkdev-docker-compose +template:install`. Any changes to the workflows should be made in [this +repository](%THIS_REPOSITORY%) and then the project template must be updated +to match the new templates. + +--- + +[github/workflows/changelog.yaml](github/workflows/changelog.yaml) + +## Changelog + +Checks that changelog has been updated + +--- + +[github/workflows/composer.yaml](github/workflows/composer.yaml) + +## Composer + +Validates composer.json and checks that it's normalized. + +### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) + is a dev requirement in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize + ``` + + Normalize `composer.json` by running + + ``` shell + docker compose run --rm phpfpm composer normalize + ``` + +--- + +[github/workflows/drupal.yaml](github/workflows/drupal.yaml) + +## Drupal + +Checks that site can be installed and can be updated (from base branch on +pull request). + +### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. The Drupal site can be installed from existing config. + +--- + +[github/workflows/markdown.yaml](github/workflows/markdown.yaml) + +## Markdown + +Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to +link all Markdown files (`**/*.md`) in the project. + +[markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +`.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. diff --git a/github/workflows/changelog.yaml b/github/workflows/changelog.yaml new file mode 100644 index 00000000..b62c51a6 --- /dev/null +++ b/github/workflows/changelog.yaml @@ -0,0 +1,29 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/changelog.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ## Changelog +### +### Checks that changelog has been updated + +name: Changelog + +on: + pull_request: + +jobs: + changelog: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Git fetch + run: git fetch + + - name: Check that changelog has been updated. + run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml new file mode 100644 index 00000000..2a0bb2a2 --- /dev/null +++ b/github/workflows/composer.yaml @@ -0,0 +1,51 @@ +### ## Composer +### +### Validates composer.json and checks that it's normalized. +### +### ### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. +### 2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) +### is a dev requirement in `composer.json`: +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize +### ``` +### +### Normalize `composer.json` by running +### +### ``` shell +### docker compose run --rm phpfpm composer normalize +### ``` + +name: Composer + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + +jobs: + composer-validate: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer validate + + composer-normalized: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer install + docker compose run --rm phpfpm composer normalize --dry-run diff --git a/github/workflows/drupal.yaml b/github/workflows/drupal.yaml new file mode 100644 index 00000000..c8dfe234 --- /dev/null +++ b/github/workflows/drupal.yaml @@ -0,0 +1,116 @@ +### ## Drupal +### +### Checks that site can be installed and can be updated (from base branch on +### pull request). +### +### ### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. +### 2. The Drupal site can be installed from existing config. + +name: Drupal + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + +jobs: + install-site: + name: Check that site can be installed + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install site + run: | + docker network create frontend + docker compose pull + docker compose up --detach + + # Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. + docker compose exec phpfpm composer install --no-interaction + + - name: Install site + run: | + # Add some local settings. + cat > web/sites/default/settings.local.php <<'EOF' + web/sites/default/settings.local.php <<'EOF' + Date: Wed, 19 Mar 2025 07:47:39 +0100 Subject: [PATCH 02/34] Taking own medicine --- .github/workflows/documentation.yaml | 12 ------------ .github/workflows/markdown.yaml | 1 + .markdownlint.jsonc | 1 + .markdownlintignore | 1 + Taskfile.yml | 8 ++++---- 5 files changed, 7 insertions(+), 16 deletions(-) create mode 120000 .github/workflows/markdown.yaml create mode 120000 .markdownlint.jsonc create mode 120000 .markdownlintignore diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 3d5459c2..5dc41642 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -12,15 +12,3 @@ jobs: # Check that documentation has not changed. - run: | git diff --exit-code docs/github-action-templates.md - - lint-markdown: - runs-on: ubuntu-latest - name: Lint Markdown - steps: - - uses: actions/checkout@v4 - - uses: arduino/setup-task@v2 - - run: | - task lint:markdown - # Check that nothing has changed. - - run: | - git diff --exit-code diff --git a/.github/workflows/markdown.yaml b/.github/workflows/markdown.yaml new file mode 120000 index 00000000..096a25d6 --- /dev/null +++ b/.github/workflows/markdown.yaml @@ -0,0 +1 @@ +../../github/workflows/markdown.yaml \ No newline at end of file diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc new file mode 120000 index 00000000..e25be49a --- /dev/null +++ b/.markdownlint.jsonc @@ -0,0 +1 @@ +config/markdownlint-cli/.markdownlint.jsonc \ No newline at end of file diff --git a/.markdownlintignore b/.markdownlintignore new file mode 120000 index 00000000..bf175359 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +config/markdownlint-cli/.markdownlintignore \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index 4a2f11a3..ef259056 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -44,13 +44,13 @@ tasks: lint:markdown: desc: "Lint Markdown" cmds: - # itkdev/markdownlint does not support `--ignore-path` - - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint --config config/markdownlint-cli/.markdownlint.jsonc --ignore-path config/markdownlint-cli/.markdownlintignore {{.GLOB}} --fix - - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint --config config/markdownlint-cli/.markdownlint.jsonc --ignore-path config/markdownlint-cli/.markdownlintignore {{.GLOB}} + # I cannot get itkdev/markdownlint to work as expected, i.e. as peterdavehello/markdownlint does … + - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}} --fix + - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}} vars: # We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier. GLOB: >- - {{.CLI_ARGS | default "\\'**/*.md\\'"}} + {{.CLI_ARGS | default "'**/*.md'"}} default: cmds: From ada874070dc82ff643acdf3c480c476c73112d1d Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:38:40 +0100 Subject: [PATCH 03/34] Update github/workflows/composer.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ture Gjørup --- github/workflows/composer.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml index 2a0bb2a2..6667b4c1 100644 --- a/github/workflows/composer.yaml +++ b/github/workflows/composer.yaml @@ -49,3 +49,13 @@ jobs: docker network create frontend docker compose run --rm phpfpm composer install docker compose run --rm phpfpm composer normalize --dry-run + + composer-audit: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer audit From b17d5a0d36b4503b436c466a42218a3a98043ce5 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:39:16 +0100 Subject: [PATCH 04/34] Update github/workflows/drupal.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ture Gjørup --- github/workflows/drupal.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github/workflows/drupal.yaml b/github/workflows/drupal.yaml index c8dfe234..da311059 100644 --- a/github/workflows/drupal.yaml +++ b/github/workflows/drupal.yaml @@ -7,7 +7,9 @@ ### ### 1. A docker compose service named `phpfpm` can be run and `composer` can be ### run inside the `phpfpm` service. -### 2. The Drupal site can be installed from existing config. +### 2. The docker setup contains a database container and other the dependent services and the + default settings match connection credentials for these services. +### 3. The Drupal site can be installed from existing config. name: Drupal From 4563bd18459d36b51cfea13874a3bb6652341fd1 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:39:31 +0100 Subject: [PATCH 05/34] Update config/markdownlint-cli/.markdownlintignore Co-authored-by: Sine Jespersen --- config/markdownlint-cli/.markdownlintignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/markdownlint-cli/.markdownlintignore b/config/markdownlint-cli/.markdownlintignore index dc56f3d9..3869d411 100644 --- a/config/markdownlint-cli/.markdownlintignore +++ b/config/markdownlint-cli/.markdownlintignore @@ -1,7 +1,7 @@ # https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files vendor/ node_modules/ - +LICENSE.md # Drupal web/*.md web/core/ From e965ecf2da5b041008d7bedefad3a936a90e9099 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:40:18 +0100 Subject: [PATCH 06/34] Update github/workflows/composer.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ture Gjørup --- github/workflows/composer.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml index 6667b4c1..28894ef4 100644 --- a/github/workflows/composer.yaml +++ b/github/workflows/composer.yaml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v4 - run: | docker network create frontend - docker compose run --rm phpfpm composer validate + docker compose run --rm phpfpm composer validate --strict composer-normalized: runs-on: ubuntu-latest From 5faf70b2974afe8078c79342c2363cba790af359 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:52:04 +0100 Subject: [PATCH 07/34] Updated generated documentation --- docs/github-action-templates.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/github-action-templates.md b/docs/github-action-templates.md index 5353c71b..404326bd 100644 --- a/docs/github-action-templates.md +++ b/docs/github-action-templates.md @@ -53,7 +53,8 @@ pull request). 1. A docker compose service named `phpfpm` can be run and `composer` can be run inside the `phpfpm` service. -2. The Drupal site can be installed from existing config. +2. The docker setup contains a database container and other the dependent services and the +3. The Drupal site can be installed from existing config. --- From 488861b829b59f53ad17628cd2f0980f379c4d0d Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 10:55:28 +0100 Subject: [PATCH 08/34] Added and checked file headers --- .github/workflows/documentation.yaml | 12 ++++++++++++ Taskfile.yml | 26 ++++++++++++++++++++++++++ github/workflows/composer.yaml | 4 ++++ github/workflows/drupal.yaml | 4 ++++ github/workflows/markdown.yaml | 4 ++++ 5 files changed, 50 insertions(+) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 5dc41642..ead2e3bc 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -12,3 +12,15 @@ jobs: # Check that documentation has not changed. - run: | git diff --exit-code docs/github-action-templates.md + + check-github-actions-template-headers: + runs-on: ubuntu-latest + name: Check that Github Actions template headers are up to date + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + - run: | + task github-actions:update-headers --yes + # Check that files hav not changed. + - run: | + git diff --exit-code github/workflows/ diff --git a/Taskfile.yml b/Taskfile.yml index ef259056..20fad9af 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -41,6 +41,32 @@ tasks: # Link to clean up. - task lint:markdown -- docs/github-action-templates.md + github-actions:update-headers: + prompt: "Updating headers may break things, so check result afterwards. Really update headers?" + desc: "Update headers in GitHub Actions templates" + cmds: + - | + for f in github/workflows/*.yaml; do + echo "$f" + # If file starts with `# ` … + if [[ $(head --lines=1 "$f") =~ "^# " ]]; then + # … replace the header. + # This is done by deleting all lines from the top of the file to a blank line. + docker run --rm --volume=$PWD:/app itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" + fi + + # Write header and file into temporary file. + ( + echo "# Do not edit this file! Make a pull request on changing"; + echo "# $f in"; + echo "# https://github.com/itk-dev/devops_itkdev-docker if need be."; + echo ""; + cat "$f" + ) > "$f.tmp" + # Replace original file with temporary file. + mv "$f.tmp" "$f" + done + lint:markdown: desc: "Lint Markdown" cmds: diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml index 28894ef4..aa65bd6c 100644 --- a/github/workflows/composer.yaml +++ b/github/workflows/composer.yaml @@ -1,3 +1,7 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/composer.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + ### ## Composer ### ### Validates composer.json and checks that it's normalized. diff --git a/github/workflows/drupal.yaml b/github/workflows/drupal.yaml index da311059..22ac959f 100644 --- a/github/workflows/drupal.yaml +++ b/github/workflows/drupal.yaml @@ -1,3 +1,7 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/drupal.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + ### ## Drupal ### ### Checks that site can be installed and can be updated (from base branch on diff --git a/github/workflows/markdown.yaml b/github/workflows/markdown.yaml index 2f0702f4..12df4d74 100644 --- a/github/workflows/markdown.yaml +++ b/github/workflows/markdown.yaml @@ -1,3 +1,7 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/markdown.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + ### ## Markdown ### ### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to From e1ab8766ca6ce2284e4487cdf0412968fa4b2654 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 11:08:17 +0100 Subject: [PATCH 09/34] Updated Markdown actions --- .github/workflows/markdown.yaml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) mode change 120000 => 100644 .github/workflows/markdown.yaml diff --git a/.github/workflows/markdown.yaml b/.github/workflows/markdown.yaml deleted file mode 120000 index 096a25d6..00000000 --- a/.github/workflows/markdown.yaml +++ /dev/null @@ -1 +0,0 @@ -../../github/workflows/markdown.yaml \ No newline at end of file diff --git a/.github/workflows/markdown.yaml b/.github/workflows/markdown.yaml new file mode 100644 index 00000000..12df4d74 --- /dev/null +++ b/.github/workflows/markdown.yaml @@ -0,0 +1,29 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/markdown.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ## Markdown +### +### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to +### link all Markdown files (`**/*.md`) in the project. +### +### [markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +### `.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. + +name: Markdown + +on: + pull_request: + push: + +jobs: + markdown-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker run --rm --volume "$PWD":/md itkdev/markdownlint '**/*.md' From d036091742cd8a7572042a2675591c61a1660899 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 11:13:25 +0100 Subject: [PATCH 10/34] Run docker image as appropriate user --- .github/workflows/documentation.yaml | 5 +++++ Taskfile.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index ead2e3bc..ec043454 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -1,5 +1,10 @@ on: pull_request + name: Review + +env: + COMPOSE_USER: root + jobs: check-github-actions-documentation: runs-on: ubuntu-latest diff --git a/Taskfile.yml b/Taskfile.yml index 20fad9af..9e7386eb 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -52,7 +52,7 @@ tasks: if [[ $(head --lines=1 "$f") =~ "^# " ]]; then # … replace the header. # This is done by deleting all lines from the top of the file to a blank line. - docker run --rm --volume=$PWD:/app itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" + docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" fi # Write header and file into temporary file. From 9d31d7cb846c9e240a98b645072cb4ac072eccd6 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 2 Apr 2025 13:33:28 +0200 Subject: [PATCH 11/34] Cleaned up and improved --- .github/workflows/documentation.yaml | 20 ++- .markdownlint.jsonc | 20 ++- .markdownlintignore | 9 +- Taskfile.yml | 59 +------- config/drupal/php/phpcs.xml | 0 config/drupal/twig/.twig-cs-fixer.dist.php | 17 +++ .../.markdownlint.jsonc | 0 .../.markdownlintignore | 0 config/symfony/php/php-cs-fixer.php.dist | 0 config/symfony/twig/.twig-cs-fixer.dist.php | 10 ++ docs/github-action-templates.md | 69 ---------- docs/github-actions-templates.md | 127 ++++++++++++++++++ github/workflows/changelog.yaml | 2 +- github/workflows/composer.yaml | 4 +- github/workflows/drupal-php.yaml | 5 + .../{drupal.yaml => drupal-site.yaml} | 6 +- github/workflows/javascript.yaml | 5 + github/workflows/markdown.yaml | 2 +- github/workflows/styles.yaml | 5 + github/workflows/symfony-php.yaml | 5 + github/workflows/twig.yaml | 45 +++++++ task/Tasfile.github-actions.yml | 84 ++++++++++++ task/github-actions-link.sh | 100 ++++++++++++++ task/github-actions-templates.md | 16 +++ task/github-documentation-update.sh | 54 ++++++++ task/links.png | Bin 0 -> 5257 bytes .../drupal-10/.github/workflows/drupal.yaml | 1 - .../.github/workflows/javascript.yaml | 1 + .../drupal-10/.github/workflows/php.yaml | 1 + .../drupal-10/.github/workflows/site.yaml | 1 + .../drupal-10/.github/workflows/styles.yaml | 1 + .../drupal-10/.github/workflows/twig.yaml | 1 + templates/drupal-10/.markdownlint.jsonc | 2 +- templates/drupal-10/.markdownlintignore | 2 +- templates/drupal-10/.twig-cs-fixer.dist.php | 1 + .../drupal-7/.github/workflows/changelog.yaml | 1 + .../drupal-7/.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../drupal-7/.github/workflows/markdown.yaml | 1 + templates/drupal-7/.github/workflows/php.yaml | 1 + .../drupal-7/.github/workflows/site.yaml | 1 + .../drupal-7/.github/workflows/styles.yaml | 1 + .../drupal-7/.github/workflows/twig.yaml | 1 + templates/drupal-7/.markdownlint.jsonc | 1 + templates/drupal-7/.markdownlintignore | 1 + templates/drupal-7/.twig-cs-fixer.dist.php | 1 + .../drupal-8/.github/workflows/changelog.yaml | 1 + .../drupal-8/.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../drupal-8/.github/workflows/markdown.yaml | 1 + templates/drupal-8/.github/workflows/php.yaml | 1 + .../drupal-8/.github/workflows/site.yaml | 1 + .../drupal-8/.github/workflows/styles.yaml | 1 + .../drupal-8/.github/workflows/twig.yaml | 1 + templates/drupal-8/.markdownlint.jsonc | 1 + templates/drupal-8/.markdownlintignore | 1 + templates/drupal-8/.twig-cs-fixer.dist.php | 1 + .../drupal-9/.github/workflows/changelog.yaml | 1 + .../drupal-9/.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../drupal-9/.github/workflows/markdown.yaml | 1 + templates/drupal-9/.github/workflows/php.yaml | 1 + .../drupal-9/.github/workflows/site.yaml | 1 + .../drupal-9/.github/workflows/styles.yaml | 1 + .../drupal-9/.github/workflows/twig.yaml | 1 + templates/drupal-9/.markdownlint.jsonc | 1 + templates/drupal-9/.markdownlintignore | 1 + templates/drupal-9/.twig-cs-fixer.dist.php | 1 + .../.github/workflows/changelog.yaml | 1 + .../symfony-3/.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../symfony-3/.github/workflows/markdown.yaml | 1 + .../symfony-3/.github/workflows/php.yaml | 1 + .../symfony-3/.github/workflows/styles.yaml | 1 + .../symfony-3/.github/workflows/twig.yaml | 1 + templates/symfony-3/.markdownlint.jsonc | 1 + templates/symfony-3/.markdownlintignore | 1 + templates/symfony-3/.twig-cs-fixer.dist.php | 1 + .../.github/workflows/changelog.yaml | 1 + .../symfony-4/.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../symfony-4/.github/workflows/markdown.yaml | 1 + .../symfony-4/.github/workflows/php.yaml | 1 + .../symfony-4/.github/workflows/styles.yaml | 1 + .../symfony-4/.github/workflows/twig.yaml | 1 + templates/symfony-4/.markdownlint.jsonc | 1 + templates/symfony-4/.markdownlintignore | 1 + templates/symfony-4/.twig-cs-fixer.dist.php | 1 + .../.github/workflows/javascript.yaml | 1 + .../symfony-6/.github/workflows/php.yaml | 1 + .../symfony-6/.github/workflows/styles.yaml | 1 + .../symfony-6/.github/workflows/twig.yaml | 1 + templates/symfony-6/.markdownlint.jsonc | 1 + templates/symfony-6/.markdownlintignore | 1 + templates/symfony-6/.twig-cs-fixer.dist.php | 1 + 95 files changed, 597 insertions(+), 138 deletions(-) mode change 120000 => 100644 .markdownlint.jsonc mode change 120000 => 100644 .markdownlintignore create mode 100644 config/drupal/php/phpcs.xml create mode 100644 config/drupal/twig/.twig-cs-fixer.dist.php rename config/{markdownlint-cli => markdown}/.markdownlint.jsonc (100%) rename config/{markdownlint-cli => markdown}/.markdownlintignore (100%) create mode 100644 config/symfony/php/php-cs-fixer.php.dist create mode 100644 config/symfony/twig/.twig-cs-fixer.dist.php delete mode 100644 docs/github-action-templates.md create mode 100644 docs/github-actions-templates.md create mode 100644 github/workflows/drupal-php.yaml rename github/workflows/{drupal.yaml => drupal-site.yaml} (98%) create mode 100644 github/workflows/javascript.yaml create mode 100644 github/workflows/styles.yaml create mode 100644 github/workflows/symfony-php.yaml create mode 100644 github/workflows/twig.yaml create mode 100644 task/Tasfile.github-actions.yml create mode 100755 task/github-actions-link.sh create mode 100644 task/github-actions-templates.md create mode 100755 task/github-documentation-update.sh create mode 100644 task/links.png delete mode 120000 templates/drupal-10/.github/workflows/drupal.yaml create mode 120000 templates/drupal-10/.github/workflows/javascript.yaml create mode 120000 templates/drupal-10/.github/workflows/php.yaml create mode 120000 templates/drupal-10/.github/workflows/site.yaml create mode 120000 templates/drupal-10/.github/workflows/styles.yaml create mode 120000 templates/drupal-10/.github/workflows/twig.yaml create mode 120000 templates/drupal-10/.twig-cs-fixer.dist.php create mode 120000 templates/drupal-7/.github/workflows/changelog.yaml create mode 120000 templates/drupal-7/.github/workflows/composer.yaml create mode 120000 templates/drupal-7/.github/workflows/javascript.yaml create mode 120000 templates/drupal-7/.github/workflows/markdown.yaml create mode 120000 templates/drupal-7/.github/workflows/php.yaml create mode 120000 templates/drupal-7/.github/workflows/site.yaml create mode 120000 templates/drupal-7/.github/workflows/styles.yaml create mode 120000 templates/drupal-7/.github/workflows/twig.yaml create mode 120000 templates/drupal-7/.markdownlint.jsonc create mode 120000 templates/drupal-7/.markdownlintignore create mode 120000 templates/drupal-7/.twig-cs-fixer.dist.php create mode 120000 templates/drupal-8/.github/workflows/changelog.yaml create mode 120000 templates/drupal-8/.github/workflows/composer.yaml create mode 120000 templates/drupal-8/.github/workflows/javascript.yaml create mode 120000 templates/drupal-8/.github/workflows/markdown.yaml create mode 120000 templates/drupal-8/.github/workflows/php.yaml create mode 120000 templates/drupal-8/.github/workflows/site.yaml create mode 120000 templates/drupal-8/.github/workflows/styles.yaml create mode 120000 templates/drupal-8/.github/workflows/twig.yaml create mode 120000 templates/drupal-8/.markdownlint.jsonc create mode 120000 templates/drupal-8/.markdownlintignore create mode 120000 templates/drupal-8/.twig-cs-fixer.dist.php create mode 120000 templates/drupal-9/.github/workflows/changelog.yaml create mode 120000 templates/drupal-9/.github/workflows/composer.yaml create mode 120000 templates/drupal-9/.github/workflows/javascript.yaml create mode 120000 templates/drupal-9/.github/workflows/markdown.yaml create mode 120000 templates/drupal-9/.github/workflows/php.yaml create mode 120000 templates/drupal-9/.github/workflows/site.yaml create mode 120000 templates/drupal-9/.github/workflows/styles.yaml create mode 120000 templates/drupal-9/.github/workflows/twig.yaml create mode 120000 templates/drupal-9/.markdownlint.jsonc create mode 120000 templates/drupal-9/.markdownlintignore create mode 120000 templates/drupal-9/.twig-cs-fixer.dist.php create mode 120000 templates/symfony-3/.github/workflows/changelog.yaml create mode 120000 templates/symfony-3/.github/workflows/composer.yaml create mode 120000 templates/symfony-3/.github/workflows/javascript.yaml create mode 120000 templates/symfony-3/.github/workflows/markdown.yaml create mode 120000 templates/symfony-3/.github/workflows/php.yaml create mode 120000 templates/symfony-3/.github/workflows/styles.yaml create mode 120000 templates/symfony-3/.github/workflows/twig.yaml create mode 120000 templates/symfony-3/.markdownlint.jsonc create mode 120000 templates/symfony-3/.markdownlintignore create mode 120000 templates/symfony-3/.twig-cs-fixer.dist.php create mode 120000 templates/symfony-4/.github/workflows/changelog.yaml create mode 120000 templates/symfony-4/.github/workflows/composer.yaml create mode 120000 templates/symfony-4/.github/workflows/javascript.yaml create mode 120000 templates/symfony-4/.github/workflows/markdown.yaml create mode 120000 templates/symfony-4/.github/workflows/php.yaml create mode 120000 templates/symfony-4/.github/workflows/styles.yaml create mode 120000 templates/symfony-4/.github/workflows/twig.yaml create mode 120000 templates/symfony-4/.markdownlint.jsonc create mode 120000 templates/symfony-4/.markdownlintignore create mode 120000 templates/symfony-4/.twig-cs-fixer.dist.php create mode 120000 templates/symfony-6/.github/workflows/javascript.yaml create mode 120000 templates/symfony-6/.github/workflows/php.yaml create mode 120000 templates/symfony-6/.github/workflows/styles.yaml create mode 120000 templates/symfony-6/.github/workflows/twig.yaml create mode 120000 templates/symfony-6/.markdownlint.jsonc create mode 120000 templates/symfony-6/.markdownlintignore create mode 120000 templates/symfony-6/.twig-cs-fixer.dist.php diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index ec043454..6d106294 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -3,7 +3,7 @@ on: pull_request name: Review env: - COMPOSE_USER: root + COMPOSE_USER: runner jobs: check-github-actions-documentation: @@ -12,11 +12,23 @@ jobs: steps: - uses: actions/checkout@v4 - uses: arduino/setup-task@v2 + # https://github.com/arduino/setup-task/tree/56d0cc033e3cecc5f07a291fdd39f29388d21800?tab=readme-ov-file#repo-token + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + # https://github.com/mxschmitt/action-tmate?tab=readme-ov-file#manually-triggered-debug + # Enable tmate debugging if debug logging is enabled (cf. + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context) + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: 1 == runner.debug + - run: | task github-actions:documentation:update + # Check that documentation has not changed. - run: | - git diff --exit-code docs/github-action-templates.md + task github-actions:documentation:diff check-github-actions-template-headers: runs-on: ubuntu-latest @@ -24,8 +36,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - run: | - task github-actions:update-headers --yes + task github-actions:template-headers:update --yes # Check that files hav not changed. - run: | git diff --exit-code github/workflows/ diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc deleted file mode 120000 index e25be49a..00000000 --- a/.markdownlint.jsonc +++ /dev/null @@ -1 +0,0 @@ -config/markdownlint-cli/.markdownlint.jsonc \ No newline at end of file diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc new file mode 100644 index 00000000..37d8959c --- /dev/null +++ b/.markdownlint.jsonc @@ -0,0 +1,19 @@ +// markdownlint-cli configuration file (cf. https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration) +{ + "default": true, + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md + "line-length": { + "line_length": 120, + "code_blocks": false, + "tables": false + }, + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md + "no-duplicate-heading": { + "siblings_only": true + }, + // https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md + "no-inline-html": { + "allowed_elements": ["details", "summary"] + } +} diff --git a/.markdownlintignore b/.markdownlintignore deleted file mode 120000 index bf175359..00000000 --- a/.markdownlintignore +++ /dev/null @@ -1 +0,0 @@ -config/markdownlint-cli/.markdownlintignore \ No newline at end of file diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 00000000..3869d411 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1,8 @@ +# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files +vendor/ +node_modules/ +LICENSE.md +# Drupal +web/*.md +web/core/ +web/*/contrib/ diff --git a/Taskfile.yml b/Taskfile.yml index 9e7386eb..2f291915 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -2,6 +2,9 @@ version: '3' +includes: + github-actions: ./task/Tasfile.github-actions.yml + vars: GITHUB_ACTIONS_TEMPLATES_HEADER: | # Github Actions templates @@ -16,63 +19,11 @@ vars: GITHUB_ACTIONS_TEMPLATES_FOOTER: | tasks: - github-actions:documentation:update: - desc: "Update GitHub Actions template documentation" - sources: - - github/workflows/*.yaml - generates: - - docs/github-action-templates.md - cmds: - - mkdir -p docs - - | - echo '{{.GITHUB_ACTIONS_TEMPLATES_HEADER}}' > docs/github-action-templates.md - - | - for f in github/workflows/*.yaml; do - echo "" >> docs/github-action-templates.md - echo "---" >> docs/github-action-templates.md - echo "" >> docs/github-action-templates.md - - echo "[$f]($f)" >> docs/github-action-templates.md - - cat "$f" | grep -E '^###( |$)' | sed -E -e 's/^### ?//' >> docs/github-action-templates.md - done - - | - echo "{{.GITHUB_ACTIONS_TEMPLATES_FOOTER}}" >> docs/github-action-templates.md - # Link to clean up. - - task lint:markdown -- docs/github-action-templates.md - - github-actions:update-headers: - prompt: "Updating headers may break things, so check result afterwards. Really update headers?" - desc: "Update headers in GitHub Actions templates" - cmds: - - | - for f in github/workflows/*.yaml; do - echo "$f" - # If file starts with `# ` … - if [[ $(head --lines=1 "$f") =~ "^# " ]]; then - # … replace the header. - # This is done by deleting all lines from the top of the file to a blank line. - docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" - fi - - # Write header and file into temporary file. - ( - echo "# Do not edit this file! Make a pull request on changing"; - echo "# $f in"; - echo "# https://github.com/itk-dev/devops_itkdev-docker if need be."; - echo ""; - cat "$f" - ) > "$f.tmp" - # Replace original file with temporary file. - mv "$f.tmp" "$f" - done - lint:markdown: desc: "Lint Markdown" cmds: - # I cannot get itkdev/markdownlint to work as expected, i.e. as peterdavehello/markdownlint does … - - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}} --fix - - docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}} + - '[[ -n "$SKIP_FIX" ]] || docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}} --fix' + - docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}} vars: # We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier. GLOB: >- diff --git a/config/drupal/php/phpcs.xml b/config/drupal/php/phpcs.xml new file mode 100644 index 00000000..e69de29b diff --git a/config/drupal/twig/.twig-cs-fixer.dist.php b/config/drupal/twig/.twig-cs-fixer.dist.php new file mode 100644 index 00000000..f36cb79b --- /dev/null +++ b/config/drupal/twig/.twig-cs-fixer.dist.php @@ -0,0 +1,17 @@ +in('web/*/custom/*/templates'); +} +// Include sub-modules or sub-themes +if (glob('web/*/custom/*/*/templates')) { + $finder->in('web/*/custom/*/*/templates'); +} + +$config = new TwigCsFixer\Config\Config(); +$config->setFinder($finder); + +return $config; diff --git a/config/markdownlint-cli/.markdownlint.jsonc b/config/markdown/.markdownlint.jsonc similarity index 100% rename from config/markdownlint-cli/.markdownlint.jsonc rename to config/markdown/.markdownlint.jsonc diff --git a/config/markdownlint-cli/.markdownlintignore b/config/markdown/.markdownlintignore similarity index 100% rename from config/markdownlint-cli/.markdownlintignore rename to config/markdown/.markdownlintignore diff --git a/config/symfony/php/php-cs-fixer.php.dist b/config/symfony/php/php-cs-fixer.php.dist new file mode 100644 index 00000000..e69de29b diff --git a/config/symfony/twig/.twig-cs-fixer.dist.php b/config/symfony/twig/.twig-cs-fixer.dist.php new file mode 100644 index 00000000..13d932a7 --- /dev/null +++ b/config/symfony/twig/.twig-cs-fixer.dist.php @@ -0,0 +1,10 @@ +in('templates'); + +$config = new TwigCsFixer\Config\Config(); +$config->setFinder($finder); + +return $config; diff --git a/docs/github-action-templates.md b/docs/github-action-templates.md deleted file mode 100644 index 404326bd..00000000 --- a/docs/github-action-templates.md +++ /dev/null @@ -1,69 +0,0 @@ -# Github Actions templates - -This repository contains a number of [GitHub -Actions](https://docs.github.com/en/actions) workflow template files that -are copied to a project when running `itkdev-docker-compose -template:install`. Any changes to the workflows should be made in [this -repository](%THIS_REPOSITORY%) and then the project template must be updated -to match the new templates. - ---- - -[github/workflows/changelog.yaml](github/workflows/changelog.yaml) - -## Changelog - -Checks that changelog has been updated - ---- - -[github/workflows/composer.yaml](github/workflows/composer.yaml) - -## Composer - -Validates composer.json and checks that it's normalized. - -### Assumptions - -1. A docker compose service named `phpfpm` can be run and `composer` can be - run inside the `phpfpm` service. -2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) - is a dev requirement in `composer.json`: - - ``` shell - docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize - ``` - - Normalize `composer.json` by running - - ``` shell - docker compose run --rm phpfpm composer normalize - ``` - ---- - -[github/workflows/drupal.yaml](github/workflows/drupal.yaml) - -## Drupal - -Checks that site can be installed and can be updated (from base branch on -pull request). - -### Assumptions - -1. A docker compose service named `phpfpm` can be run and `composer` can be - run inside the `phpfpm` service. -2. The docker setup contains a database container and other the dependent services and the -3. The Drupal site can be installed from existing config. - ---- - -[github/workflows/markdown.yaml](github/workflows/markdown.yaml) - -## Markdown - -Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to -link all Markdown files (`**/*.md`) in the project. - -[markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), -`.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md new file mode 100644 index 00000000..86406b7c --- /dev/null +++ b/docs/github-actions-templates.md @@ -0,0 +1,127 @@ + +# Github Actions templates + +This repository contains a number of [GitHub Actions](https://docs.github.com/en/actions) workflow template files that +are copied to a project when running `itkdev-docker-compose template:install`. Any changes to the workflows should be +made in [this repository](https://github.com/itk-dev/devops_itkdev-docker) and then the project template must be updated +to match the new templates. + +## Naming conventions + +* Named after what a tool is concerned with, not how it's concerned with it. +* Some configuration based on template type (drupal, symfony) + +## Templates + +--- + +[github/workflows/changelog.yaml](github/workflows/changelog.yaml) + +### Changelog + +Checks that changelog has been updated + +--- + +[github/workflows/composer.yaml](github/workflows/composer.yaml) + +### Composer + +Validates composer.json and checks that it's normalized. + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) + is a dev requirement in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize + ``` + + Normalize `composer.json` by running + + ``` shell + docker compose run --rm phpfpm composer normalize + ``` + +--- + +[github/workflows/drupal-php.yaml](github/workflows/drupal-php.yaml) + +Drupal PHP + +--- + +[github/workflows/drupal-site.yaml](github/workflows/drupal-site.yaml) + +### Drupal + +Checks that site can be installed and can be updated (from base branch on +pull request). + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. The docker setup contains a database container and other the dependent services and the +3. The Drupal site can be installed from existing config. + +--- + +[github/workflows/javascript.yaml](github/workflows/javascript.yaml) + +JavaScript (and TypeScript) + +--- + +[github/workflows/markdown.yaml](github/workflows/markdown.yaml) + +### Markdown + +Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to +link all Markdown files (`**/*.md`) in the project. + +[markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +`.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. + +--- + +[github/workflows/styles.yaml](github/workflows/styles.yaml) + +Styles (CSS and SCSS) + +--- + +[github/workflows/symfony-php.yaml](github/workflows/symfony-php.yaml) + +Symfony PHP + +--- + +[github/workflows/twig.yaml](github/workflows/twig.yaml) + +### Twigt + +Validates Twig files + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. [vincentlanglet/twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) + is a dev requirement in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev vincentlanglet/twig-cs-fixer + ``` + +3. A [Configuration + file](https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file) + in the root of the project defines which files to check and rules to use. + +--- diff --git a/github/workflows/changelog.yaml b/github/workflows/changelog.yaml index b62c51a6..483da6e9 100644 --- a/github/workflows/changelog.yaml +++ b/github/workflows/changelog.yaml @@ -2,7 +2,7 @@ # github/workflows/changelog.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ## Changelog +### ### Changelog ### ### Checks that changelog has been updated diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml index aa65bd6c..4586cbc7 100644 --- a/github/workflows/composer.yaml +++ b/github/workflows/composer.yaml @@ -2,11 +2,11 @@ # github/workflows/composer.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ## Composer +### ### Composer ### ### Validates composer.json and checks that it's normalized. ### -### ### Assumptions +### #### Assumptions ### ### 1. A docker compose service named `phpfpm` can be run and `composer` can be ### run inside the `phpfpm` service. diff --git a/github/workflows/drupal-php.yaml b/github/workflows/drupal-php.yaml new file mode 100644 index 00000000..0c416127 --- /dev/null +++ b/github/workflows/drupal-php.yaml @@ -0,0 +1,5 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/drupal-php.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### Drupal PHP diff --git a/github/workflows/drupal.yaml b/github/workflows/drupal-site.yaml similarity index 98% rename from github/workflows/drupal.yaml rename to github/workflows/drupal-site.yaml index 22ac959f..ea130350 100644 --- a/github/workflows/drupal.yaml +++ b/github/workflows/drupal-site.yaml @@ -1,13 +1,13 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/drupal.yaml in +# github/workflows/drupal-site.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ## Drupal +### ### Drupal ### ### Checks that site can be installed and can be updated (from base branch on ### pull request). ### -### ### Assumptions +### #### Assumptions ### ### 1. A docker compose service named `phpfpm` can be run and `composer` can be ### run inside the `phpfpm` service. diff --git a/github/workflows/javascript.yaml b/github/workflows/javascript.yaml new file mode 100644 index 00000000..8696a809 --- /dev/null +++ b/github/workflows/javascript.yaml @@ -0,0 +1,5 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/javascript.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### JavaScript (and TypeScript) diff --git a/github/workflows/markdown.yaml b/github/workflows/markdown.yaml index 12df4d74..b490284b 100644 --- a/github/workflows/markdown.yaml +++ b/github/workflows/markdown.yaml @@ -2,7 +2,7 @@ # github/workflows/markdown.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ## Markdown +### ### Markdown ### ### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to ### link all Markdown files (`**/*.md`) in the project. diff --git a/github/workflows/styles.yaml b/github/workflows/styles.yaml new file mode 100644 index 00000000..7f4e1d62 --- /dev/null +++ b/github/workflows/styles.yaml @@ -0,0 +1,5 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/styles.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### Styles (CSS and SCSS) diff --git a/github/workflows/symfony-php.yaml b/github/workflows/symfony-php.yaml new file mode 100644 index 00000000..a0e18458 --- /dev/null +++ b/github/workflows/symfony-php.yaml @@ -0,0 +1,5 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/symfony-php.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### Symfony PHP diff --git a/github/workflows/twig.yaml b/github/workflows/twig.yaml new file mode 100644 index 00000000..95b0a2b4 --- /dev/null +++ b/github/workflows/twig.yaml @@ -0,0 +1,45 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/twig.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Twigt +### +### Validates Twig files +### +### #### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. +### 2. [vincentlanglet/twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) +### is a dev requirement in `composer.json`: +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev vincentlanglet/twig-cs-fixer +### ``` +### +### 3. A [Configuration +### file](https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file) +### in the root of the project defines which files to check and rules to use. + +name: Twig + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + +jobs: + twig-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + docker compose run --rm phpfpm composer install + docker compose run --rm phpfpm vendor/bin/twig-cs-fixer lint diff --git a/task/Tasfile.github-actions.yml b/task/Tasfile.github-actions.yml new file mode 100644 index 00000000..71ccfd38 --- /dev/null +++ b/task/Tasfile.github-actions.yml @@ -0,0 +1,84 @@ +version: '3' + +tasks: + documentation:update: + desc: "Update GitHub Actions template documentation" + cmds: + - task: run-script + vars: + SCRIPT: task/github-documentation-update.sh + - SKIP_FIX=1 task lint:markdown -- docs/github-actions-templates.md + + documentation:diff: + desc: "Diff generated documentation ignoring select lines" + cmds: + # Ignore some PO metadata when git diff'ing, e.g. + # + # "POT-Creation-Date: 2025-03-12 18:18+0100\n" + # "PO-Revision-Date: 2025-03-12 18:18+0100\n" + - git diff --exit-code --ignore-blank-lines --ignore-matching-lines='automatically created' '*.md' + + documentation:checkout: + desc: 'git checkout all translation file changes if only date metadata is changed' + cmds: + - git checkout '*.md' + # https://taskfile.dev/reference/schema#precondition + preconditions: + - sh: task {{.TASK | replace ":checkout" ":diff" }} + msg: | + Translations seem to have changed. + + Run + + task {{.TASK | replace ":checkout" ":diff" }} + + to check. + + template-headers:update: + prompt: "Updating headers may break things, so check result afterwards. Really update headers?" + desc: "Update headers in GitHub Actions templates" + cmds: + - | + for f in github/workflows/*.yaml; do + echo "$f" + # If file starts with `# ` … + if [[ $(head --lines=1 "$f") =~ "^# " ]]; then + # … replace the header. + # This is done by deleting all lines from the top of the file to a blank line. + docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" + fi + + # Write header and file into temporary file. + ( + echo "# Do not edit this file! Make a pull request on changing"; + echo "# $f in"; + echo "# https://github.com/itk-dev/devops_itkdev-docker if need be."; + echo ""; + cat "$f" + ) > "$f.tmp" + # Replace original file with temporary file. + mv "$f.tmp" "$f" + done + + link: + desc: "Set up symlinks" + prompt: "Reset all symlinks?" + cmds: + - task: run-script + vars: + SCRIPT: task/github-actions-link.sh + silent: true + + show: + desc: "Show links" + cmds: + - find templates -type l -ls + silent: true + + run-script: + internal: true + cmds: + - docker run --rm --volume "$PWD:/app" --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest {{.SCRIPT}} + requires: + vars: + - SCRIPT diff --git a/task/github-actions-link.sh b/task/github-actions-link.sh new file mode 100755 index 00000000..84062ef0 --- /dev/null +++ b/task/github-actions-link.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +set -o errexit -o errtrace -o noclobber -o nounset -o pipefail +IFS=$'\n\t' + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +project_dir=$(cd "$(dirname "$script_dir")" && pwd) + +cd "$project_dir" || exit + +# String type (drupal or symfony) from start of name +function strip-project-type() { + name=$1 + + if [[ "$name" =~ ^(drupal-|symfony-)(.+) ]]; then + name="${BASH_REMATCH[2]}" + fi + + echo $name +} + +find templates -type l -delete + +for template_dir in templates/*; do + template_name=$(basename "$template_dir") + + echo "$template_name" + echo + + project_type="" + if [[ "$template_name" =~ ^drupal- ]]; then + project_type="drupal" + elif [[ "$template_name" =~ ^symfony- ]]; then + project_type="symfony" + else + (>&2 echo "Unknown template type: $template_name") + exit 1 + fi + + for f in github/workflows/*.yaml; do + file_name=$(basename "$f") + source_file_name='' + if [[ "$file_name" =~ ^drupal- ]]; then + if [[ "$project_type" == "drupal" ]]; then + source_file_name="$file_name" + fi + elif [[ "$file_name" =~ ^symfony- ]]; then + if [[ "$project_type" == "symfony" ]]; then + source_file_name="$file_name" + fi + else + source_file_name="$file_name" + fi + + if [[ -n "$source_file_name" ]]; then + # Link GitHub Actions workflow file + target_dir="$template_dir/.github/workflows" + mkdir -p "$target_dir" + ln -sf "../../../../github/workflows/$source_file_name" "$target_dir/$(strip-project-type "$source_file_name")" + + # Check if we need a language configuration as well + language_name=${source_file_name%.yaml} + config_dir="" + # Check for project_type specific configuration first. + if [ -d "config/$project_type/$language_name" ]; then + config_dir="config/$project_type/$language_name" + elif [ -d "config/$language_name" ]; then + config_dir="config/$language_name" + fi + + if [[ -n "$config_dir" ]]; then + # Some config files are hidden + GLOBIGNORE=".:.." + for config_file in "$config_dir"/*; do + if [ -f "$config_file" ]; then + ln -sf "../../$config_file" "$template_dir/" + fi + done + fi + fi + done + + find "$template_dir" -type l -ls + echo +done + +# Generate Mermaid graph showing links +mermaid_file_name="$script_dir/links.mermaid" + +cat >| "$mermaid_file_name" <<'EOF' +graph TD +EOF +for link in $(find templates -type l); do + link_id=$(base64 <<< $link) + link_id=${link_id//=} + + target=$(readlink $link) + target_id=$(base64 <<< $target) + target_id=${target_id//=} + echo " $link_id[$link] --> $target_id[$target]" >> "$mermaid_file_name" +done diff --git a/task/github-actions-templates.md b/task/github-actions-templates.md new file mode 100644 index 00000000..48063169 --- /dev/null +++ b/task/github-actions-templates.md @@ -0,0 +1,16 @@ +# Github Actions templates + +This repository contains a number of [GitHub Actions](https://docs.github.com/en/actions) workflow template files that +are copied to a project when running `itkdev-docker-compose template:install`. Any changes to the workflows should be +made in [this repository](https://github.com/itk-dev/devops_itkdev-docker) and then the project template must be updated +to match the new templates. + +## Naming conventions + +* Named after what a tool is concerned with, not how it's concerned with it. +* Some configuration based on template type (drupal, symfony) + +## Templates + + +--- diff --git a/task/github-documentation-update.sh b/task/github-documentation-update.sh new file mode 100755 index 00000000..c6e181ed --- /dev/null +++ b/task/github-documentation-update.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# set -o errexit -o errtrace -o noclobber -o nounset -o pipefail +# IFS=$'\n\t' + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +project_dir=$(cd "$(dirname "$script_dir")" && pwd) + +cd "$project_dir" || exit + +template_file_name="$script_dir/github-actions-templates.md" + +place_holder="insert:templates:here" +place_holder_line=$(grep --line-number --no-filename "$place_holder" task/github-actions-templates.md | cut -d: -f1) + +if [[ -z "$place_holder_line" ]]; then + (>&2 echo "Cannot find placeholder $place_holder in $template_file_name") + exit 1 +fi + +output_file_name="docs/$(basename "$template_file_name")" + +mkdir -p "$(dirname "$output_file_name")" + +# Empty the output file +: >| "$output_file_name" + +cat >> "$output_file_name" < +EOF + +# Template content before place holder +head --lines="$((place_holder_line-1))" "$template_file_name" >> "$output_file_name" + +for f in github/workflows/*.yaml; do + # Separator + cat >> "$output_file_name" <> "$output_file_name" +done + +# Template content after place holder +tail --lines="+$((place_holder_line+1))" "$template_file_name" >> "$output_file_name" + +echo "$output_file_name" diff --git a/task/links.png b/task/links.png new file mode 100644 index 0000000000000000000000000000000000000000..a9af4562d35ebfa449166c3931bcafd7468a4f36 GIT binary patch literal 5257 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 Date: Tue, 8 Apr 2025 09:52:19 +0200 Subject: [PATCH 12/34] More clean up --- Taskfile.yml | 2 +- config/drupal/php/.phpcs.xml.dist | 29 +++++++++ config/drupal/php/phpcs.xml | 0 config/drupal/twig/.twig-cs-fixer.dist.php | 12 ++-- config/symfony/php/.php-cs-fixer.dist.php | 17 +++++ config/symfony/php/php-cs-fixer.php.dist | 0 config/symfony/twig/.twig-cs-fixer.dist.php | 5 +- docs/github-actions-templates.md | 10 +-- .../{drupal-php.yaml => drupal/php.yaml} | 2 +- .../{drupal-site.yaml => drupal/site.yaml} | 2 +- .../{symfony-php.yaml => symfony/php.yaml} | 2 +- github/workflows/twig.yaml | 2 +- ...ctions.yml => Taskfile.github-actions.yml} | 18 +++--- task/docs/github-actions-templates.md | 24 ++++++++ task/github-documentation-update.sh | 54 ---------------- task/links.png | Bin 5257 -> 0 bytes .../github-actions-link} | 34 +++------- task/scripts/github-documentation-update | 58 ++++++++++++++++++ .../github-actions-templates.md | 1 + .../drupal-10/.github/workflows/php.yaml | 2 +- .../drupal-10/.github/workflows/site.yaml | 2 +- templates/drupal-10/.phpcs.xml.dist | 1 + templates/drupal-7/.github/workflows/php.yaml | 2 +- .../drupal-7/.github/workflows/site.yaml | 2 +- templates/drupal-7/.phpcs.xml.dist | 1 + templates/drupal-8/.github/workflows/php.yaml | 2 +- .../drupal-8/.github/workflows/site.yaml | 2 +- templates/drupal-8/.phpcs.xml.dist | 1 + templates/drupal-9/.github/workflows/php.yaml | 2 +- .../drupal-9/.github/workflows/site.yaml | 2 +- templates/drupal-9/.phpcs.xml.dist | 1 + .../symfony-3/.github/workflows/php.yaml | 2 +- templates/symfony-3/.php-cs-fixer.dist.php | 1 + .../symfony-4/.github/workflows/php.yaml | 2 +- templates/symfony-4/.php-cs-fixer.dist.php | 1 + .../symfony-6/.github/workflows/php.yaml | 2 +- templates/symfony-6/.php-cs-fixer.dist.php | 1 + 37 files changed, 183 insertions(+), 118 deletions(-) create mode 100644 config/drupal/php/.phpcs.xml.dist delete mode 100644 config/drupal/php/phpcs.xml create mode 100644 config/symfony/php/.php-cs-fixer.dist.php delete mode 100644 config/symfony/php/php-cs-fixer.php.dist rename github/workflows/{drupal-php.yaml => drupal/php.yaml} (78%) rename github/workflows/{drupal-site.yaml => drupal/site.yaml} (99%) rename github/workflows/{symfony-php.yaml => symfony/php.yaml} (77%) rename task/{Tasfile.github-actions.yml => Taskfile.github-actions.yml} (87%) create mode 100644 task/docs/github-actions-templates.md delete mode 100755 task/github-documentation-update.sh delete mode 100644 task/links.png rename task/{github-actions-link.sh => scripts/github-actions-link} (71%) create mode 100755 task/scripts/github-documentation-update rename task/{ => templates}/github-actions-templates.md (99%) create mode 120000 templates/drupal-10/.phpcs.xml.dist create mode 120000 templates/drupal-7/.phpcs.xml.dist create mode 120000 templates/drupal-8/.phpcs.xml.dist create mode 120000 templates/drupal-9/.phpcs.xml.dist create mode 120000 templates/symfony-3/.php-cs-fixer.dist.php create mode 120000 templates/symfony-4/.php-cs-fixer.dist.php create mode 120000 templates/symfony-6/.php-cs-fixer.dist.php diff --git a/Taskfile.yml b/Taskfile.yml index 2f291915..9a621dc0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,7 +3,7 @@ version: '3' includes: - github-actions: ./task/Tasfile.github-actions.yml + github-actions: ./task/Taskfile.github-actions.yml vars: GITHUB_ACTIONS_TEMPLATES_HEADER: | diff --git a/config/drupal/php/.phpcs.xml.dist b/config/drupal/php/.phpcs.xml.dist new file mode 100644 index 00000000..e3edb524 --- /dev/null +++ b/config/drupal/php/.phpcs.xml.dist @@ -0,0 +1,29 @@ + + + The coding standard. + + web/*/custom/ + + + node_modules + vendor + web/*/custom/*/build/ + *.css + *.js + + + + + + + + + + + + + + + + + diff --git a/config/drupal/php/phpcs.xml b/config/drupal/php/phpcs.xml deleted file mode 100644 index e69de29b..00000000 diff --git a/config/drupal/twig/.twig-cs-fixer.dist.php b/config/drupal/twig/.twig-cs-fixer.dist.php index f36cb79b..427f75ce 100644 --- a/config/drupal/twig/.twig-cs-fixer.dist.php +++ b/config/drupal/twig/.twig-cs-fixer.dist.php @@ -2,14 +2,10 @@ // https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file $finder = new TwigCsFixer\File\Finder(); - -if (glob('web/*/custom/*/templates')) { - $finder->in('web/*/custom/*/templates'); -} -// Include sub-modules or sub-themes -if (glob('web/*/custom/*/*/templates')) { - $finder->in('web/*/custom/*/*/templates'); -} +// Check all files … +$finder->in(__DIR__); +// … that are not ignored by VCS +$finder->ignoreVCSIgnored(true); $config = new TwigCsFixer\Config\Config(); $config->setFinder($finder); diff --git a/config/symfony/php/.php-cs-fixer.dist.php b/config/symfony/php/.php-cs-fixer.dist.php new file mode 100644 index 00000000..7556896e --- /dev/null +++ b/config/symfony/php/.php-cs-fixer.dist.php @@ -0,0 +1,17 @@ +in(__DIR__); +// … that are not ignored by VCS +$finder->ignoreVCSIgnored(true); + +$config = new PhpCsFixer\Config(); +$config->setFinder($finder); + +$config->setRules([ + '@Symfony' => true, +]); + +return $config; diff --git a/config/symfony/php/php-cs-fixer.php.dist b/config/symfony/php/php-cs-fixer.php.dist deleted file mode 100644 index e69de29b..00000000 diff --git a/config/symfony/twig/.twig-cs-fixer.dist.php b/config/symfony/twig/.twig-cs-fixer.dist.php index 13d932a7..427f75ce 100644 --- a/config/symfony/twig/.twig-cs-fixer.dist.php +++ b/config/symfony/twig/.twig-cs-fixer.dist.php @@ -2,7 +2,10 @@ // https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file $finder = new TwigCsFixer\File\Finder(); -$finder->in('templates'); +// Check all files … +$finder->in(__DIR__); +// … that are not ignored by VCS +$finder->ignoreVCSIgnored(true); $config = new TwigCsFixer\Config\Config(); $config->setFinder($finder); diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index 86406b7c..9c738b55 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ # Github Actions templates @@ -51,13 +51,13 @@ Validates composer.json and checks that it's normalized. --- -[github/workflows/drupal-php.yaml](github/workflows/drupal-php.yaml) +[github/workflows/drupal/php.yaml](github/workflows/drupal/php.yaml) Drupal PHP --- -[github/workflows/drupal-site.yaml](github/workflows/drupal-site.yaml) +[github/workflows/drupal/site.yaml](github/workflows/drupal/site.yaml) ### Drupal @@ -97,7 +97,7 @@ Styles (CSS and SCSS) --- -[github/workflows/symfony-php.yaml](github/workflows/symfony-php.yaml) +[github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml) Symfony PHP @@ -105,7 +105,7 @@ Symfony PHP [github/workflows/twig.yaml](github/workflows/twig.yaml) -### Twigt +### Twig Validates Twig files diff --git a/github/workflows/drupal-php.yaml b/github/workflows/drupal/php.yaml similarity index 78% rename from github/workflows/drupal-php.yaml rename to github/workflows/drupal/php.yaml index 0c416127..21722fb9 100644 --- a/github/workflows/drupal-php.yaml +++ b/github/workflows/drupal/php.yaml @@ -1,5 +1,5 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/drupal-php.yaml in +# github/workflows/drupal/php.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. ### Drupal PHP diff --git a/github/workflows/drupal-site.yaml b/github/workflows/drupal/site.yaml similarity index 99% rename from github/workflows/drupal-site.yaml rename to github/workflows/drupal/site.yaml index ea130350..3a5328bd 100644 --- a/github/workflows/drupal-site.yaml +++ b/github/workflows/drupal/site.yaml @@ -1,5 +1,5 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/drupal-site.yaml in +# github/workflows/drupal/site.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. ### ### Drupal diff --git a/github/workflows/symfony-php.yaml b/github/workflows/symfony/php.yaml similarity index 77% rename from github/workflows/symfony-php.yaml rename to github/workflows/symfony/php.yaml index a0e18458..a567fa8a 100644 --- a/github/workflows/symfony-php.yaml +++ b/github/workflows/symfony/php.yaml @@ -1,5 +1,5 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/symfony-php.yaml in +# github/workflows/symfony/php.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. ### Symfony PHP diff --git a/github/workflows/twig.yaml b/github/workflows/twig.yaml index 95b0a2b4..7cff4ff7 100644 --- a/github/workflows/twig.yaml +++ b/github/workflows/twig.yaml @@ -2,7 +2,7 @@ # github/workflows/twig.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ### Twigt +### ### Twig ### ### Validates Twig files ### diff --git a/task/Tasfile.github-actions.yml b/task/Taskfile.github-actions.yml similarity index 87% rename from task/Tasfile.github-actions.yml rename to task/Taskfile.github-actions.yml index 71ccfd38..e6598c09 100644 --- a/task/Tasfile.github-actions.yml +++ b/task/Taskfile.github-actions.yml @@ -6,7 +6,7 @@ tasks: cmds: - task: run-script vars: - SCRIPT: task/github-documentation-update.sh + SCRIPT: github-documentation-update - SKIP_FIX=1 task lint:markdown -- docs/github-actions-templates.md documentation:diff: @@ -39,21 +39,21 @@ tasks: desc: "Update headers in GitHub Actions templates" cmds: - | - for f in github/workflows/*.yaml; do + for f in $(find github/workflows/ -name '*.yaml'); do echo "$f" # If file starts with `# ` … if [[ $(head --lines=1 "$f") =~ "^# " ]]; then # … replace the header. # This is done by deleting all lines from the top of the file to a blank line. - docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f" + docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest sed -i '1,/^$/d' "$f" fi # Write header and file into temporary file. ( - echo "# Do not edit this file! Make a pull request on changing"; - echo "# $f in"; - echo "# https://github.com/itk-dev/devops_itkdev-docker if need be."; - echo ""; + echo "# Do not edit this file! Make a pull request on changing" + echo "# $f in" + echo "# https://github.com/itk-dev/devops_itkdev-docker if need be." + echo "" cat "$f" ) > "$f.tmp" # Replace original file with temporary file. @@ -66,7 +66,7 @@ tasks: cmds: - task: run-script vars: - SCRIPT: task/github-actions-link.sh + SCRIPT: github-actions-link silent: true show: @@ -78,7 +78,7 @@ tasks: run-script: internal: true cmds: - - docker run --rm --volume "$PWD:/app" --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest {{.SCRIPT}} + - docker run --rm --volume "$PWD:/app" --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest task/scripts/{{.SCRIPT}} requires: vars: - SCRIPT diff --git a/task/docs/github-actions-templates.md b/task/docs/github-actions-templates.md new file mode 100644 index 00000000..f7ce5f7a --- /dev/null +++ b/task/docs/github-actions-templates.md @@ -0,0 +1,24 @@ + +# Github Actions templates + +This repository contains a number of [GitHub Actions](https://docs.github.com/en/actions) workflow template files that +are copied to a project when running `itkdev-docker-compose template:install`. Any changes to the workflows should be +made in [this repository](https://github.com/itk-dev/devops_itkdev-docker) and then the project template must be updated +to match the new templates. + +## Naming conventions + +* Named after what a tool is concerned with, not how it's concerned with it. +* Some configuration based on template type (drupal, symfony) + +## Templates + +--- + +[github/workflows/*.yaml](github/workflows/*.yaml) + + +--- diff --git a/task/github-documentation-update.sh b/task/github-documentation-update.sh deleted file mode 100755 index c6e181ed..00000000 --- a/task/github-documentation-update.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash -# set -o errexit -o errtrace -o noclobber -o nounset -o pipefail -# IFS=$'\n\t' - -script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -project_dir=$(cd "$(dirname "$script_dir")" && pwd) - -cd "$project_dir" || exit - -template_file_name="$script_dir/github-actions-templates.md" - -place_holder="insert:templates:here" -place_holder_line=$(grep --line-number --no-filename "$place_holder" task/github-actions-templates.md | cut -d: -f1) - -if [[ -z "$place_holder_line" ]]; then - (>&2 echo "Cannot find placeholder $place_holder in $template_file_name") - exit 1 -fi - -output_file_name="docs/$(basename "$template_file_name")" - -mkdir -p "$(dirname "$output_file_name")" - -# Empty the output file -: >| "$output_file_name" - -cat >> "$output_file_name" < -EOF - -# Template content before place holder -head --lines="$((place_holder_line-1))" "$template_file_name" >> "$output_file_name" - -for f in github/workflows/*.yaml; do - # Separator - cat >> "$output_file_name" <> "$output_file_name" -done - -# Template content after place holder -tail --lines="+$((place_holder_line+1))" "$template_file_name" >> "$output_file_name" - -echo "$output_file_name" diff --git a/task/links.png b/task/links.png deleted file mode 100644 index a9af4562d35ebfa449166c3931bcafd7468a4f36..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5257 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 "$mermaid_file_name" <<'EOF' -graph TD -EOF -for link in $(find templates -type l); do - link_id=$(base64 <<< $link) - link_id=${link_id//=} - - target=$(readlink $link) - target_id=$(base64 <<< $target) - target_id=${target_id//=} - echo " $link_id[$link] --> $target_id[$target]" >> "$mermaid_file_name" -done diff --git a/task/scripts/github-documentation-update b/task/scripts/github-documentation-update new file mode 100755 index 00000000..7822d8d1 --- /dev/null +++ b/task/scripts/github-documentation-update @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# set -o errexit -o errtrace -o noclobber -o nounset -o pipefail +# IFS=$'\n\t' + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +project_dir=$(cd "$(dirname "$script_dir")/.." && pwd) + +cd "$project_dir" || exit + +template_file_name="$script_dir/../templates/github-actions-templates.md" + +placeholder="insert:templates:here" +placeholder_line=$(grep --line-number --no-filename "$placeholder" "$template_file_name" | cut -d: -f1) + +if [[ -z "$placeholder_line" ]]; then + (>&2 echo "Cannot find placeholder $placeholder in $template_file_name") + exit 1 +fi + +output_file_name="docs/$(basename "$template_file_name")" + +mkdir -p "$(dirname "$output_file_name")" + +# Empty the output file +: >| "$output_file_name" + +cat >> "$output_file_name" < +EOF + +# Template content before placeholder +head --lines="$((placeholder_line-1))" "$template_file_name" >> "$output_file_name" + +for f in $(find github/workflows/ -name '*.yaml' | sort); do + # Separator + cat >> "$output_file_name" <> "$output_file_name" +done + +# Template content after placeholder without any leading blank lines (cf. +# https://stackoverflow.com/a/7359879) +tail --lines="+$((placeholder_line+1))" "$template_file_name" | sed '/./,$!d' >> "$output_file_name" + +echo "$output_file_name" diff --git a/task/github-actions-templates.md b/task/templates/github-actions-templates.md similarity index 99% rename from task/github-actions-templates.md rename to task/templates/github-actions-templates.md index 48063169..94dca584 100644 --- a/task/github-actions-templates.md +++ b/task/templates/github-actions-templates.md @@ -11,6 +11,7 @@ to match the new templates. * Some configuration based on template type (drupal, symfony) ## Templates + --- diff --git a/templates/drupal-10/.github/workflows/php.yaml b/templates/drupal-10/.github/workflows/php.yaml index ec1343e4..9367a866 120000 --- a/templates/drupal-10/.github/workflows/php.yaml +++ b/templates/drupal-10/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-php.yaml \ No newline at end of file +../../../../github/workflows/drupal/php.yaml \ No newline at end of file diff --git a/templates/drupal-10/.github/workflows/site.yaml b/templates/drupal-10/.github/workflows/site.yaml index 3ce13d08..001dbf2c 120000 --- a/templates/drupal-10/.github/workflows/site.yaml +++ b/templates/drupal-10/.github/workflows/site.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-site.yaml \ No newline at end of file +../../../../github/workflows/drupal/site.yaml \ No newline at end of file diff --git a/templates/drupal-10/.phpcs.xml.dist b/templates/drupal-10/.phpcs.xml.dist new file mode 120000 index 00000000..17295906 --- /dev/null +++ b/templates/drupal-10/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-7/.github/workflows/php.yaml b/templates/drupal-7/.github/workflows/php.yaml index ec1343e4..9367a866 120000 --- a/templates/drupal-7/.github/workflows/php.yaml +++ b/templates/drupal-7/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-php.yaml \ No newline at end of file +../../../../github/workflows/drupal/php.yaml \ No newline at end of file diff --git a/templates/drupal-7/.github/workflows/site.yaml b/templates/drupal-7/.github/workflows/site.yaml index 3ce13d08..001dbf2c 120000 --- a/templates/drupal-7/.github/workflows/site.yaml +++ b/templates/drupal-7/.github/workflows/site.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-site.yaml \ No newline at end of file +../../../../github/workflows/drupal/site.yaml \ No newline at end of file diff --git a/templates/drupal-7/.phpcs.xml.dist b/templates/drupal-7/.phpcs.xml.dist new file mode 120000 index 00000000..17295906 --- /dev/null +++ b/templates/drupal-7/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-8/.github/workflows/php.yaml b/templates/drupal-8/.github/workflows/php.yaml index ec1343e4..9367a866 120000 --- a/templates/drupal-8/.github/workflows/php.yaml +++ b/templates/drupal-8/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-php.yaml \ No newline at end of file +../../../../github/workflows/drupal/php.yaml \ No newline at end of file diff --git a/templates/drupal-8/.github/workflows/site.yaml b/templates/drupal-8/.github/workflows/site.yaml index 3ce13d08..001dbf2c 120000 --- a/templates/drupal-8/.github/workflows/site.yaml +++ b/templates/drupal-8/.github/workflows/site.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-site.yaml \ No newline at end of file +../../../../github/workflows/drupal/site.yaml \ No newline at end of file diff --git a/templates/drupal-8/.phpcs.xml.dist b/templates/drupal-8/.phpcs.xml.dist new file mode 120000 index 00000000..17295906 --- /dev/null +++ b/templates/drupal-8/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-9/.github/workflows/php.yaml b/templates/drupal-9/.github/workflows/php.yaml index ec1343e4..9367a866 120000 --- a/templates/drupal-9/.github/workflows/php.yaml +++ b/templates/drupal-9/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-php.yaml \ No newline at end of file +../../../../github/workflows/drupal/php.yaml \ No newline at end of file diff --git a/templates/drupal-9/.github/workflows/site.yaml b/templates/drupal-9/.github/workflows/site.yaml index 3ce13d08..001dbf2c 120000 --- a/templates/drupal-9/.github/workflows/site.yaml +++ b/templates/drupal-9/.github/workflows/site.yaml @@ -1 +1 @@ -../../../../github/workflows/drupal-site.yaml \ No newline at end of file +../../../../github/workflows/drupal/site.yaml \ No newline at end of file diff --git a/templates/drupal-9/.phpcs.xml.dist b/templates/drupal-9/.phpcs.xml.dist new file mode 120000 index 00000000..17295906 --- /dev/null +++ b/templates/drupal-9/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/symfony-3/.github/workflows/php.yaml b/templates/symfony-3/.github/workflows/php.yaml index 6e3ebf61..e5388fe1 120000 --- a/templates/symfony-3/.github/workflows/php.yaml +++ b/templates/symfony-3/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/symfony-php.yaml \ No newline at end of file +../../../../github/workflows/symfony/php.yaml \ No newline at end of file diff --git a/templates/symfony-3/.php-cs-fixer.dist.php b/templates/symfony-3/.php-cs-fixer.dist.php new file mode 120000 index 00000000..4527ff86 --- /dev/null +++ b/templates/symfony-3/.php-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/symfony/php/.php-cs-fixer.dist.php \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/php.yaml b/templates/symfony-4/.github/workflows/php.yaml index 6e3ebf61..e5388fe1 120000 --- a/templates/symfony-4/.github/workflows/php.yaml +++ b/templates/symfony-4/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/symfony-php.yaml \ No newline at end of file +../../../../github/workflows/symfony/php.yaml \ No newline at end of file diff --git a/templates/symfony-4/.php-cs-fixer.dist.php b/templates/symfony-4/.php-cs-fixer.dist.php new file mode 120000 index 00000000..4527ff86 --- /dev/null +++ b/templates/symfony-4/.php-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/symfony/php/.php-cs-fixer.dist.php \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/php.yaml b/templates/symfony-6/.github/workflows/php.yaml index 6e3ebf61..e5388fe1 120000 --- a/templates/symfony-6/.github/workflows/php.yaml +++ b/templates/symfony-6/.github/workflows/php.yaml @@ -1 +1 @@ -../../../../github/workflows/symfony-php.yaml \ No newline at end of file +../../../../github/workflows/symfony/php.yaml \ No newline at end of file diff --git a/templates/symfony-6/.php-cs-fixer.dist.php b/templates/symfony-6/.php-cs-fixer.dist.php new file mode 120000 index 00000000..4527ff86 --- /dev/null +++ b/templates/symfony-6/.php-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/symfony/php/.php-cs-fixer.dist.php \ No newline at end of file From aa66060025e0219ccf6103b55d2824a088215b33 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 12:47:28 +0200 Subject: [PATCH 13/34] Added config file headers --- config/drupal/php/.phpcs.xml.dist | 3 +++ config/drupal/twig/.twig-cs-fixer.dist.php | 3 +++ config/markdown/.markdownlint.jsonc | 3 +++ config/markdown/.markdownlintignore | 3 +++ config/symfony/php/.php-cs-fixer.dist.php | 3 +++ config/symfony/twig/.twig-cs-fixer.dist.php | 3 +++ task/Taskfile.github-actions.yml | 27 +++++++++++++++++++++ 7 files changed, 45 insertions(+) diff --git a/config/drupal/php/.phpcs.xml.dist b/config/drupal/php/.phpcs.xml.dist index e3edb524..70d19cda 100644 --- a/config/drupal/php/.phpcs.xml.dist +++ b/config/drupal/php/.phpcs.xml.dist @@ -1,3 +1,6 @@ + + + The coding standard. diff --git a/config/drupal/twig/.twig-cs-fixer.dist.php b/config/drupal/twig/.twig-cs-fixer.dist.php index 427f75ce..0a0f2951 100644 --- a/config/drupal/twig/.twig-cs-fixer.dist.php +++ b/config/drupal/twig/.twig-cs-fixer.dist.php @@ -1,4 +1,7 @@ "$f.tmp" + # # Replace original file with temporary file. + # mv "$f.tmp" "$f" + # done + link: desc: "Set up symlinks" prompt: "Reset all symlinks?" From b1592b3bd7605e646ccd027aed86d48f0cca5b68 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 13:15:31 +0200 Subject: [PATCH 14/34] Cleaned up tasks and shell scripts --- .github/workflows/documentation.yaml | 52 ++++++++++++++++++++++++++-- Taskfile.yml | 10 ++++++ task/Taskfile.github-actions.yml | 49 ++++---------------------- task/scripts/config-headers-update | 40 +++++++++++++++++++++ task/scripts/github-actions-link | 6 ++-- task/scripts/template-headers-update | 26 ++++++++++++++ 6 files changed, 135 insertions(+), 48 deletions(-) create mode 100755 task/scripts/config-headers-update create mode 100755 task/scripts/template-headers-update diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 6d106294..5dfad4d3 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -40,6 +40,54 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - run: | task github-actions:template-headers:update --yes - # Check that files hav not changed. + # Check that files have not changed. - run: | - git diff --exit-code github/workflows/ + git diff --exit-code + + check-config-file-headers: + runs-on: ubuntu-latest + name: Check that config file headers are up to date + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + task github-actions:config-headers:update --yes + # Check that files have not changed. + - run: | + git diff --exit-code + + check-links: + runs-on: ubuntu-latest + name: Check that workflow and config file links are up to date + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + task github-actions:link --yes + # Check that files have not changed. + - run: | + git diff --exit-code + + lint-markdown: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + SKIP_FIX=1 task lint:markdown + + lint-shell-script: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + SKIP_FIX=1 task lint:shell-script diff --git a/Taskfile.yml b/Taskfile.yml index 9a621dc0..54c3f828 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -29,6 +29,16 @@ tasks: GLOB: >- {{.CLI_ARGS | default "'**/*.md'"}} + lint:shell-script: + desc: "Lint shell scripts" + cmds: + # https://github.com/koalaman/shellcheck?tab=readme-ov-file#installing + - docker run --rm --volume "$PWD:"/mnt koalaman/shellcheck:stable {{.GLOB}} + vars: + # We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier. + GLOB: >- + {{.CLI_ARGS | default "task/scripts/*"}} + default: cmds: - task --list diff --git a/task/Taskfile.github-actions.yml b/task/Taskfile.github-actions.yml index c67a21ab..1f5df23e 100644 --- a/task/Taskfile.github-actions.yml +++ b/task/Taskfile.github-actions.yml @@ -38,54 +38,17 @@ tasks: prompt: "Updating headers may break things, so check result afterwards. Really update headers?" desc: "Update headers in GitHub Actions templates" cmds: - - | - for f in $(find github/workflows/ -name '*.yaml'); do - echo "$f" - # If file starts with `# ` … - if [[ $(head --lines=1 "$f") =~ "^# " ]]; then - # … replace the header. - # This is done by deleting all lines from the top of the file to a blank line. - docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest sed -i '1,/^$/d' "$f" - fi - - # Write header and file into temporary file. - ( - echo "# Do not edit this file! Make a pull request on changing" - echo "# $f in" - echo "# https://github.com/itk-dev/devops_itkdev-docker if need be." - echo "" - cat "$f" - ) > "$f.tmp" - # Replace original file with temporary file. - mv "$f.tmp" "$f" - done + - task: run-script + vars: + SCRIPT: template-headers-update config-headers:update: prompt: "Updating headers may break things, so check result afterwards. Really update headers?" desc: "Update headers in tool config" cmds: - - 'echo TODO: implement {{.TASK}}' - # - | - # for f in $(find config -type f); do - # echo "$f" - # # # If file starts with `# ` … - # # if [[ $(head --lines=1 "$f") =~ "^# " ]]; then - # # # … replace the header. - # # # This is done by deleting all lines from the top of the file to a blank line. - # # docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest sed -i '1,/^$/d' "$f" - # # fi - - # # Write header and file into temporary file. - # ( - # echo "# This file is copied from $f in https://github.com/itk-dev/devops_itkdev-docker." - # echo "#" - # echo "# Feel free to edit the file, but consider making a pull request if you find a general issue with the file." - # echo "" - # cat "$f" - # ) > "$f.tmp" - # # Replace original file with temporary file. - # mv "$f.tmp" "$f" - # done + - task: run-script + vars: + SCRIPT: config-headers-update link: desc: "Set up symlinks" diff --git a/task/scripts/config-headers-update b/task/scripts/config-headers-update new file mode 100755 index 00000000..16e1538a --- /dev/null +++ b/task/scripts/config-headers-update @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +project_dir=$(cd "$(dirname "$script_dir")/.." && pwd) + +cd "$project_dir" || exit + +# shellcheck disable=SC2044 +for f in $(find config -type f); do + echo "$f" + + # Remove exiting header. + # This is done by deleting all lines from the top of the file to a blank line. + sed -i '1,/^$/d' "$f" + + comment_prefix='' + comment_start='# ' + comment_end='' + if [[ "$f" =~ \.php(\.dist)?$ ]]; then + comment_prefix='' + fi + # Write header and file into temporary file. + ( + [[ -n "${comment_prefix}" ]] && echo "${comment_prefix}" + echo "${comment_start}This file is copied from $f in https://github.com/itk-dev/devops_itkdev-docker.${comment_end}" + echo "${comment_start}Feel free to edit the file, but consider making a pull request if you find a general issue with the file.${comment_end}" + echo "" + cat "$f" + ) > "$f.tmp" + # Replace original file with temporary file. + mv "$f.tmp" "$f" +done diff --git a/task/scripts/github-actions-link b/task/scripts/github-actions-link index 46c27d01..5b71f4c5 100755 --- a/task/scripts/github-actions-link +++ b/task/scripts/github-actions-link @@ -15,7 +15,7 @@ function strip-project-type() { name="${BASH_REMATCH[2]}" fi - echo $name + echo "$name" } find templates -type l -delete @@ -41,11 +41,11 @@ for template_dir in templates/*; do # Note: / is NOT a regex delimiter here, but an actual /, i.e. a directory separator. if [[ "$f" =~ /drupal/ ]]; then if [[ "$project_type" == "drupal" ]]; then - source_file_name="$(basename $(dirname "$f"))/$(basename "$f")" + source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" fi elif [[ "$f" =~ /symfony/ ]]; then if [[ "$project_type" == "symfony" ]]; then - source_file_name="$(basename $(dirname "$f"))/$(basename "$f")" + source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" fi else source_file_name=$(basename "$f") diff --git a/task/scripts/template-headers-update b/task/scripts/template-headers-update new file mode 100755 index 00000000..1e3ade3d --- /dev/null +++ b/task/scripts/template-headers-update @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +project_dir=$(cd "$(dirname "$script_dir")/.." && pwd) + +cd "$project_dir" || exit + +# shellcheck disable=SC2044 +for f in $(find github/workflows/ -name '*.yaml'); do + echo "$f" + + # Remove exiting header. + # This is done by deleting all lines from the top of the file to a blank line. + sed -i '1,/^$/d' "$f" + + # Write header and file into temporary file. + ( + echo "# Do not edit this file! Make a pull request on changing" + echo "# $f in" + echo "# https://github.com/itk-dev/devops_itkdev-docker if need be." + echo "" + cat "$f" + ) > "$f.tmp" + # Replace original file with temporary file. + mv "$f.tmp" "$f" +done From 0bd7408ea0e0833c0b0048aa261168c10111f8c7 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 13:31:40 +0200 Subject: [PATCH 15/34] Updated GitHub Actions template documentation --- docs/github-actions-templates.md | 12 +++++++++--- task/templates/github-actions-templates.md | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index 9c738b55..b7126b60 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ # Github Actions templates @@ -11,8 +11,14 @@ to match the new templates. ## Naming conventions -* Named after what a tool is concerned with, not how it's concerned with it. -* Some configuration based on template type (drupal, symfony) +* A workflow file is named after what it is _concerned_ with, not _how_ it's concerned with it and which tools are + actually used, i.e. we have a [`markdown.yaml`](github/workflows/markdown.yaml) file and not a `markdownlint.yaml` + file. +* Some workflows are specific to a project type, currently `drupal` or `symfony`, and these sit in a project type + subfolder, e.g. `github/workflows/drupal`. +* Some tools require configuration files, and these sit in the `config` folder. Some tool configuration may be specific + to a project type (or make sence only for a specific project type), and these specific config files sit in a project + type subfolder, e.g. `config/drupal/php/.phpcs.xml.dist` and `config/drupal/twig/.twig-cs-fixer.dist.php` ## Templates diff --git a/task/templates/github-actions-templates.md b/task/templates/github-actions-templates.md index 94dca584..d9c0b0d7 100644 --- a/task/templates/github-actions-templates.md +++ b/task/templates/github-actions-templates.md @@ -7,8 +7,14 @@ to match the new templates. ## Naming conventions -* Named after what a tool is concerned with, not how it's concerned with it. -* Some configuration based on template type (drupal, symfony) +* A workflow file is named after what it is _concerned_ with, not _how_ it's concerned with it and which tools are + actually used, i.e. we have a [`markdown.yaml`](github/workflows/markdown.yaml) file and not a `markdownlint.yaml` + file. +* Some workflows are specific to a project type, currently `drupal` or `symfony`, and these sit in a project type + subfolder, e.g. `github/workflows/drupal`. +* Some tools require configuration files, and these sit in the `config` folder. Some tool configuration may be specific + to a project type (or make sence only for a specific project type), and these specific config files sit in a project + type subfolder, e.g. `config/drupal/php/.phpcs.xml.dist` and `config/drupal/twig/.twig-cs-fixer.dist.php` ## Templates From 3e30132a95d987fd03f9e02d9bc5f4b95aee7f57 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 9 Apr 2025 11:30:41 +0200 Subject: [PATCH 16/34] More documentation and cleanup --- README.md | 14 +++-- config/drupal/php/.phpcs.xml.dist | 5 +- docs/github-actions-templates.md | 67 ++++++++++++++++++++-- github/workflows/drupal/php.yaml | 49 +++++++++++++++- github/workflows/markdown.yaml | 6 +- github/workflows/symfony/php.yaml | 2 +- task/scripts/config-headers-update | 1 + task/scripts/github-documentation-update | 4 +- task/templates/github-actions-templates.md | 26 +++++++++ 9 files changed, 158 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6470e6e6..c6244b14 100644 --- a/README.md +++ b/README.md @@ -47,14 +47,20 @@ brew install dory ### Templates The [`templates`](templates/) directory contains templates for adding -the itkdev `docker-compose` setup to new or exiting projects. +the itkdev `docker compose` setup to new or exiting projects. + +Run ```sh -rsync -avz templates// +itkdev-docker-compose template:install --list ``` -Also create an `.env` file beside the `docker-compose.yml` file that contains -`COMPOSE_PROJECT_NAME=` to namespace the docker setup for the projekt. +to see a list of all templates. + +Run `itkdev-docker-compose template:install drupal-10`, say, to install or update a template in a project. + +In addition to the docker compose setup for our projects, installing a template will also add GitHib Actions workflow +files to a project; see [Github Actions templates](docs/github-actions-templates.md) for details. ### Docker commands diff --git a/config/drupal/php/.phpcs.xml.dist b/config/drupal/php/.phpcs.xml.dist index 70d19cda..c8f54bd8 100644 --- a/config/drupal/php/.phpcs.xml.dist +++ b/config/drupal/php/.phpcs.xml.dist @@ -1,11 +1,12 @@ + - The coding standard. - web/*/custom/ + web/modules/custom/ + web/themes/custom/ node_modules diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index b7126b60..94e02d87 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,8 @@ # Github Actions templates @@ -22,6 +24,8 @@ to match the new templates. ## Templates +The current list of templates is shown in the following sections. + --- [github/workflows/changelog.yaml](github/workflows/changelog.yaml) @@ -59,7 +63,34 @@ Validates composer.json and checks that it's normalized. [github/workflows/drupal/php.yaml](github/workflows/drupal/php.yaml) -Drupal PHP +### Drupal PHP + +Checks that PHP code adheres to the [Drupal coding +standards](https://www.drupal.org/docs/develop/standards). + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. [drupal/coder](https://www.drupal.org/project/coder) is a dev requirement +in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev drupal/coder + ``` + + Clean up and check code by running + + ``` shell + docker compose run --rm phpfpm vendor/bin/phpcbf + docker compose run --rm phpfpm vendor/bin/phpcs + ``` + +> [!NOTE] +> The template adds `.phpcs.xml.dist` as [a configuration file for +> PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) +> and this makes it possible to override the actual configuration used in a +> project by adding a more important configuration file, e.g. `.phpcs.xml`. --- @@ -92,8 +123,10 @@ JavaScript (and TypeScript) Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to link all Markdown files (`**/*.md`) in the project. -[markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), -`.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. +[markdownlint-cli configuration +files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +`.markdownlint.jsonc` and `.markdownlintignore`, control what is actually +linted and how. --- @@ -105,7 +138,7 @@ Styles (CSS and SCSS) [github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml) -Symfony PHP +### Symfony PHP --- @@ -131,3 +164,27 @@ Validates Twig files in the root of the project defines which files to check and rules to use. --- + +## Updating template documentation + +To update this document, run + +``` shell +task github-actions:documentation:update +``` + +### GitHub Actions workflow documentation convention + +Each workflow file must contain a single documentation block with lines starting with `###`, e.g. + +``` markdown +### ### The title +### +### This template … +### +### See … for details. +``` + +> [!IMPORTANT] +> All lines in the documentation block must start with `###` and the documentation block consists of all consecutive +> lines starting with `###`. diff --git a/github/workflows/drupal/php.yaml b/github/workflows/drupal/php.yaml index 21722fb9..b0d3ac76 100644 --- a/github/workflows/drupal/php.yaml +++ b/github/workflows/drupal/php.yaml @@ -2,4 +2,51 @@ # github/workflows/drupal/php.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### Drupal PHP +### ### Drupal PHP +### +### Checks that PHP code adheres to the [Drupal coding +### standards](https://www.drupal.org/docs/develop/standards). +### +### #### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. +### 2. [drupal/coder](https://www.drupal.org/project/coder) is a dev requirement +### in `composer.json`: +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev drupal/coder +### ``` +### +### Clean up and check code by running +### +### ``` shell +### docker compose run --rm phpfpm vendor/bin/phpcbf +### docker compose run --rm phpfpm vendor/bin/phpcs +### ``` +### +### > [!NOTE] +### > The template adds `.phpcs.xml.dist` as [a configuration file for +### > PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) +### > and this makes it possible to override the actual configuration used in a +### > project by adding a more important configuration file, e.g. `.phpcs.xml`. + +name: PHP + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + +jobs: + coding-standards: + name: PHP - Check Coding Standards + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer install + docker compose run --rm phpfpm vendor/bin/phpcs diff --git a/github/workflows/markdown.yaml b/github/workflows/markdown.yaml index b490284b..c62b17f6 100644 --- a/github/workflows/markdown.yaml +++ b/github/workflows/markdown.yaml @@ -7,8 +7,10 @@ ### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to ### link all Markdown files (`**/*.md`) in the project. ### -### [markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), -### `.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. +### [markdownlint-cli configuration +### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +### `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually +### linted and how. name: Markdown diff --git a/github/workflows/symfony/php.yaml b/github/workflows/symfony/php.yaml index a567fa8a..9245f783 100644 --- a/github/workflows/symfony/php.yaml +++ b/github/workflows/symfony/php.yaml @@ -2,4 +2,4 @@ # github/workflows/symfony/php.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### Symfony PHP +### ### Symfony PHP diff --git a/task/scripts/config-headers-update b/task/scripts/config-headers-update index 16e1538a..035f27df 100755 --- a/task/scripts/config-headers-update +++ b/task/scripts/config-headers-update @@ -24,6 +24,7 @@ for f in $(find config -type f); do comment_start='// ' comment_end='' elif [[ "$f" =~ \.xml(\.dist)?$ ]]; then + comment_prefix='' comment_start='' fi diff --git a/task/scripts/github-documentation-update b/task/scripts/github-documentation-update index 7822d8d1..6eb978d7 100755 --- a/task/scripts/github-documentation-update +++ b/task/scripts/github-documentation-update @@ -27,7 +27,9 @@ mkdir -p "$(dirname "$output_file_name")" cat >> "$output_file_name" < EOF diff --git a/task/templates/github-actions-templates.md b/task/templates/github-actions-templates.md index d9c0b0d7..078b0354 100644 --- a/task/templates/github-actions-templates.md +++ b/task/templates/github-actions-templates.md @@ -18,6 +18,32 @@ to match the new templates. ## Templates +The current list of templates is shown in the following sections. + --- + +## Updating template documentation + +To update this document, run + +``` shell +task github-actions:documentation:update +``` + +### GitHub Actions workflow documentation convention + +Each workflow file must contain a single documentation block with lines starting with `###`, e.g. + +``` markdown +### ### The title +### +### This template … +### +### See … for details. +``` + +> [!IMPORTANT] +> All lines in the documentation block must start with `###` and the documentation block consists of all consecutive +> lines starting with `###`. From 739e661f5c72f66388bd52136ab39f8b74fd0191 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 23 Apr 2025 13:16:57 +0200 Subject: [PATCH 17/34] Added branches to on.push event --- github/workflows/composer.yaml | 3 +++ github/workflows/drupal/php.yaml | 3 +++ github/workflows/drupal/site.yaml | 3 +++ github/workflows/markdown.yaml | 3 +++ github/workflows/twig.yaml | 3 +++ 5 files changed, 15 insertions(+) diff --git a/github/workflows/composer.yaml b/github/workflows/composer.yaml index 4586cbc7..fe133512 100644 --- a/github/workflows/composer.yaml +++ b/github/workflows/composer.yaml @@ -31,6 +31,9 @@ env: on: pull_request: push: + branches: + - main + - develop jobs: composer-validate: diff --git a/github/workflows/drupal/php.yaml b/github/workflows/drupal/php.yaml index b0d3ac76..1bd5a93a 100644 --- a/github/workflows/drupal/php.yaml +++ b/github/workflows/drupal/php.yaml @@ -39,6 +39,9 @@ env: on: pull_request: push: + branches: + - main + - develop jobs: coding-standards: diff --git a/github/workflows/drupal/site.yaml b/github/workflows/drupal/site.yaml index 3a5328bd..6e92636b 100644 --- a/github/workflows/drupal/site.yaml +++ b/github/workflows/drupal/site.yaml @@ -23,6 +23,9 @@ env: on: pull_request: push: + branches: + - main + - develop jobs: install-site: diff --git a/github/workflows/markdown.yaml b/github/workflows/markdown.yaml index c62b17f6..5a951fa4 100644 --- a/github/workflows/markdown.yaml +++ b/github/workflows/markdown.yaml @@ -17,6 +17,9 @@ name: Markdown on: pull_request: push: + branches: + - main + - develop jobs: markdown-lint: diff --git a/github/workflows/twig.yaml b/github/workflows/twig.yaml index 7cff4ff7..9b0e3431 100644 --- a/github/workflows/twig.yaml +++ b/github/workflows/twig.yaml @@ -29,6 +29,9 @@ env: on: pull_request: push: + branches: + - main + - develop jobs: twig-lint: From 6729f6ada113462a963e77a3afc96d34705ed101 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 11:07:36 +0200 Subject: [PATCH 18/34] Added Drupal styles workflow --- docs/github-actions-templates.md | 21 +++++++++++------ github/workflows/drupal/styles.yaml | 36 +++++++++++++++++++++++++++++ github/workflows/styles.yaml | 5 ---- 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 github/workflows/drupal/styles.yaml delete mode 100644 github/workflows/styles.yaml diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index 94e02d87..d1a82530 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -110,6 +110,19 @@ pull request). --- +[github/workflows/drupal/styles.yaml](github/workflows/drupal/styles.yaml) + +### Styles (CSS and SCSS) + +Validates styles files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +--- + [github/workflows/javascript.yaml](github/workflows/javascript.yaml) JavaScript (and TypeScript) @@ -130,12 +143,6 @@ linted and how. --- -[github/workflows/styles.yaml](github/workflows/styles.yaml) - -Styles (CSS and SCSS) - ---- - [github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml) ### Symfony PHP diff --git a/github/workflows/drupal/styles.yaml b/github/workflows/drupal/styles.yaml new file mode 100644 index 00000000..cd944499 --- /dev/null +++ b/github/workflows/drupal/styles.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/styles.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Styles (CSS and SCSS) +### +### Validates styles files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: Styles + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + styles-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'web/themes/custom/**/css/**/*.css' --check diff --git a/github/workflows/styles.yaml b/github/workflows/styles.yaml deleted file mode 100644 index 7f4e1d62..00000000 --- a/github/workflows/styles.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# Do not edit this file! Make a pull request on changing -# github/workflows/styles.yaml in -# https://github.com/itk-dev/devops_itkdev-docker if need be. - -### Styles (CSS and SCSS) From fb43f0311e96cd2c4c74dbd30b15051531de5413 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 11:35:36 +0200 Subject: [PATCH 19/34] Checked YAML files --- .github/workflows/workflow-template.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/workflow-template.yaml diff --git a/.github/workflows/workflow-template.yaml b/.github/workflows/workflow-template.yaml new file mode 100644 index 00000000..c2f0d12b --- /dev/null +++ b/.github/workflows/workflow-template.yaml @@ -0,0 +1,15 @@ +on: pull_request + +name: Workflow templates + +jobs: + check-yaml: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - run: | + docker pull mikefarah/yq + for f in $(find github/workflows/ -name '*.yaml'); do + docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" + done From 85f853a8a05d7e4ae5cb59884f067b70e81a7193 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 13:42:02 +0200 Subject: [PATCH 20/34] Cleaned up --- .github/workflows/workflow-template.yaml | 2 +- Taskfile.yml | 9 +++++++++ github/workflows/drupal/site.yaml | 5 +++-- task/docs/github-actions-templates.md | 1 - 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow-template.yaml b/.github/workflows/workflow-template.yaml index c2f0d12b..74a0ffa1 100644 --- a/.github/workflows/workflow-template.yaml +++ b/.github/workflows/workflow-template.yaml @@ -11,5 +11,5 @@ jobs: - run: | docker pull mikefarah/yq for f in $(find github/workflows/ -name '*.yaml'); do - docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" + docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" > /dev/null done diff --git a/Taskfile.yml b/Taskfile.yml index 54c3f828..0fe253df 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -39,6 +39,15 @@ tasks: GLOB: >- {{.CLI_ARGS | default "task/scripts/*"}} + lint:yaml: + desc: "Lint YAML" + cmds: + - | + # docker pull mikefarah/yq + for f in $(find github/workflows/ -name '*.yaml'); do + docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" > /dev/null + done + default: cmds: - task --list diff --git a/github/workflows/drupal/site.yaml b/github/workflows/drupal/site.yaml index 6e92636b..70561cba 100644 --- a/github/workflows/drupal/site.yaml +++ b/github/workflows/drupal/site.yaml @@ -11,8 +11,9 @@ ### ### 1. A docker compose service named `phpfpm` can be run and `composer` can be ### run inside the `phpfpm` service. -### 2. The docker setup contains a database container and other the dependent services and the - default settings match connection credentials for these services. +### 2. The docker setup contains a database container and other the dependent +### services and the default settings match connection credentials for these +### services. ### 3. The Drupal site can be installed from existing config. name: Drupal diff --git a/task/docs/github-actions-templates.md b/task/docs/github-actions-templates.md index f7ce5f7a..e2fad1bb 100644 --- a/task/docs/github-actions-templates.md +++ b/task/docs/github-actions-templates.md @@ -20,5 +20,4 @@ to match the new templates. [github/workflows/*.yaml](github/workflows/*.yaml) - --- From 8c69076ddc69e1dd36ec66ffbc5db1a04b7f1e3e Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 13:48:56 +0200 Subject: [PATCH 21/34] Updated workflow files --- Taskfile.yml | 8 ++++++++ docs/github-actions-templates.md | 6 ++++-- github/workflows/drupal/styles.yaml | 2 +- templates/drupal-10/.github/workflows/styles.yaml | 2 +- templates/drupal-11/.github/workflows/changelog.yaml | 1 + templates/drupal-11/.github/workflows/composer.yaml | 1 + templates/drupal-11/.github/workflows/javascript.yaml | 1 + templates/drupal-11/.github/workflows/markdown.yaml | 1 + templates/drupal-11/.github/workflows/php.yaml | 1 + templates/drupal-11/.github/workflows/site.yaml | 1 + templates/drupal-11/.github/workflows/styles.yaml | 1 + templates/drupal-11/.github/workflows/twig.yaml | 1 + templates/drupal-11/.markdownlint.jsonc | 1 + templates/drupal-11/.markdownlintignore | 1 + templates/drupal-11/.phpcs.xml.dist | 1 + templates/drupal-11/.twig-cs-fixer.dist.php | 1 + templates/drupal-7/.github/workflows/styles.yaml | 2 +- templates/drupal-8/.github/workflows/styles.yaml | 2 +- templates/drupal-9/.github/workflows/styles.yaml | 2 +- templates/symfony-3/.github/workflows/styles.yaml | 1 - templates/symfony-4/.github/workflows/styles.yaml | 1 - templates/symfony-6/.github/workflows/styles.yaml | 1 - 22 files changed, 29 insertions(+), 10 deletions(-) create mode 120000 templates/drupal-11/.github/workflows/changelog.yaml create mode 120000 templates/drupal-11/.github/workflows/composer.yaml create mode 120000 templates/drupal-11/.github/workflows/javascript.yaml create mode 120000 templates/drupal-11/.github/workflows/markdown.yaml create mode 120000 templates/drupal-11/.github/workflows/php.yaml create mode 120000 templates/drupal-11/.github/workflows/site.yaml create mode 120000 templates/drupal-11/.github/workflows/styles.yaml create mode 120000 templates/drupal-11/.github/workflows/twig.yaml create mode 120000 templates/drupal-11/.markdownlint.jsonc create mode 120000 templates/drupal-11/.markdownlintignore create mode 120000 templates/drupal-11/.phpcs.xml.dist create mode 120000 templates/drupal-11/.twig-cs-fixer.dist.php delete mode 120000 templates/symfony-3/.github/workflows/styles.yaml delete mode 120000 templates/symfony-4/.github/workflows/styles.yaml delete mode 120000 templates/symfony-6/.github/workflows/styles.yaml diff --git a/Taskfile.yml b/Taskfile.yml index 0fe253df..6f2c9903 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -19,6 +19,14 @@ vars: GITHUB_ACTIONS_TEMPLATES_FOOTER: | tasks: + build: + desc: "Build everything" + cmds: + - task: github-actions:documentation:update + - task: github-actions:link + - task: lint:markdown + - task: lint:yaml + lint:markdown: desc: "Lint Markdown" cmds: diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index d1a82530..aa30f7ce 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -105,7 +105,9 @@ pull request). 1. A docker compose service named `phpfpm` can be run and `composer` can be run inside the `phpfpm` service. -2. The docker setup contains a database container and other the dependent services and the +2. The docker setup contains a database container and other the dependent + services and the default settings match connection credentials for these + services. 3. The Drupal site can be installed from existing config. --- diff --git a/github/workflows/drupal/styles.yaml b/github/workflows/drupal/styles.yaml index cd944499..f10bbcf3 100644 --- a/github/workflows/drupal/styles.yaml +++ b/github/workflows/drupal/styles.yaml @@ -1,5 +1,5 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/styles.yaml in +# github/workflows/drupal/styles.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. ### ### Styles (CSS and SCSS) diff --git a/templates/drupal-10/.github/workflows/styles.yaml b/templates/drupal-10/.github/workflows/styles.yaml index 020b58bd..b3e30b71 120000 --- a/templates/drupal-10/.github/workflows/styles.yaml +++ b/templates/drupal-10/.github/workflows/styles.yaml @@ -1 +1 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file +../../../../github/workflows/drupal/styles.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/changelog.yaml b/templates/drupal-11/.github/workflows/changelog.yaml new file mode 120000 index 00000000..5ffe5c3c --- /dev/null +++ b/templates/drupal-11/.github/workflows/changelog.yaml @@ -0,0 +1 @@ +../../../../github/workflows/changelog.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/composer.yaml b/templates/drupal-11/.github/workflows/composer.yaml new file mode 120000 index 00000000..23955648 --- /dev/null +++ b/templates/drupal-11/.github/workflows/composer.yaml @@ -0,0 +1 @@ +../../../../github/workflows/composer.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/javascript.yaml b/templates/drupal-11/.github/workflows/javascript.yaml new file mode 120000 index 00000000..b272c00b --- /dev/null +++ b/templates/drupal-11/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/markdown.yaml b/templates/drupal-11/.github/workflows/markdown.yaml new file mode 120000 index 00000000..ab3eafad --- /dev/null +++ b/templates/drupal-11/.github/workflows/markdown.yaml @@ -0,0 +1 @@ +../../../../github/workflows/markdown.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/php.yaml b/templates/drupal-11/.github/workflows/php.yaml new file mode 120000 index 00000000..9367a866 --- /dev/null +++ b/templates/drupal-11/.github/workflows/php.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal/php.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/site.yaml b/templates/drupal-11/.github/workflows/site.yaml new file mode 120000 index 00000000..001dbf2c --- /dev/null +++ b/templates/drupal-11/.github/workflows/site.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal/site.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/styles.yaml b/templates/drupal-11/.github/workflows/styles.yaml new file mode 120000 index 00000000..b3e30b71 --- /dev/null +++ b/templates/drupal-11/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal/styles.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/twig.yaml b/templates/drupal-11/.github/workflows/twig.yaml new file mode 120000 index 00000000..649f1cd6 --- /dev/null +++ b/templates/drupal-11/.github/workflows/twig.yaml @@ -0,0 +1 @@ +../../../../github/workflows/twig.yaml \ No newline at end of file diff --git a/templates/drupal-11/.markdownlint.jsonc b/templates/drupal-11/.markdownlint.jsonc new file mode 120000 index 00000000..1a3d9afe --- /dev/null +++ b/templates/drupal-11/.markdownlint.jsonc @@ -0,0 +1 @@ +../../config/markdown/.markdownlint.jsonc \ No newline at end of file diff --git a/templates/drupal-11/.markdownlintignore b/templates/drupal-11/.markdownlintignore new file mode 120000 index 00000000..0a61367e --- /dev/null +++ b/templates/drupal-11/.markdownlintignore @@ -0,0 +1 @@ +../../config/markdown/.markdownlintignore \ No newline at end of file diff --git a/templates/drupal-11/.phpcs.xml.dist b/templates/drupal-11/.phpcs.xml.dist new file mode 120000 index 00000000..17295906 --- /dev/null +++ b/templates/drupal-11/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-11/.twig-cs-fixer.dist.php b/templates/drupal-11/.twig-cs-fixer.dist.php new file mode 120000 index 00000000..7330065d --- /dev/null +++ b/templates/drupal-11/.twig-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/drupal/twig/.twig-cs-fixer.dist.php \ No newline at end of file diff --git a/templates/drupal-7/.github/workflows/styles.yaml b/templates/drupal-7/.github/workflows/styles.yaml index 020b58bd..b3e30b71 120000 --- a/templates/drupal-7/.github/workflows/styles.yaml +++ b/templates/drupal-7/.github/workflows/styles.yaml @@ -1 +1 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file +../../../../github/workflows/drupal/styles.yaml \ No newline at end of file diff --git a/templates/drupal-8/.github/workflows/styles.yaml b/templates/drupal-8/.github/workflows/styles.yaml index 020b58bd..b3e30b71 120000 --- a/templates/drupal-8/.github/workflows/styles.yaml +++ b/templates/drupal-8/.github/workflows/styles.yaml @@ -1 +1 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file +../../../../github/workflows/drupal/styles.yaml \ No newline at end of file diff --git a/templates/drupal-9/.github/workflows/styles.yaml b/templates/drupal-9/.github/workflows/styles.yaml index 020b58bd..b3e30b71 120000 --- a/templates/drupal-9/.github/workflows/styles.yaml +++ b/templates/drupal-9/.github/workflows/styles.yaml @@ -1 +1 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file +../../../../github/workflows/drupal/styles.yaml \ No newline at end of file diff --git a/templates/symfony-3/.github/workflows/styles.yaml b/templates/symfony-3/.github/workflows/styles.yaml deleted file mode 120000 index 020b58bd..00000000 --- a/templates/symfony-3/.github/workflows/styles.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/styles.yaml b/templates/symfony-4/.github/workflows/styles.yaml deleted file mode 120000 index 020b58bd..00000000 --- a/templates/symfony-4/.github/workflows/styles.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/styles.yaml b/templates/symfony-6/.github/workflows/styles.yaml deleted file mode 120000 index 020b58bd..00000000 --- a/templates/symfony-6/.github/workflows/styles.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file From b97b44a25b5369bb24805166ab98176f6fd25d22 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 10:21:15 +0200 Subject: [PATCH 22/34] Added Drupal JavaScript workflow --- docs/github-actions-templates.md | 23 ++++++++++------ github/workflows/drupal/javascript.yaml | 36 +++++++++++++++++++++++++ github/workflows/drupal/styles.yaml | 2 +- github/workflows/javascript.yaml | 5 ---- 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 github/workflows/drupal/javascript.yaml delete mode 100644 github/workflows/javascript.yaml diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index aa30f7ce..8aac76e0 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -61,6 +61,19 @@ Validates composer.json and checks that it's normalized. --- +[github/workflows/drupal/javascript.yaml](github/workflows/drupal/javascript.yaml) + +### Drupal JavaScript (and TypeScript) + +Validates JavaScript files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +--- + [github/workflows/drupal/php.yaml](github/workflows/drupal/php.yaml) ### Drupal PHP @@ -114,7 +127,7 @@ pull request). [github/workflows/drupal/styles.yaml](github/workflows/drupal/styles.yaml) -### Styles (CSS and SCSS) +### Drupal Styles (CSS and SCSS) Validates styles files. @@ -125,12 +138,6 @@ Validates styles files. --- -[github/workflows/javascript.yaml](github/workflows/javascript.yaml) - -JavaScript (and TypeScript) - ---- - [github/workflows/markdown.yaml](github/workflows/markdown.yaml) ### Markdown diff --git a/github/workflows/drupal/javascript.yaml b/github/workflows/drupal/javascript.yaml new file mode 100644 index 00000000..c4005a48 --- /dev/null +++ b/github/workflows/drupal/javascript.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/javascript.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Drupal JavaScript (and TypeScript) +### +### Validates JavaScript files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: JavaScript + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + javascript-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'web/themes/custom/**/js/**/*.js' --check diff --git a/github/workflows/drupal/styles.yaml b/github/workflows/drupal/styles.yaml index f10bbcf3..c94c0786 100644 --- a/github/workflows/drupal/styles.yaml +++ b/github/workflows/drupal/styles.yaml @@ -2,7 +2,7 @@ # github/workflows/drupal/styles.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ### Styles (CSS and SCSS) +### ### Drupal Styles (CSS and SCSS) ### ### Validates styles files. ### diff --git a/github/workflows/javascript.yaml b/github/workflows/javascript.yaml deleted file mode 100644 index 8696a809..00000000 --- a/github/workflows/javascript.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# Do not edit this file! Make a pull request on changing -# github/workflows/javascript.yaml in -# https://github.com/itk-dev/devops_itkdev-docker if need be. - -### JavaScript (and TypeScript) From ad8c2e44c4a28dfb5878549f32703f8f8352862d Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 12:25:12 +0200 Subject: [PATCH 23/34] Updated links --- github/workflows/drupal/javascript.yaml | 2 +- templates/drupal-10/.github/workflows/javascript.yaml | 2 +- templates/drupal-11/.github/workflows/javascript.yaml | 2 +- templates/drupal-7/.github/workflows/javascript.yaml | 2 +- templates/drupal-8/.github/workflows/javascript.yaml | 2 +- templates/drupal-9/.github/workflows/javascript.yaml | 2 +- templates/symfony-3/.github/workflows/javascript.yaml | 1 - templates/symfony-4/.github/workflows/javascript.yaml | 1 - templates/symfony-6/.github/workflows/javascript.yaml | 1 - 9 files changed, 6 insertions(+), 9 deletions(-) delete mode 120000 templates/symfony-3/.github/workflows/javascript.yaml delete mode 120000 templates/symfony-4/.github/workflows/javascript.yaml delete mode 120000 templates/symfony-6/.github/workflows/javascript.yaml diff --git a/github/workflows/drupal/javascript.yaml b/github/workflows/drupal/javascript.yaml index c4005a48..65d54681 100644 --- a/github/workflows/drupal/javascript.yaml +++ b/github/workflows/drupal/javascript.yaml @@ -1,5 +1,5 @@ # Do not edit this file! Make a pull request on changing -# github/workflows/javascript.yaml in +# github/workflows/drupal/javascript.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. ### ### Drupal JavaScript (and TypeScript) diff --git a/templates/drupal-10/.github/workflows/javascript.yaml b/templates/drupal-10/.github/workflows/javascript.yaml index b272c00b..e76b3a56 120000 --- a/templates/drupal-10/.github/workflows/javascript.yaml +++ b/templates/drupal-10/.github/workflows/javascript.yaml @@ -1 +1 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file +../../../../github/workflows/drupal/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/javascript.yaml b/templates/drupal-11/.github/workflows/javascript.yaml index b272c00b..e76b3a56 120000 --- a/templates/drupal-11/.github/workflows/javascript.yaml +++ b/templates/drupal-11/.github/workflows/javascript.yaml @@ -1 +1 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file +../../../../github/workflows/drupal/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-7/.github/workflows/javascript.yaml b/templates/drupal-7/.github/workflows/javascript.yaml index b272c00b..e76b3a56 120000 --- a/templates/drupal-7/.github/workflows/javascript.yaml +++ b/templates/drupal-7/.github/workflows/javascript.yaml @@ -1 +1 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file +../../../../github/workflows/drupal/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-8/.github/workflows/javascript.yaml b/templates/drupal-8/.github/workflows/javascript.yaml index b272c00b..e76b3a56 120000 --- a/templates/drupal-8/.github/workflows/javascript.yaml +++ b/templates/drupal-8/.github/workflows/javascript.yaml @@ -1 +1 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file +../../../../github/workflows/drupal/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-9/.github/workflows/javascript.yaml b/templates/drupal-9/.github/workflows/javascript.yaml index b272c00b..e76b3a56 120000 --- a/templates/drupal-9/.github/workflows/javascript.yaml +++ b/templates/drupal-9/.github/workflows/javascript.yaml @@ -1 +1 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file +../../../../github/workflows/drupal/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-3/.github/workflows/javascript.yaml b/templates/symfony-3/.github/workflows/javascript.yaml deleted file mode 120000 index b272c00b..00000000 --- a/templates/symfony-3/.github/workflows/javascript.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/javascript.yaml b/templates/symfony-4/.github/workflows/javascript.yaml deleted file mode 120000 index b272c00b..00000000 --- a/templates/symfony-4/.github/workflows/javascript.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/javascript.yaml b/templates/symfony-6/.github/workflows/javascript.yaml deleted file mode 120000 index b272c00b..00000000 --- a/templates/symfony-6/.github/workflows/javascript.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file From 1a2f5584d2ecc14257325799b0c2abccc915a5b9 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 14:30:30 +0200 Subject: [PATCH 24/34] Added shellckeck to workflo --- .github/workflows/workflow-template.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/workflow-template.yaml b/.github/workflows/workflow-template.yaml index 74a0ffa1..b7f8cf71 100644 --- a/.github/workflows/workflow-template.yaml +++ b/.github/workflows/workflow-template.yaml @@ -13,3 +13,14 @@ jobs: for f in $(find github/workflows/ -name '*.yaml'); do docker run --rm --volume "$PWD":/workdir mikefarah/yq "$f" > /dev/null done + + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - run: | + task lint:shell-script From 9100df2ef98002f8d30feb246261d29f207fcccc Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 6 May 2025 10:06:17 +0200 Subject: [PATCH 25/34] Updated Markdownlint ignores --- config/markdown/.markdownlintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/config/markdown/.markdownlintignore b/config/markdown/.markdownlintignore index 49046b73..d143acee 100644 --- a/config/markdown/.markdownlintignore +++ b/config/markdown/.markdownlintignore @@ -8,4 +8,5 @@ LICENSE.md # Drupal web/*.md web/core/ +web/libraries/ web/*/contrib/ From ee5f438d4cdb173ce2d7cb4f891d0a4482468ebd Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 6 May 2025 10:13:40 +0200 Subject: [PATCH 26/34] Run markdownlint via docker compose --- .github/workflows/markdown.yaml | 26 ++++++++++++++++++++------ compose.yaml | 7 +++++++ docs/github-actions-templates.md | 12 +++++++++--- github/workflows/markdown.yaml | 15 ++++++++++++--- 4 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 compose.yaml diff --git a/.github/workflows/markdown.yaml b/.github/workflows/markdown.yaml index 12df4d74..60fc0ee5 100644 --- a/.github/workflows/markdown.yaml +++ b/.github/workflows/markdown.yaml @@ -2,19 +2,30 @@ # github/workflows/markdown.yaml in # https://github.com/itk-dev/devops_itkdev-docker if need be. -### ## Markdown +### ### Markdown ### -### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to -### link all Markdown files (`**/*.md`) in the project. +### Lints Markdown files (`**/*.md`) in the project. ### -### [markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), -### `.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how. +### [markdownlint-cli configuration +### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), +### `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually +### linted and how. +### +### #### Assumptions +### +### 1. A docker compose service named `markdownlint` for running `markdownlint` +### (from +### [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli)) +### exists. name: Markdown on: pull_request: push: + branches: + - main + - develop jobs: markdown-lint: @@ -26,4 +37,7 @@ jobs: uses: actions/checkout@v4 - run: | - docker run --rm --volume "$PWD":/md itkdev/markdownlint '**/*.md' + docker network create frontend + + - run: | + docker compose run --rm markdownlint markdownlint '**/*.md' diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..a2be8aa3 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,7 @@ +services: + markdownlint: + image: itkdev/markdownlint + profiles: + - dev + volumes: + - ./:/md diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index 8aac76e0..1bd0c191 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -142,14 +142,20 @@ Validates styles files. ### Markdown -Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to -link all Markdown files (`**/*.md`) in the project. +Lints Markdown files (`**/*.md`) in the project. [markdownlint-cli configuration files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually linted and how. +#### Assumptions + +1. A docker compose service named `markdownlint` for running `markdownlint` + (from + [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli)) + exists. + --- [github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml) diff --git a/github/workflows/markdown.yaml b/github/workflows/markdown.yaml index 5a951fa4..60fc0ee5 100644 --- a/github/workflows/markdown.yaml +++ b/github/workflows/markdown.yaml @@ -4,13 +4,19 @@ ### ### Markdown ### -### Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to -### link all Markdown files (`**/*.md`) in the project. +### Lints Markdown files (`**/*.md`) in the project. ### ### [markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration), ### `.markdownlint.jsonc` and `.markdownlintignore`, control what is actually ### linted and how. +### +### #### Assumptions +### +### 1. A docker compose service named `markdownlint` for running `markdownlint` +### (from +### [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli)) +### exists. name: Markdown @@ -31,4 +37,7 @@ jobs: uses: actions/checkout@v4 - run: | - docker run --rm --volume "$PWD":/md itkdev/markdownlint '**/*.md' + docker network create frontend + + - run: | + docker compose run --rm markdownlint markdownlint '**/*.md' From 7ee57235bb58d083492686e124ad2d9d7086307a Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 7 May 2025 13:06:48 +0200 Subject: [PATCH 27/34] Updated Symfony workflows --- Taskfile.yml | 1 + docs/github-actions-templates.md | 55 ++++++++++++++++++- github/workflows/symfony/javascript.yaml | 36 ++++++++++++ github/workflows/symfony/php.yaml | 51 +++++++++++++++++ github/workflows/symfony/styles.yaml | 36 ++++++++++++ .../.github/workflows/javascript.yaml | 1 + .../symfony-3/.github/workflows/styles.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../symfony-4/.github/workflows/styles.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../symfony-6/.github/workflows/styles.yaml | 1 + 11 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 github/workflows/symfony/javascript.yaml create mode 100644 github/workflows/symfony/styles.yaml create mode 120000 templates/symfony-3/.github/workflows/javascript.yaml create mode 120000 templates/symfony-3/.github/workflows/styles.yaml create mode 120000 templates/symfony-4/.github/workflows/javascript.yaml create mode 120000 templates/symfony-4/.github/workflows/styles.yaml create mode 120000 templates/symfony-6/.github/workflows/javascript.yaml create mode 120000 templates/symfony-6/.github/workflows/styles.yaml diff --git a/Taskfile.yml b/Taskfile.yml index 6f2c9903..50d10280 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -22,6 +22,7 @@ tasks: build: desc: "Build everything" cmds: + - task: github-actions:template-headers:update - task: github-actions:documentation:update - task: github-actions:link - task: lint:markdown diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index 1bd0c191..e5fd6daf 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -158,10 +158,63 @@ linted and how. --- +[github/workflows/symfony/javascript.yaml](github/workflows/symfony/javascript.yaml) + +### Symfony JavaScript (and TypeScript) + +Validates JavaScript files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +--- + [github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml) ### Symfony PHP +Checks that PHP code adheres to the [Symfony coding +standards](https://symfony.com/doc/current/contributing/code/standards.html). + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. 2. + [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) + is a dev requirement in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev friendsofphp/php-cs-fixer + ``` + + Clean up and check code by running + + ``` shell + docker compose run --rm phpfpm vendor/bin/phpcbf + docker compose run --rm phpfpm vendor/bin/phpcs + ``` + +> [!NOTE] The template adds `.php-cs-fixer.dist.php` as [a configuration +> file for PHP CS +> Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst) +> and this makes it possible to override the actual configuration used in a +> project by adding a more important configuration file, `.php-cs-fixer.php`. + +--- + +[github/workflows/symfony/styles.yaml](github/workflows/symfony/styles.yaml) + +### Symfony Styles (CSS and SCSS) + +Validates styles files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + --- [github/workflows/twig.yaml](github/workflows/twig.yaml) diff --git a/github/workflows/symfony/javascript.yaml b/github/workflows/symfony/javascript.yaml new file mode 100644 index 00000000..5b20c8da --- /dev/null +++ b/github/workflows/symfony/javascript.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/symfony/javascript.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Symfony JavaScript (and TypeScript) +### +### Validates JavaScript files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: JavaScript + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + javascript-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'assets/**/*.js' --check diff --git a/github/workflows/symfony/php.yaml b/github/workflows/symfony/php.yaml index 9245f783..60fb70eb 100644 --- a/github/workflows/symfony/php.yaml +++ b/github/workflows/symfony/php.yaml @@ -3,3 +3,54 @@ # https://github.com/itk-dev/devops_itkdev-docker if need be. ### ### Symfony PHP +### +### Checks that PHP code adheres to the [Symfony coding +### standards](https://symfony.com/doc/current/contributing/code/standards.html). +### +### #### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. 2. +### [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) +### is a dev requirement in `composer.json`: +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev friendsofphp/php-cs-fixer +### ``` +### +### Clean up and check code by running +### +### ``` shell +### docker compose run --rm phpfpm vendor/bin/php-cs-fixer fix +### docker compose run --rm phpfpm vendor/bin/php-cs-fixer fix --dry-run --diff +### ``` +### +### > [!NOTE] The template adds `.php-cs-fixer.dist.php` as [a configuration +### > file for PHP CS +### > Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst) +### > and this makes it possible to override the actual configuration used in a +### > project by adding a more important configuration file, `.php-cs-fixer.php`. + +name: Symfony PHP + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + coding-standards: + name: PHP - Check Coding Standards + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer install + # https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/usage.rst#the-check-command + docker compose run --rm phpfpm vendor/bin/php-cs-fixer fix --dry-run --diff diff --git a/github/workflows/symfony/styles.yaml b/github/workflows/symfony/styles.yaml new file mode 100644 index 00000000..c6dec50f --- /dev/null +++ b/github/workflows/symfony/styles.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/symfony/styles.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Symfony Styles (CSS and SCSS) +### +### Validates styles files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: Styles + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + styles-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'assets/**/*.?css' --check diff --git a/templates/symfony-3/.github/workflows/javascript.yaml b/templates/symfony-3/.github/workflows/javascript.yaml new file mode 120000 index 00000000..32f4e115 --- /dev/null +++ b/templates/symfony-3/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-3/.github/workflows/styles.yaml b/templates/symfony-3/.github/workflows/styles.yaml new file mode 120000 index 00000000..af396b48 --- /dev/null +++ b/templates/symfony-3/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/styles.yaml \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/javascript.yaml b/templates/symfony-4/.github/workflows/javascript.yaml new file mode 120000 index 00000000..32f4e115 --- /dev/null +++ b/templates/symfony-4/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/styles.yaml b/templates/symfony-4/.github/workflows/styles.yaml new file mode 120000 index 00000000..af396b48 --- /dev/null +++ b/templates/symfony-4/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/styles.yaml \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/javascript.yaml b/templates/symfony-6/.github/workflows/javascript.yaml new file mode 120000 index 00000000..32f4e115 --- /dev/null +++ b/templates/symfony-6/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/javascript.yaml \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/styles.yaml b/templates/symfony-6/.github/workflows/styles.yaml new file mode 120000 index 00000000..af396b48 --- /dev/null +++ b/templates/symfony-6/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/styles.yaml \ No newline at end of file From 8eee3cdd16b28149c7b396f3fc1219deda7bf7f1 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 9 May 2025 09:40:40 +0200 Subject: [PATCH 28/34] Update Drupal site workflow --- github/workflows/drupal/site.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/github/workflows/drupal/site.yaml b/github/workflows/drupal/site.yaml index 70561cba..92ce5ab4 100644 --- a/github/workflows/drupal/site.yaml +++ b/github/workflows/drupal/site.yaml @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install site + - name: Start docker and install dependencies run: | docker network create frontend docker compose pull @@ -71,7 +71,7 @@ jobs: with: ref: ${{ github.base_ref }} - - name: setup-docker-and-composer + - name: Start docker and install dependencies run: | docker network create frontend docker compose pull @@ -109,8 +109,9 @@ jobs: # https://github.com/actions/checkout?tab=readme-ov-file#usage) clean: false - - name: setup-docker-and-composer + - name: Start docker and install dependencies run: | + docker network create frontend || true docker compose pull docker compose up --detach From 64908fbff155128d66c395dd7a20d26fa53b967a Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 9 May 2025 09:40:50 +0200 Subject: [PATCH 29/34] Updated docs --- docs/github-actions-templates.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index e5fd6daf..de4e3887 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -192,8 +192,8 @@ standards](https://symfony.com/doc/current/contributing/code/standards.html). Clean up and check code by running ``` shell - docker compose run --rm phpfpm vendor/bin/phpcbf - docker compose run --rm phpfpm vendor/bin/phpcs + docker compose run --rm phpfpm vendor/bin/php-cs-fixer fix + docker compose run --rm phpfpm vendor/bin/php-cs-fixer fix --dry-run --diff ``` > [!NOTE] The template adds `.php-cs-fixer.dist.php` as [a configuration From 185a2cf97ae4154c0cbc3c24d5ffd7f6956a4d04 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 15 May 2025 16:17:03 +0200 Subject: [PATCH 30/34] Fixed prettier globs --- github/workflows/drupal/styles.yaml | 2 +- github/workflows/symfony/styles.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/github/workflows/drupal/styles.yaml b/github/workflows/drupal/styles.yaml index c94c0786..049af207 100644 --- a/github/workflows/drupal/styles.yaml +++ b/github/workflows/drupal/styles.yaml @@ -33,4 +33,4 @@ jobs: docker network create frontend - run: | - docker compose run --rm prettier 'web/themes/custom/**/css/**/*.css' --check + docker compose run --rm prettier 'web/themes/custom/**/css/**/*.{css,scss}' --check diff --git a/github/workflows/symfony/styles.yaml b/github/workflows/symfony/styles.yaml index c6dec50f..edc79602 100644 --- a/github/workflows/symfony/styles.yaml +++ b/github/workflows/symfony/styles.yaml @@ -33,4 +33,4 @@ jobs: docker network create frontend - run: | - docker compose run --rm prettier 'assets/**/*.?css' --check + docker compose run --rm prettier 'assets/**/*.{css,scss}' --check From 50126d0155af770fb832323e0a6d18dc44ea34f7 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 14:00:47 +0200 Subject: [PATCH 31/34] Added Drupal module template --- CHANGELOG.md | 3 + config/drupal-module/php/.phpcs.xml.dist | 31 ++++++++++ .../twig/.twig-cs-fixer.dist.php | 16 +++++ docs/github-actions-templates.md | 61 ++++++++++++++++++- .../workflows/drupal-module/javascript.yaml | 36 +++++++++++ github/workflows/drupal-module/php.yaml | 55 +++++++++++++++++ github/workflows/drupal-module/styles.yaml | 36 +++++++++++ task/scripts/github-actions-link | 14 +++-- .../.github/workflows/changelog.yaml | 1 + .../.github/workflows/composer.yaml | 1 + .../.github/workflows/javascript.yaml | 1 + .../.github/workflows/markdown.yaml | 1 + .../drupal-module/.github/workflows/php.yaml | 1 + .../.github/workflows/styles.yaml | 1 + .../drupal-module/.github/workflows/twig.yaml | 1 + templates/drupal-module/.markdownlint.jsonc | 1 + templates/drupal-module/.markdownlintignore | 1 + templates/drupal-module/.phpcs.xml.dist | 1 + .../drupal-module/.twig-cs-fixer.dist.php | 1 + templates/drupal-module/docker-compose.yml | 38 ++++++++++++ 20 files changed, 296 insertions(+), 5 deletions(-) create mode 100644 config/drupal-module/php/.phpcs.xml.dist create mode 100644 config/drupal-module/twig/.twig-cs-fixer.dist.php create mode 100644 github/workflows/drupal-module/javascript.yaml create mode 100644 github/workflows/drupal-module/php.yaml create mode 100644 github/workflows/drupal-module/styles.yaml create mode 120000 templates/drupal-module/.github/workflows/changelog.yaml create mode 120000 templates/drupal-module/.github/workflows/composer.yaml create mode 120000 templates/drupal-module/.github/workflows/javascript.yaml create mode 120000 templates/drupal-module/.github/workflows/markdown.yaml create mode 120000 templates/drupal-module/.github/workflows/php.yaml create mode 120000 templates/drupal-module/.github/workflows/styles.yaml create mode 120000 templates/drupal-module/.github/workflows/twig.yaml create mode 120000 templates/drupal-module/.markdownlint.jsonc create mode 120000 templates/drupal-module/.markdownlintignore create mode 120000 templates/drupal-module/.phpcs.xml.dist create mode 120000 templates/drupal-module/.twig-cs-fixer.dist.php create mode 100644 templates/drupal-module/docker-compose.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index d68152ad..08d0862e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- [PR-108](https://github.com/itk-dev/devops_itkdev-docker/pull/108) + Added Drupal module template + ### Changed - Updated to PHP 8.3 diff --git a/config/drupal-module/php/.phpcs.xml.dist b/config/drupal-module/php/.phpcs.xml.dist new file mode 100644 index 00000000..a97dd835 --- /dev/null +++ b/config/drupal-module/php/.phpcs.xml.dist @@ -0,0 +1,31 @@ + + + + + + The coding standard. + + . + + + node_modules + vendor + *.css + *.js + + + + + + + + + + + + + + + + + diff --git a/config/drupal-module/twig/.twig-cs-fixer.dist.php b/config/drupal-module/twig/.twig-cs-fixer.dist.php new file mode 100644 index 00000000..35cf5317 --- /dev/null +++ b/config/drupal-module/twig/.twig-cs-fixer.dist.php @@ -0,0 +1,16 @@ +in(__DIR__); +// … that are not ignored by VCS +$finder->ignoreVCSIgnored(true); + +$config = new TwigCsFixer\Config\Config(); +$config->setFinder($finder); + +return $config; diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index de4e3887..e83b81f0 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -61,6 +61,65 @@ Validates composer.json and checks that it's normalized. --- +[github/workflows/drupal-module/javascript.yaml](github/workflows/drupal-module/javascript.yaml) + +### Drupal module JavaScript (and TypeScript) + +Validates JavaScript files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +--- + +[github/workflows/drupal-module/php.yaml](github/workflows/drupal-module/php.yaml) + +### Drupal module PHP + +Checks that PHP code adheres to the [Drupal coding +standards](https://www.drupal.org/docs/develop/standards). + +#### Assumptions + +1. A docker compose service named `phpfpm` can be run and `composer` can be + run inside the `phpfpm` service. +2. [drupal/coder](https://www.drupal.org/project/coder) is a dev requirement +in `composer.json`: + + ``` shell + docker compose run --rm phpfpm composer require --dev drupal/coder + ``` + + Clean up and check code by running + + ``` shell + docker compose run --rm phpfpm vendor/bin/phpcbf + docker compose run --rm phpfpm vendor/bin/phpcs + ``` + +> [!NOTE] +> The template adds `.phpcs.xml.dist` as [a configuration file for +> PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) +> and this makes it possible to override the actual configuration used in a +> project by adding a more important configuration file, e.g. `.phpcs.xml`. + +--- + +[github/workflows/drupal-module/styles.yaml](github/workflows/drupal-module/styles.yaml) + +### Drupal module Styles (CSS and SCSS) + +Validates styles files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +--- + [github/workflows/drupal/javascript.yaml](github/workflows/drupal/javascript.yaml) ### Drupal JavaScript (and TypeScript) diff --git a/github/workflows/drupal-module/javascript.yaml b/github/workflows/drupal-module/javascript.yaml new file mode 100644 index 00000000..54ef6e27 --- /dev/null +++ b/github/workflows/drupal-module/javascript.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/drupal-module/javascript.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Drupal module JavaScript (and TypeScript) +### +### Validates JavaScript files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: JavaScript + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + javascript-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'js/**/*.js' --check diff --git a/github/workflows/drupal-module/php.yaml b/github/workflows/drupal-module/php.yaml new file mode 100644 index 00000000..4218f4de --- /dev/null +++ b/github/workflows/drupal-module/php.yaml @@ -0,0 +1,55 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/drupal-module/php.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Drupal module PHP +### +### Checks that PHP code adheres to the [Drupal coding +### standards](https://www.drupal.org/docs/develop/standards). +### +### #### Assumptions +### +### 1. A docker compose service named `phpfpm` can be run and `composer` can be +### run inside the `phpfpm` service. +### 2. [drupal/coder](https://www.drupal.org/project/coder) is a dev requirement +### in `composer.json`: +### +### ``` shell +### docker compose run --rm phpfpm composer require --dev drupal/coder +### ``` +### +### Clean up and check code by running +### +### ``` shell +### docker compose run --rm phpfpm vendor/bin/phpcbf +### docker compose run --rm phpfpm vendor/bin/phpcs +### ``` +### +### > [!NOTE] +### > The template adds `.phpcs.xml.dist` as [a configuration file for +### > PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) +### > and this makes it possible to override the actual configuration used in a +### > project by adding a more important configuration file, e.g. `.phpcs.xml`. + +name: PHP + +env: + COMPOSE_USER: root + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + coding-standards: + name: PHP - Check Coding Standards + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + docker network create frontend + docker compose run --rm phpfpm composer install + docker compose run --rm phpfpm vendor/bin/phpcs diff --git a/github/workflows/drupal-module/styles.yaml b/github/workflows/drupal-module/styles.yaml new file mode 100644 index 00000000..0d5cdc0b --- /dev/null +++ b/github/workflows/drupal-module/styles.yaml @@ -0,0 +1,36 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/drupal-module/styles.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### Drupal module Styles (CSS and SCSS) +### +### Validates styles files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. + +name: Styles + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + styles-lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier 'css/**/*.css' --check diff --git a/task/scripts/github-actions-link b/task/scripts/github-actions-link index 5b71f4c5..e7ec2756 100755 --- a/task/scripts/github-actions-link +++ b/task/scripts/github-actions-link @@ -11,8 +11,8 @@ cd "$project_dir" || exit function strip-project-type() { name=$1 - if [[ "$name" =~ ^(drupal|symfony)/(.+) ]]; then - name="${BASH_REMATCH[2]}" + if [[ "$name" =~ ^(drupal(-module)?|symfony)/(.+) ]]; then + name="${BASH_REMATCH[3]}" fi echo "$name" @@ -27,7 +27,9 @@ for template_dir in templates/*; do echo project_type="" - if [[ "$template_name" =~ ^drupal- ]]; then + if [[ "$template_name" =~ ^drupal-module ]]; then + project_type="drupal-module" + elif [[ "$template_name" =~ ^drupal- ]]; then project_type="drupal" elif [[ "$template_name" =~ ^symfony- ]]; then project_type="symfony" @@ -39,7 +41,11 @@ for template_dir in templates/*; do for f in $(find github/workflows/ -name '*.yaml' | sort); do source_file_name='' # Note: / is NOT a regex delimiter here, but an actual /, i.e. a directory separator. - if [[ "$f" =~ /drupal/ ]]; then + if [[ "$f" =~ /drupal-module/ ]]; then + if [[ "$project_type" == "drupal-module" ]]; then + source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" + fi + elif [[ "$f" =~ /drupal/ ]]; then if [[ "$project_type" == "drupal" ]]; then source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" fi diff --git a/templates/drupal-module/.github/workflows/changelog.yaml b/templates/drupal-module/.github/workflows/changelog.yaml new file mode 120000 index 00000000..5ffe5c3c --- /dev/null +++ b/templates/drupal-module/.github/workflows/changelog.yaml @@ -0,0 +1 @@ +../../../../github/workflows/changelog.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/composer.yaml b/templates/drupal-module/.github/workflows/composer.yaml new file mode 120000 index 00000000..23955648 --- /dev/null +++ b/templates/drupal-module/.github/workflows/composer.yaml @@ -0,0 +1 @@ +../../../../github/workflows/composer.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/javascript.yaml b/templates/drupal-module/.github/workflows/javascript.yaml new file mode 120000 index 00000000..09fb93cd --- /dev/null +++ b/templates/drupal-module/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal-module/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/markdown.yaml b/templates/drupal-module/.github/workflows/markdown.yaml new file mode 120000 index 00000000..ab3eafad --- /dev/null +++ b/templates/drupal-module/.github/workflows/markdown.yaml @@ -0,0 +1 @@ +../../../../github/workflows/markdown.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/php.yaml b/templates/drupal-module/.github/workflows/php.yaml new file mode 120000 index 00000000..405a1864 --- /dev/null +++ b/templates/drupal-module/.github/workflows/php.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal-module/php.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/styles.yaml b/templates/drupal-module/.github/workflows/styles.yaml new file mode 120000 index 00000000..31ec0309 --- /dev/null +++ b/templates/drupal-module/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal-module/styles.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/twig.yaml b/templates/drupal-module/.github/workflows/twig.yaml new file mode 120000 index 00000000..649f1cd6 --- /dev/null +++ b/templates/drupal-module/.github/workflows/twig.yaml @@ -0,0 +1 @@ +../../../../github/workflows/twig.yaml \ No newline at end of file diff --git a/templates/drupal-module/.markdownlint.jsonc b/templates/drupal-module/.markdownlint.jsonc new file mode 120000 index 00000000..1a3d9afe --- /dev/null +++ b/templates/drupal-module/.markdownlint.jsonc @@ -0,0 +1 @@ +../../config/markdown/.markdownlint.jsonc \ No newline at end of file diff --git a/templates/drupal-module/.markdownlintignore b/templates/drupal-module/.markdownlintignore new file mode 120000 index 00000000..0a61367e --- /dev/null +++ b/templates/drupal-module/.markdownlintignore @@ -0,0 +1 @@ +../../config/markdown/.markdownlintignore \ No newline at end of file diff --git a/templates/drupal-module/.phpcs.xml.dist b/templates/drupal-module/.phpcs.xml.dist new file mode 120000 index 00000000..040c94d1 --- /dev/null +++ b/templates/drupal-module/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal-module/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-module/.twig-cs-fixer.dist.php b/templates/drupal-module/.twig-cs-fixer.dist.php new file mode 120000 index 00000000..3f9471f4 --- /dev/null +++ b/templates/drupal-module/.twig-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/drupal-module/twig/.twig-cs-fixer.dist.php \ No newline at end of file diff --git a/templates/drupal-module/docker-compose.yml b/templates/drupal-module/docker-compose.yml new file mode 100644 index 00000000..8906179f --- /dev/null +++ b/templates/drupal-module/docker-compose.yml @@ -0,0 +1,38 @@ +# itk-version: 3.2.3 + +services: + phpfpm: + image: itkdev/php8.4-fpm:latest + user: ${COMPOSE_USER:-deploy} + networks: + - app + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + - PHP_XDEBUG_MODE=${PHP_XDEBUG_MODE:-off} + - PHP_MAX_EXECUTION_TIME=30 + - PHP_MEMORY_LIMIT=256M + # Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail + - PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients --read-envelope-from + - DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN} + - PHP_IDE_CONFIG=serverName=localhost + # Let drush know the site uri (makes using --uri redundant) + - DRUSH_OPTIONS_URI=http://${COMPOSE_DOMAIN} + depends_on: + mariadb: + condition: service_healthy + memcached: + condition: service_healthy + volumes: + - .:/app + + prettier: + # Prettier does not (yet, fcf. + # https://github.com/prettier/prettier/issues/15206) have an official + # docker image. + # https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc) + image: jauderho/prettier + profiles: + - dev + volumes: + - ./:/work From ea6598e01fe3cf07e05dd39e175f25e2119e4693 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 20 May 2025 14:00:40 +0200 Subject: [PATCH 32/34] Updated docker compose setup --- templates/drupal-module/docker-compose.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/templates/drupal-module/docker-compose.yml b/templates/drupal-module/docker-compose.yml index 8906179f..cb456c10 100644 --- a/templates/drupal-module/docker-compose.yml +++ b/templates/drupal-module/docker-compose.yml @@ -4,25 +4,6 @@ services: phpfpm: image: itkdev/php8.4-fpm:latest user: ${COMPOSE_USER:-deploy} - networks: - - app - extra_hosts: - - "host.docker.internal:host-gateway" - environment: - - PHP_XDEBUG_MODE=${PHP_XDEBUG_MODE:-off} - - PHP_MAX_EXECUTION_TIME=30 - - PHP_MEMORY_LIMIT=256M - # Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail - - PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients --read-envelope-from - - DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN} - - PHP_IDE_CONFIG=serverName=localhost - # Let drush know the site uri (makes using --uri redundant) - - DRUSH_OPTIONS_URI=http://${COMPOSE_DOMAIN} - depends_on: - mariadb: - condition: service_healthy - memcached: - condition: service_healthy volumes: - .:/app From 133456f64ce9ba2adc14a636cb7717c43bf05840 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 12 Jun 2025 14:57:31 +0200 Subject: [PATCH 33/34] Added YAML linting --- Taskfile.yml | 1 + config/symfony/yaml/.prettierrc.yaml | 11 +++++ docs/github-actions-templates.md | 22 +++++++++- github/workflows/yaml.yaml | 40 +++++++++++++++++++ .../drupal-10/.github/workflows/yaml.yaml | 1 + .../drupal-11/.github/workflows/yaml.yaml | 1 + .../drupal-7/.github/workflows/yaml.yaml | 1 + .../drupal-8/.github/workflows/yaml.yaml | 1 + .../drupal-9/.github/workflows/yaml.yaml | 1 + .../drupal-module/.github/workflows/yaml.yaml | 1 + .../symfony-3/.github/workflows/yaml.yaml | 1 + templates/symfony-3/.prettierrc.yaml | 1 + .../symfony-4/.github/workflows/yaml.yaml | 1 + templates/symfony-4/.prettierrc.yaml | 1 + .../symfony-6/.github/workflows/yaml.yaml | 1 + templates/symfony-6/.prettierrc.yaml | 1 + 16 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 config/symfony/yaml/.prettierrc.yaml create mode 100644 github/workflows/yaml.yaml create mode 120000 templates/drupal-10/.github/workflows/yaml.yaml create mode 120000 templates/drupal-11/.github/workflows/yaml.yaml create mode 120000 templates/drupal-7/.github/workflows/yaml.yaml create mode 120000 templates/drupal-8/.github/workflows/yaml.yaml create mode 120000 templates/drupal-9/.github/workflows/yaml.yaml create mode 120000 templates/drupal-module/.github/workflows/yaml.yaml create mode 120000 templates/symfony-3/.github/workflows/yaml.yaml create mode 120000 templates/symfony-3/.prettierrc.yaml create mode 120000 templates/symfony-4/.github/workflows/yaml.yaml create mode 120000 templates/symfony-4/.prettierrc.yaml create mode 120000 templates/symfony-6/.github/workflows/yaml.yaml create mode 120000 templates/symfony-6/.prettierrc.yaml diff --git a/Taskfile.yml b/Taskfile.yml index 50d10280..c9f37f61 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -22,6 +22,7 @@ tasks: build: desc: "Build everything" cmds: + - task: github-actions:config-headers:update - task: github-actions:template-headers:update - task: github-actions:documentation:update - task: github-actions:link diff --git a/config/symfony/yaml/.prettierrc.yaml b/config/symfony/yaml/.prettierrc.yaml new file mode 100644 index 00000000..12e08983 --- /dev/null +++ b/config/symfony/yaml/.prettierrc.yaml @@ -0,0 +1,11 @@ +# This file is copied from config/symfony/yaml/.prettierrc.yaml in https://github.com/itk-dev/devops_itkdev-docker. +# Feel free to edit the file, but consider making a pull request if you find a general issue with the file. + +# https://prettier.io/docs/configuration +overrides: + # Symfony config + - files: + - "config/**/*.{yml,yaml}" + options: + tabWidth: 4 + singleQuote: true diff --git a/docs/github-actions-templates.md b/docs/github-actions-templates.md index e83b81f0..c462c63a 100644 --- a/docs/github-actions-templates.md +++ b/docs/github-actions-templates.md @@ -1,6 +1,6 @@ @@ -299,6 +299,26 @@ Validates Twig files --- +[github/workflows/yaml.yaml](github/workflows/yaml.yaml) + +### YAML + +Validates YAML files. + +#### Assumptions + +1. A docker compose service named `prettier` for running + [Prettier](https://prettier.io/) exists. + +#### Symfony YAML + +Symfony's YAML config files use 4 spaces for indentation and single quotes. +Therefore we use a [Prettier configuration +file](https://prettier.io/docs/configuration), `.prettierrc.yaml`, to make +Prettier format YAML files in the `config/` folder like Symfony expects. + +--- + ## Updating template documentation To update this document, run diff --git a/github/workflows/yaml.yaml b/github/workflows/yaml.yaml new file mode 100644 index 00000000..1c0ada3f --- /dev/null +++ b/github/workflows/yaml.yaml @@ -0,0 +1,40 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/yaml.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### YAML +### +### Validates YAML files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. +### +### #### Symfony YAML +### +### Symfony's YAML config files use 4 spaces for indentation and single quotes. +### Therefore we use a [Prettier configuration +### file](https://prettier.io/docs/configuration), `.prettierrc.yaml`, to make +### Prettier format YAML files in the `config/` folder like Symfony expects. + +name: YAML + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + yaml-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier '**/*.{yml,yaml}' --check diff --git a/templates/drupal-10/.github/workflows/yaml.yaml b/templates/drupal-10/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-10/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-11/.github/workflows/yaml.yaml b/templates/drupal-11/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-11/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-7/.github/workflows/yaml.yaml b/templates/drupal-7/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-7/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-8/.github/workflows/yaml.yaml b/templates/drupal-8/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-8/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-9/.github/workflows/yaml.yaml b/templates/drupal-9/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-9/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-module/.github/workflows/yaml.yaml b/templates/drupal-module/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/drupal-module/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/symfony-3/.github/workflows/yaml.yaml b/templates/symfony-3/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/symfony-3/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/symfony-3/.prettierrc.yaml b/templates/symfony-3/.prettierrc.yaml new file mode 120000 index 00000000..eeef7b84 --- /dev/null +++ b/templates/symfony-3/.prettierrc.yaml @@ -0,0 +1 @@ +../../config/symfony/yaml/.prettierrc.yaml \ No newline at end of file diff --git a/templates/symfony-4/.github/workflows/yaml.yaml b/templates/symfony-4/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/symfony-4/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/symfony-4/.prettierrc.yaml b/templates/symfony-4/.prettierrc.yaml new file mode 120000 index 00000000..eeef7b84 --- /dev/null +++ b/templates/symfony-4/.prettierrc.yaml @@ -0,0 +1 @@ +../../config/symfony/yaml/.prettierrc.yaml \ No newline at end of file diff --git a/templates/symfony-6/.github/workflows/yaml.yaml b/templates/symfony-6/.github/workflows/yaml.yaml new file mode 120000 index 00000000..725a7d68 --- /dev/null +++ b/templates/symfony-6/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/symfony-6/.prettierrc.yaml b/templates/symfony-6/.prettierrc.yaml new file mode 120000 index 00000000..eeef7b84 --- /dev/null +++ b/templates/symfony-6/.prettierrc.yaml @@ -0,0 +1 @@ +../../config/symfony/yaml/.prettierrc.yaml \ No newline at end of file From fb829ac17a668b6239b76f51a4194b7327c8d4c8 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 12 Jun 2025 15:03:56 +0200 Subject: [PATCH 34/34] Linted YAML files --- .github/workflows/yaml.yaml | 40 +++++++++++++++++++ Taskfile.yml | 2 +- compose.yaml | 11 +++++ task/Taskfile.github-actions.yml | 4 +- templates/drupal-10/docker-compose.server.yml | 2 +- templates/drupal-10/docker-compose.yml | 16 ++++---- templates/drupal-11/docker-compose.server.yml | 2 +- templates/drupal-11/docker-compose.yml | 8 ++-- templates/drupal-7/docker-compose.server.yml | 2 +- templates/drupal-7/docker-compose.yml | 18 ++++----- templates/drupal-8/docker-compose.server.yml | 2 +- templates/drupal-8/docker-compose.yml | 18 ++++----- templates/drupal-9/docker-compose.server.yml | 2 +- templates/drupal-9/docker-compose.yml | 18 ++++----- templates/symfony-3/docker-compose.server.yml | 1 - templates/symfony-3/docker-compose.yml | 16 ++++---- templates/symfony-4/docker-compose.yml | 16 ++++---- templates/symfony-6/docker-compose.yml | 12 +++--- traefik/dynamic-conf.yaml | 2 +- traefik/traefik.yml | 4 +- 20 files changed, 122 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/yaml.yaml diff --git a/.github/workflows/yaml.yaml b/.github/workflows/yaml.yaml new file mode 100644 index 00000000..1c0ada3f --- /dev/null +++ b/.github/workflows/yaml.yaml @@ -0,0 +1,40 @@ +# Do not edit this file! Make a pull request on changing +# github/workflows/yaml.yaml in +# https://github.com/itk-dev/devops_itkdev-docker if need be. + +### ### YAML +### +### Validates YAML files. +### +### #### Assumptions +### +### 1. A docker compose service named `prettier` for running +### [Prettier](https://prettier.io/) exists. +### +### #### Symfony YAML +### +### Symfony's YAML config files use 4 spaces for indentation and single quotes. +### Therefore we use a [Prettier configuration +### file](https://prettier.io/docs/configuration), `.prettierrc.yaml`, to make +### Prettier format YAML files in the `config/` folder like Symfony expects. + +name: YAML + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + yaml-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - run: | + docker network create frontend + + - run: | + docker compose run --rm prettier '**/*.{yml,yaml}' --check diff --git a/Taskfile.yml b/Taskfile.yml index c9f37f61..3ce3dc80 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,6 +1,6 @@ # https://taskfile.dev -version: '3' +version: "3" includes: github-actions: ./task/Taskfile.github-actions.yml diff --git a/compose.yaml b/compose.yaml index a2be8aa3..d3f6f829 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,3 +5,14 @@ services: - dev volumes: - ./:/md + + prettier: + # Prettier does not (yet, fcf. + # https://github.com/prettier/prettier/issues/15206) have an official + # docker image. + # https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc) + image: jauderho/prettier + profiles: + - dev + volumes: + - ./:/work diff --git a/task/Taskfile.github-actions.yml b/task/Taskfile.github-actions.yml index 1f5df23e..f92d3e1a 100644 --- a/task/Taskfile.github-actions.yml +++ b/task/Taskfile.github-actions.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" tasks: documentation:update: @@ -19,7 +19,7 @@ tasks: - git diff --exit-code --ignore-blank-lines --ignore-matching-lines='automatically created' '*.md' documentation:checkout: - desc: 'git checkout all translation file changes if only date metadata is changed' + desc: "git checkout all translation file changes if only date metadata is changed" cmds: - git checkout '*.md' # https://taskfile.dev/reference/schema#precondition diff --git a/templates/drupal-10/docker-compose.server.yml b/templates/drupal-10/docker-compose.server.yml index 6f984b5a..363b08e0 100644 --- a/templates/drupal-10/docker-compose.server.yml +++ b/templates/drupal-10/docker-compose.server.yml @@ -52,7 +52,7 @@ services: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" memcached: - image: 'memcached:latest' + image: "memcached:latest" restart: unless-stopped networks: - app diff --git a/templates/drupal-10/docker-compose.yml b/templates/drupal-10/docker-compose.yml index 130da86b..5b35a905 100644 --- a/templates/drupal-10/docker-compose.yml +++ b/templates/drupal-10/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php8.3-fpm:latest @@ -62,7 +62,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -75,16 +75,16 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" memcached: image: memcached:alpine networks: - app ports: - - '11211' + - "11211" healthcheck: test: echo "version" | nc -vn -w 1 127.0.0.1 11211 interval: 10s diff --git a/templates/drupal-11/docker-compose.server.yml b/templates/drupal-11/docker-compose.server.yml index e4306ba1..96d401b5 100644 --- a/templates/drupal-11/docker-compose.server.yml +++ b/templates/drupal-11/docker-compose.server.yml @@ -52,7 +52,7 @@ services: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" memcached: - image: 'memcached:latest' + image: "memcached:latest" restart: unless-stopped networks: - app diff --git a/templates/drupal-11/docker-compose.yml b/templates/drupal-11/docker-compose.yml index 3f1aa268..826b71ec 100644 --- a/templates/drupal-11/docker-compose.yml +++ b/templates/drupal-11/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -59,7 +59,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -81,7 +81,7 @@ services: networks: - app ports: - - '11211' + - "11211" healthcheck: test: echo "version" | nc -vn -w 1 127.0.0.1 11211 interval: 10s diff --git a/templates/drupal-7/docker-compose.server.yml b/templates/drupal-7/docker-compose.server.yml index 2ffbf547..023a758d 100644 --- a/templates/drupal-7/docker-compose.server.yml +++ b/templates/drupal-7/docker-compose.server.yml @@ -51,7 +51,7 @@ services: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" memcached: - image: 'memcached:latest' + image: "memcached:latest" restart: unless-stopped networks: - app diff --git a/templates/drupal-7/docker-compose.yml b/templates/drupal-7/docker-compose.yml index e79bb13a..628cc8c5 100644 --- a/templates/drupal-7/docker-compose.yml +++ b/templates/drupal-7/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php7.4-fpm:latest @@ -61,7 +61,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -74,16 +74,16 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" memcached: - image: 'memcached:latest' + image: "memcached:latest" networks: - app ports: - - '11211' + - "11211" healthcheck: test: echo "version" | nc -vn -w 1 127.0.0.1 11211 interval: 10s diff --git a/templates/drupal-8/docker-compose.server.yml b/templates/drupal-8/docker-compose.server.yml index d5a39d2d..4114feba 100644 --- a/templates/drupal-8/docker-compose.server.yml +++ b/templates/drupal-8/docker-compose.server.yml @@ -50,7 +50,7 @@ services: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" memcached: - image: 'memcached:latest' + image: "memcached:latest" restart: unless-stopped networks: - app diff --git a/templates/drupal-8/docker-compose.yml b/templates/drupal-8/docker-compose.yml index da6b4b0a..e1fac7fa 100644 --- a/templates/drupal-8/docker-compose.yml +++ b/templates/drupal-8/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php8.0-fpm:latest @@ -60,7 +60,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -73,16 +73,16 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" memcached: - image: 'memcached:latest' + image: "memcached:latest" networks: - app ports: - - '11211' + - "11211" healthcheck: test: echo "version" | nc -vn -w 1 127.0.0.1 11211 interval: 10s diff --git a/templates/drupal-9/docker-compose.server.yml b/templates/drupal-9/docker-compose.server.yml index 50770aa3..6dc4546a 100644 --- a/templates/drupal-9/docker-compose.server.yml +++ b/templates/drupal-9/docker-compose.server.yml @@ -52,7 +52,7 @@ services: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" memcached: - image: 'memcached:latest' + image: "memcached:latest" restart: unless-stopped networks: - app diff --git a/templates/drupal-9/docker-compose.yml b/templates/drupal-9/docker-compose.yml index 839a0b84..f9401dbf 100644 --- a/templates/drupal-9/docker-compose.yml +++ b/templates/drupal-9/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php8.3-fpm:latest @@ -62,7 +62,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -75,16 +75,16 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" memcached: - image: 'memcached:latest' + image: "memcached:latest" networks: - app ports: - - '11211' + - "11211" healthcheck: test: echo "version" | nc -vn -w 1 127.0.0.1 11211 interval: 10s diff --git a/templates/symfony-3/docker-compose.server.yml b/templates/symfony-3/docker-compose.server.yml index 94f7368a..cfe2c112 100644 --- a/templates/symfony-3/docker-compose.server.yml +++ b/templates/symfony-3/docker-compose.server.yml @@ -46,4 +46,3 @@ services: - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_SERVER_DOMAIN}`)" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=websecure" - diff --git a/templates/symfony-3/docker-compose.yml b/templates/symfony-3/docker-compose.yml index e986e846..04a5ae6a 100644 --- a/templates/symfony-3/docker-compose.yml +++ b/templates/symfony-3/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php7.2-fpm:latest @@ -46,7 +46,7 @@ services: - PHP_IDE_CONFIG=serverName=localhost depends_on: mariadb: - condition: service_healthy + condition: service_healthy volumes: - .:/app @@ -58,7 +58,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -71,9 +71,9 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" mail: image: axllent/mailpit diff --git a/templates/symfony-4/docker-compose.yml b/templates/symfony-4/docker-compose.yml index d6af9603..c3645644 100644 --- a/templates/symfony-4/docker-compose.yml +++ b/templates/symfony-4/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. # https://symfony.com/doc/current/setup/symfony_server.html#docker-integration labels: - com.symfony.server.service-prefix: 'DATABASE' + com.symfony.server.service-prefix: "DATABASE" phpfpm: image: itkdev/php7.4-fpm:latest @@ -46,7 +46,7 @@ services: - PHP_IDE_CONFIG=serverName=localhost depends_on: mariadb: - condition: service_healthy + condition: service_healthy volumes: - .:/app @@ -58,7 +58,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -71,9 +71,9 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" mail: image: axllent/mailpit diff --git a/templates/symfony-6/docker-compose.yml b/templates/symfony-6/docker-compose.yml index 6edca922..b5c08946 100644 --- a/templates/symfony-6/docker-compose.yml +++ b/templates/symfony-6/docker-compose.yml @@ -12,9 +12,9 @@ services: networks: - app ports: - - '3306' + - "3306" healthcheck: - test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s @@ -55,7 +55,7 @@ services: depends_on: - phpfpm ports: - - '8080' + - "8080" volumes: - ./.docker/templates:/etc/nginx/templates:ro - .:/app @@ -68,9 +68,9 @@ services: - "traefik.enable=true" - "traefik.docker.network=frontend" - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)" -# HTTPS config - uncomment to enable redirect from :80 to :443 -# - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" -# - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + # HTTPS config - uncomment to enable redirect from :80 to :443 + # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" + # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" mail: image: axllent/mailpit diff --git a/traefik/dynamic-conf.yaml b/traefik/dynamic-conf.yaml index c5214327..e87c11cc 100644 --- a/traefik/dynamic-conf.yaml +++ b/traefik/dynamic-conf.yaml @@ -3,7 +3,7 @@ http: ITKMetricsAuth: basicAuth: users: - - 'metrics:$apr1$NN0pEsue$o.K99fyHjlf8XpOh1NA8Y.' + - "metrics:$apr1$NN0pEsue$o.K99fyHjlf8XpOh1NA8Y." tls: certificates: diff --git a/traefik/traefik.yml b/traefik/traefik.yml index 2b7fa5d7..2840741b 100644 --- a/traefik/traefik.yml +++ b/traefik/traefik.yml @@ -1,4 +1,3 @@ - api: dashboard: true insecure: true @@ -10,8 +9,7 @@ entryPoints: https: address: ":443" http: - tls: - {} + tls: {} providers: file: