From 0d04d02d953f13e797863acae50f87657cdb0ac0 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 18 Mar 2025 11:30:31 +0100 Subject: [PATCH 01/27] 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 0000000..3d5459c --- /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 0000000..26ba479 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.task diff --git a/README.md b/README.md index 4b532d2..6470e6e 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 0000000..4a2f11a --- /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 0000000..37d8959 --- /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 0000000..dc56f3d --- /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 0000000..5353c71 --- /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 0000000..b62c51a --- /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 0000000..2a0bb2a --- /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 0000000..c8dfe23 --- /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/27] 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 3d5459c..5dc4164 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 0000000..096a25d --- /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 0000000..e25be49 --- /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 0000000..bf17535 --- /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 4a2f11a..ef25905 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 5a1752c70f5ffe770a4aa921487c20ce9faf962d Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:38:40 +0100 Subject: [PATCH 03/27] 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 2a0bb2a..6667b4c 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 6366b2e5f05ecf6992b4d92e1e50342f97db28a3 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:39:16 +0100 Subject: [PATCH 04/27] 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 c8dfe23..da31105 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 f67e9ae93b323e118e3ccf1240a7a374910008a7 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:39:31 +0100 Subject: [PATCH 05/27] 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 dc56f3d..3869d41 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 32774adf44aa2c77ff221cf37009d2d50d66962b Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:40:18 +0100 Subject: [PATCH 06/27] 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 6667b4c..28894ef 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 678951b2fa8553e15b36561f6f06ddeb485a6440 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 09:52:04 +0100 Subject: [PATCH 07/27] 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 5353c71..404326b 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 a42cb1f236eb463eb2f416bac7ac49c0fe920695 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 10:55:28 +0100 Subject: [PATCH 08/27] 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 5dc4164..ead2e3b 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 ef25905..20fad9a 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 28894ef..aa65bd6 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 da31105..22ac959 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 2f0702f..12df4d7 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 ef8d484a83015ebfc5ceb564a00542de051ec4a7 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 11:08:17 +0100 Subject: [PATCH 09/27] 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 096a25d..0000000 --- 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 0000000..12df4d7 --- /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 8bc03ac386d39e63629c38e0f6527fbd452be082 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 24 Mar 2025 11:13:25 +0100 Subject: [PATCH 10/27] 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 ead2e3b..ec04345 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 20fad9a..9e7386e 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 9f892dec7662f3c8b73e6194643c550fd30f5433 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 2 Apr 2025 13:33:28 +0200 Subject: [PATCH 11/27] 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 ec04345..6d10629 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 e25be49..0000000 --- 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 0000000..37d8959 --- /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 bf17535..0000000 --- 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 0000000..3869d41 --- /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 9e7386e..2f29191 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 0000000..e69de29 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 0000000..f36cb79 --- /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 0000000..e69de29 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 0000000..13d932a --- /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 404326b..0000000 --- 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 0000000..86406b7 --- /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 b62c51a..483da6e 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 aa65bd6..4586cbc 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 0000000..0c41612 --- /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 22ac959..ea13035 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 0000000..8696a80 --- /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 12df4d7..b490284 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 0000000..7f4e1d6 --- /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 0000000..a0e1845 --- /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 0000000..95b0a2b --- /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 0000000..71ccfd3 --- /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 0000000..84062ef --- /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 0000000..4806316 --- /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 0000000..c6e181e --- /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/27] 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 2f29191..9a621dc 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 0000000..e3edb52 --- /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 e69de29..0000000 diff --git a/config/drupal/twig/.twig-cs-fixer.dist.php b/config/drupal/twig/.twig-cs-fixer.dist.php index f36cb79..427f75c 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 0000000..7556896 --- /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 e69de29..0000000 diff --git a/config/symfony/twig/.twig-cs-fixer.dist.php b/config/symfony/twig/.twig-cs-fixer.dist.php index 13d932a..427f75c 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 86406b7..9c738b5 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 0c41612..21722fb 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 ea13035..3a5328b 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 a0e1845..a567fa8 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 95b0a2b..7cff4ff 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 71ccfd3..e6598c0 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 0000000..f7ce5f7 --- /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 c6e181e..0000000 --- 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 0000000..7822d8d --- /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 4806316..94dca58 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 ec1343e..9367a86 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 3ce13d0..001dbf2 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 0000000..1729590 --- /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 ec1343e..9367a86 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 3ce13d0..001dbf2 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 0000000..1729590 --- /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 ec1343e..9367a86 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 3ce13d0..001dbf2 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 0000000..1729590 --- /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 ec1343e..9367a86 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 3ce13d0..001dbf2 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 0000000..1729590 --- /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 6e3ebf6..e5388fe 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 0000000..4527ff8 --- /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 6e3ebf6..e5388fe 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 0000000..4527ff8 --- /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 6e3ebf6..e5388fe 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 0000000..4527ff8 --- /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 cc5a513ac9657d1d7c6cff72220cadaf3687edbc Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 12:47:28 +0200 Subject: [PATCH 13/27] 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 e3edb52..70d19cd 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 427f75c..0a0f295 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 c07e6bbdf83e63ea582f307595635897314ccb60 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 13:15:31 +0200 Subject: [PATCH 14/27] 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 6d10629..5dfad4d 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 9a621dc..54c3f82 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 c67a21a..1f5df23 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 0000000..16e1538 --- /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 46c27d0..5b71f4c 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 0000000..1e3ade3 --- /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 c601873742688eb2e862f71a778e59da137126f2 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 8 Apr 2025 13:31:40 +0200 Subject: [PATCH 15/27] 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 9c738b5..b7126b6 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 94dca58..d9c0b0d 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 6610aeef7ba156ce1a67e9acbf06fdeba62df713 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 9 Apr 2025 11:30:41 +0200 Subject: [PATCH 16/27] 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 6470e6e..c6244b1 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 70d19cd..c8f54bd 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 b7126b6..94e02d8 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 21722fb..b0d3ac7 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 b490284..c62b17f 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 a567fa8..9245f78 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 16e1538..035f27d 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 7822d8d..6eb978d 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 d9c0b0d..078b035 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 7996f3711ff472d5cc46b159ed07d894d9bb3f52 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 23 Apr 2025 13:16:57 +0200 Subject: [PATCH 17/27] 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 4586cbc..fe13351 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 b0d3ac7..1bd5a93 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 3a5328b..6e92636 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 c62b17f..5a951fa 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 7cff4ff..9b0e343 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 fb1efe1ea1d669c8f9e3b0353afd76201b9da58a Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 11:07:36 +0200 Subject: [PATCH 18/27] 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 94e02d8..d1a8253 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 0000000..cd94449 --- /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 7f4e1d6..0000000 --- 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 2281239669ad3da9958ccb84447a79ba7258cd6e Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 11:35:36 +0200 Subject: [PATCH 19/27] 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 0000000..c2f0d12 --- /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 f23708db27f1ef40c96fa112d1bfbb402f4d24ad Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 13:42:02 +0200 Subject: [PATCH 20/27] 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 c2f0d12..74a0ffa 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 54c3f82..0fe253d 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 6e92636..70561cb 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 f7ce5f7..e2fad1b 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 12386c3e1e5788160dd658833e8377ac876b5989 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 13:48:56 +0200 Subject: [PATCH 21/27] 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 0fe253d..6f2c990 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 d1a8253..aa30f7c 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 cd94449..f10bbcf 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 020b58b..b3e30b7 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 0000000..5ffe5c3 --- /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 0000000..2395564 --- /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 0000000..b272c00 --- /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 0000000..ab3eafa --- /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 0000000..9367a86 --- /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 0000000..001dbf2 --- /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 0000000..b3e30b7 --- /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 0000000..649f1cd --- /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 0000000..1a3d9af --- /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 0000000..0a61367 --- /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 0000000..1729590 --- /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 0000000..7330065 --- /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 020b58b..b3e30b7 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 020b58b..b3e30b7 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 020b58b..b3e30b7 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 020b58b..0000000 --- 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 020b58b..0000000 --- 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 020b58b..0000000 --- a/templates/symfony-6/.github/workflows/styles.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/styles.yaml \ No newline at end of file From e0589c1eb3ac44406e3713700f21a491d623b8ee Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 10:21:15 +0200 Subject: [PATCH 22/27] 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 aa30f7c..8aac76e 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 0000000..c4005a4 --- /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 f10bbcf..c94c078 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 8696a80..0000000 --- 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 c01409ad405f5a22150b0e0cf94d8d5197ce0d9f Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 12:25:12 +0200 Subject: [PATCH 23/27] 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 c4005a4..65d5468 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 b272c00..e76b3a5 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 b272c00..e76b3a5 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 b272c00..e76b3a5 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 b272c00..e76b3a5 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 b272c00..e76b3a5 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 b272c00..0000000 --- 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 b272c00..0000000 --- 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 b272c00..0000000 --- a/templates/symfony-6/.github/workflows/javascript.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../github/workflows/javascript.yaml \ No newline at end of file From 1093f59e6fd3380b9c3ec68d61e12f3e90b0e7b8 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 5 May 2025 14:30:30 +0200 Subject: [PATCH 24/27] 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 74a0ffa..b7f8cf7 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 917b114e56f44edeebb59387f583d422e8dca18c Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 6 May 2025 10:06:17 +0200 Subject: [PATCH 25/27] Updated Markdownlint ignores --- config/markdown/.markdownlintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/config/markdown/.markdownlintignore b/config/markdown/.markdownlintignore index 49046b7..d143ace 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 b53a8fcd16f04c22c82d1d32391c6c2dc91d5718 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 6 May 2025 10:13:40 +0200 Subject: [PATCH 26/27] 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 12df4d7..60fc0ee 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 0000000..a2be8aa --- /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 8aac76e..1bd0c19 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 5a951fa..60fc0ee 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 042a574fbb583c609f7fd2958e91080f991900e5 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 7 May 2025 13:06:48 +0200 Subject: [PATCH 27/27] 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 6f2c990..50d1028 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 1bd0c19..e5fd6da 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 0000000..5b20c8d --- /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 9245f78..60fb70e 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 0000000..c6dec50 --- /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 0000000..32f4e11 --- /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 0000000..af396b4 --- /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 0000000..32f4e11 --- /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 0000000..af396b4 --- /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 0000000..32f4e11 --- /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 0000000..af396b4 --- /dev/null +++ b/templates/symfony-6/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/symfony/styles.yaml \ No newline at end of file