Skip to content

Commit c26f25a

Browse files
committed
Cleaned up and improved
1 parent 52aea36 commit c26f25a

File tree

95 files changed

+597
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+597
-138
lines changed

.github/workflows/documentation.yaml

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: pull_request
33
name: Review
44

55
env:
6-
COMPOSE_USER: root
6+
COMPOSE_USER: runner
77

88
jobs:
99
check-github-actions-documentation:
@@ -12,20 +12,34 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
- uses: arduino/setup-task@v2
15+
# https://github.com/arduino/setup-task/tree/56d0cc033e3cecc5f07a291fdd39f29388d21800?tab=readme-ov-file#repo-token
16+
with:
17+
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
# https://github.com/mxschmitt/action-tmate?tab=readme-ov-file#manually-triggered-debug
20+
# Enable tmate debugging if debug logging is enabled (cf.
21+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context)
22+
- name: Setup tmate session
23+
uses: mxschmitt/action-tmate@v3
24+
if: 1 == runner.debug
25+
1526
- run: |
1627
task github-actions:documentation:update
28+
1729
# Check that documentation has not changed.
1830
- run: |
19-
git diff --exit-code docs/github-action-templates.md
31+
task github-actions:documentation:diff
2032
2133
check-github-actions-template-headers:
2234
runs-on: ubuntu-latest
2335
name: Check that Github Actions template headers are up to date
2436
steps:
2537
- uses: actions/checkout@v4
2638
- uses: arduino/setup-task@v2
39+
with:
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}
2741
- run: |
28-
task github-actions:update-headers --yes
42+
task github-actions:template-headers:update --yes
2943
# Check that files hav not changed.
3044
- run: |
3145
git diff --exit-code github/workflows/

.markdownlint.jsonc

-1
This file was deleted.

.markdownlint.jsonc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// markdownlint-cli configuration file (cf. https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration)
2+
{
3+
"default": true,
4+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
5+
"line-length": {
6+
"line_length": 120,
7+
"code_blocks": false,
8+
"tables": false
9+
},
10+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
11+
"no-duplicate-heading": {
12+
"siblings_only": true
13+
},
14+
// https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section
15+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
16+
"no-inline-html": {
17+
"allowed_elements": ["details", "summary"]
18+
}
19+
}

.markdownlintignore

-1
This file was deleted.

.markdownlintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files
2+
vendor/
3+
node_modules/
4+
LICENSE.md
5+
# Drupal
6+
web/*.md
7+
web/core/
8+
web/*/contrib/

Taskfile.yml

+5-54
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
version: '3'
44

5+
includes:
6+
github-actions: ./task/Tasfile.github-actions.yml
7+
58
vars:
69
GITHUB_ACTIONS_TEMPLATES_HEADER: |
710
# Github Actions templates
@@ -16,63 +19,11 @@ vars:
1619
GITHUB_ACTIONS_TEMPLATES_FOOTER: |
1720
1821
tasks:
19-
github-actions:documentation:update:
20-
desc: "Update GitHub Actions template documentation"
21-
sources:
22-
- github/workflows/*.yaml
23-
generates:
24-
- docs/github-action-templates.md
25-
cmds:
26-
- mkdir -p docs
27-
- |
28-
echo '{{.GITHUB_ACTIONS_TEMPLATES_HEADER}}' > docs/github-action-templates.md
29-
- |
30-
for f in github/workflows/*.yaml; do
31-
echo "" >> docs/github-action-templates.md
32-
echo "---" >> docs/github-action-templates.md
33-
echo "" >> docs/github-action-templates.md
34-
35-
echo "[$f]($f)" >> docs/github-action-templates.md
36-
37-
cat "$f" | grep -E '^###( |$)' | sed -E -e 's/^### ?//' >> docs/github-action-templates.md
38-
done
39-
- |
40-
echo "{{.GITHUB_ACTIONS_TEMPLATES_FOOTER}}" >> docs/github-action-templates.md
41-
# Link to clean up.
42-
- task lint:markdown -- docs/github-action-templates.md
43-
44-
github-actions:update-headers:
45-
prompt: "Updating headers may break things, so check result afterwards. Really update headers?"
46-
desc: "Update headers in GitHub Actions templates"
47-
cmds:
48-
- |
49-
for f in github/workflows/*.yaml; do
50-
echo "$f"
51-
# If file starts with `# ` …
52-
if [[ $(head --lines=1 "$f") =~ "^# " ]]; then
53-
# … replace the header.
54-
# This is done by deleting all lines from the top of the file to a blank line.
55-
docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f"
56-
fi
57-
58-
# Write header and file into temporary file.
59-
(
60-
echo "# Do not edit this file! Make a pull request on changing";
61-
echo "# $f in";
62-
echo "# https://github.com/itk-dev/devops_itkdev-docker if need be.";
63-
echo "";
64-
cat "$f"
65-
) > "$f.tmp"
66-
# Replace original file with temporary file.
67-
mv "$f.tmp" "$f"
68-
done
69-
7022
lint:markdown:
7123
desc: "Lint Markdown"
7224
cmds:
73-
# I cannot get itkdev/markdownlint to work as expected, i.e. as peterdavehello/markdownlint does …
74-
- docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}} --fix
75-
- docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint {{.GLOB}}
25+
- '[[ -n "$SKIP_FIX" ]] || docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}} --fix'
26+
- docker run --rm --volume "$PWD":/md itkdev/markdownlint markdownlint {{.GLOB}}
7627
vars:
7728
# We use a block scalar (https://yaml-multiline.info/#block-scalars) here to make escaping (a little) easier.
7829
GLOB: >-

config/drupal/php/phpcs.xml

Whitespace-only changes.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file
3+
4+
$finder = new TwigCsFixer\File\Finder();
5+
6+
if (glob('web/*/custom/*/templates')) {
7+
$finder->in('web/*/custom/*/templates');
8+
}
9+
// Include sub-modules or sub-themes
10+
if (glob('web/*/custom/*/*/templates')) {
11+
$finder->in('web/*/custom/*/*/templates');
12+
}
13+
14+
$config = new TwigCsFixer\Config\Config();
15+
$config->setFinder($finder);
16+
17+
return $config;

config/symfony/php/php-cs-fixer.php.dist

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
// https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file
3+
4+
$finder = new TwigCsFixer\File\Finder();
5+
$finder->in('templates');
6+
7+
$config = new TwigCsFixer\Config\Config();
8+
$config->setFinder($finder);
9+
10+
return $config;

docs/github-action-templates.md

-69
This file was deleted.

docs/github-actions-templates.md

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!-- DO NOT EDIT THIS FILE!
2+
3+
It was automatically created by task/github-documentation-update.sh at Fri Apr 4 13:49:36 CEST 2025.
4+
-->
5+
# Github Actions templates
6+
7+
This repository contains a number of [GitHub Actions](https://docs.github.com/en/actions) workflow template files that
8+
are copied to a project when running `itkdev-docker-compose template:install`. Any changes to the workflows should be
9+
made in [this repository](https://github.com/itk-dev/devops_itkdev-docker) and then the project template must be updated
10+
to match the new templates.
11+
12+
## Naming conventions
13+
14+
* Named after what a tool is concerned with, not how it's concerned with it.
15+
* Some configuration based on template type (drupal, symfony)
16+
17+
## Templates
18+
19+
---
20+
21+
[github/workflows/changelog.yaml](github/workflows/changelog.yaml)
22+
23+
### Changelog
24+
25+
Checks that changelog has been updated
26+
27+
---
28+
29+
[github/workflows/composer.yaml](github/workflows/composer.yaml)
30+
31+
### Composer
32+
33+
Validates composer.json and checks that it's normalized.
34+
35+
#### Assumptions
36+
37+
1. A docker compose service named `phpfpm` can be run and `composer` can be
38+
run inside the `phpfpm` service.
39+
2. [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize)
40+
is a dev requirement in `composer.json`:
41+
42+
``` shell
43+
docker compose run --rm phpfpm composer require --dev ergebnis/composer-normalize
44+
```
45+
46+
Normalize `composer.json` by running
47+
48+
``` shell
49+
docker compose run --rm phpfpm composer normalize
50+
```
51+
52+
---
53+
54+
[github/workflows/drupal-php.yaml](github/workflows/drupal-php.yaml)
55+
56+
Drupal PHP
57+
58+
---
59+
60+
[github/workflows/drupal-site.yaml](github/workflows/drupal-site.yaml)
61+
62+
### Drupal
63+
64+
Checks that site can be installed and can be updated (from base branch on
65+
pull request).
66+
67+
#### Assumptions
68+
69+
1. A docker compose service named `phpfpm` can be run and `composer` can be
70+
run inside the `phpfpm` service.
71+
2. The docker setup contains a database container and other the dependent services and the
72+
3. The Drupal site can be installed from existing config.
73+
74+
---
75+
76+
[github/workflows/javascript.yaml](github/workflows/javascript.yaml)
77+
78+
JavaScript (and TypeScript)
79+
80+
---
81+
82+
[github/workflows/markdown.yaml](github/workflows/markdown.yaml)
83+
84+
### Markdown
85+
86+
Uses [itkdev/markdownlint](https://hub.docker.com/r/itkdev/markdownlint) to
87+
link all Markdown files (`**/*.md`) in the project.
88+
89+
[markdownlint-cli configuration ### files](https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#configuration),
90+
`.markdownlint.jsonc` and `.markdownlintignore` control what is actually linted and how.
91+
92+
---
93+
94+
[github/workflows/styles.yaml](github/workflows/styles.yaml)
95+
96+
Styles (CSS and SCSS)
97+
98+
---
99+
100+
[github/workflows/symfony-php.yaml](github/workflows/symfony-php.yaml)
101+
102+
Symfony PHP
103+
104+
---
105+
106+
[github/workflows/twig.yaml](github/workflows/twig.yaml)
107+
108+
### Twigt
109+
110+
Validates Twig files
111+
112+
#### Assumptions
113+
114+
1. A docker compose service named `phpfpm` can be run and `composer` can be
115+
run inside the `phpfpm` service.
116+
2. [vincentlanglet/twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer)
117+
is a dev requirement in `composer.json`:
118+
119+
``` shell
120+
docker compose run --rm phpfpm composer require --dev vincentlanglet/twig-cs-fixer
121+
```
122+
123+
3. A [Configuration
124+
file](https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file)
125+
in the root of the project defines which files to check and rules to use.
126+
127+
---

github/workflows/changelog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# github/workflows/changelog.yaml in
33
# https://github.com/itk-dev/devops_itkdev-docker if need be.
44

5-
### ## Changelog
5+
### ### Changelog
66
###
77
### Checks that changelog has been updated
88

0 commit comments

Comments
 (0)