Skip to content

Commit 8985de3

Browse files
committed
More clean up
1 parent c26f25a commit 8985de3

File tree

32 files changed

+74
-60
lines changed

32 files changed

+74
-60
lines changed

Taskfile.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
version: '3'
44

55
includes:
6-
github-actions: ./task/Tasfile.github-actions.yml
6+
github-actions: ./task/Taskfile.github-actions.yml
77

88
vars:
99
GITHUB_ACTIONS_TEMPLATES_HEADER: |

config/drupal/twig/.twig-cs-fixer.dist.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
// https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file
33

44
$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-
}
5+
// Check all files …
6+
$finder->in(__DIR__);
7+
// … that are not ignored by VSC
8+
$finder->ignoreVCSIgnored(true);
139

1410
$config = new TwigCsFixer\Config\Config();
1511
$config->setFinder($finder);

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
// https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file
33

44
$finder = new TwigCsFixer\File\Finder();
5-
$finder->in('templates');
5+
// Check all files …
6+
$finder->in(__DIR__);
7+
// … that are not ignored by VSC
8+
$finder->ignoreVCSIgnored(true);
69

710
$config = new TwigCsFixer\Config\Config();
811
$config->setFinder($finder);

docs/github-actions-templates.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- DO NOT EDIT THIS FILE!
22
3-
It was automatically created by task/github-documentation-update.sh at Fri Apr 4 13:49:36 CEST 2025.
3+
It was automatically created by task/scripts/github-documentation-update at Tue Apr 8 10:02:13 CEST 2025.
44
-->
55
# Github Actions templates
66

@@ -51,13 +51,13 @@ Validates composer.json and checks that it's normalized.
5151

5252
---
5353

54-
[github/workflows/drupal-php.yaml](github/workflows/drupal-php.yaml)
54+
[github/workflows/drupal/php.yaml](github/workflows/drupal/php.yaml)
5555

5656
Drupal PHP
5757

5858
---
5959

60-
[github/workflows/drupal-site.yaml](github/workflows/drupal-site.yaml)
60+
[github/workflows/drupal/site.yaml](github/workflows/drupal/site.yaml)
6161

6262
### Drupal
6363

@@ -97,15 +97,15 @@ Styles (CSS and SCSS)
9797

9898
---
9999

100-
[github/workflows/symfony-php.yaml](github/workflows/symfony-php.yaml)
100+
[github/workflows/symfony/php.yaml](github/workflows/symfony/php.yaml)
101101

102102
Symfony PHP
103103

104104
---
105105

106106
[github/workflows/twig.yaml](github/workflows/twig.yaml)
107107

108-
### Twigt
108+
### Twig
109109

110110
Validates Twig files
111111

File renamed without changes.
File renamed without changes.
File renamed without changes.

github/workflows/twig.yaml

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

5-
### ### Twigt
5+
### ### Twig
66
###
77
### Validates Twig files
88
###

task/Tasfile.github-actions.yml renamed to task/Taskfile.github-actions.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tasks:
66
cmds:
77
- task: run-script
88
vars:
9-
SCRIPT: task/github-documentation-update.sh
9+
SCRIPT: github-documentation-update
1010
- SKIP_FIX=1 task lint:markdown -- docs/github-actions-templates.md
1111

1212
documentation:diff:
@@ -45,7 +45,7 @@ tasks:
4545
if [[ $(head --lines=1 "$f") =~ "^# " ]]; then
4646
# … replace the header.
4747
# This is done by deleting all lines from the top of the file to a blank line.
48-
docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest sed -i '1,/^$/d' "$f"
48+
docker run --rm --volume=$PWD:/app --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest sed -i '1,/^$/d' "$f"
4949
fi
5050
5151
# Write header and file into temporary file.
@@ -66,7 +66,7 @@ tasks:
6666
cmds:
6767
- task: run-script
6868
vars:
69-
SCRIPT: task/github-actions-link.sh
69+
SCRIPT: github-actions-link
7070
silent: true
7171

7272
show:
@@ -78,7 +78,7 @@ tasks:
7878
run-script:
7979
internal: true
8080
cmds:
81-
- docker run --rm --volume "$PWD:/app" --user ${COMPOSE_USER:-deploy} itkdev/php8.3-fpm:latest {{.SCRIPT}}
81+
- docker run --rm --volume "$PWD:/app" --user ${COMPOSE_USER:-deploy} itkdev/php8.4-fpm:latest task/scripts/{{.SCRIPT}}
8282
requires:
8383
vars:
8484
- SCRIPT

task/docs/github-actions-templates.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- DO NOT EDIT THIS FILE!
2+
3+
It was automatically created by task/scripts/github-documentation-update.sh at Tue Apr 8 09:33:44 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/*.yaml](github/workflows/*.yaml)
22+
23+
24+
---

task/links.png

-5.13 KB
Binary file not shown.

task/github-actions-link.sh renamed to task/scripts/github-actions-link

+9-25
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ set -o errexit -o errtrace -o noclobber -o nounset -o pipefail
33
IFS=$'\n\t'
44

55
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
6-
project_dir=$(cd "$(dirname "$script_dir")" && pwd)
6+
project_dir=$(cd "$(dirname "$script_dir")/.." && pwd)
77

88
cd "$project_dir" || exit
99

1010
# String type (drupal or symfony) from start of name
1111
function strip-project-type() {
1212
name=$1
1313

14-
if [[ "$name" =~ ^(drupal-|symfony-)(.+) ]]; then
14+
if [[ "$name" =~ ^(drupal|symfony)/(.+) ]]; then
1515
name="${BASH_REMATCH[2]}"
1616
fi
1717

@@ -36,19 +36,19 @@ for template_dir in templates/*; do
3636
exit 1
3737
fi
3838

39-
for f in github/workflows/*.yaml; do
40-
file_name=$(basename "$f")
39+
for f in $(find github/workflows/ -name '*.yaml' | sort); do
4140
source_file_name=''
42-
if [[ "$file_name" =~ ^drupal- ]]; then
41+
# Note: / is NOT a regex delimiter here, but an actual /, i.e. a directory separator.
42+
if [[ "$f" =~ /drupal/ ]]; then
4343
if [[ "$project_type" == "drupal" ]]; then
44-
source_file_name="$file_name"
44+
source_file_name="$(basename $(dirname "$f"))/$(basename "$f")"
4545
fi
46-
elif [[ "$file_name" =~ ^symfony- ]]; then
46+
elif [[ "$f" =~ /symfony/ ]]; then
4747
if [[ "$project_type" == "symfony" ]]; then
48-
source_file_name="$file_name"
48+
source_file_name="$(basename $(dirname "$f"))/$(basename "$f")"
4949
fi
5050
else
51-
source_file_name="$file_name"
51+
source_file_name=$(basename "$f")
5252
fi
5353

5454
if [[ -n "$source_file_name" ]]; then
@@ -82,19 +82,3 @@ for template_dir in templates/*; do
8282
find "$template_dir" -type l -ls
8383
echo
8484
done
85-
86-
# Generate Mermaid graph showing links
87-
mermaid_file_name="$script_dir/links.mermaid"
88-
89-
cat >| "$mermaid_file_name" <<'EOF'
90-
graph TD
91-
EOF
92-
for link in $(find templates -type l); do
93-
link_id=$(base64 <<< $link)
94-
link_id=${link_id//=}
95-
96-
target=$(readlink $link)
97-
target_id=$(base64 <<< $target)
98-
target_id=${target_id//=}
99-
echo " $link_id[$link] --> $target_id[$target]" >> "$mermaid_file_name"
100-
done

task/github-documentation-update.sh renamed to task/scripts/github-documentation-update

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# IFS=$'\n\t'
44

55
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
6-
project_dir=$(cd "$(dirname "$script_dir")" && pwd)
6+
project_dir=$(cd "$(dirname "$script_dir")/.." && pwd)
77

88
cd "$project_dir" || exit
99

10-
template_file_name="$script_dir/github-actions-templates.md"
10+
template_file_name="$script_dir/../templates/github-actions-templates.md"
1111

1212
place_holder="insert:templates:here"
13-
place_holder_line=$(grep --line-number --no-filename "$place_holder" task/github-actions-templates.md | cut -d: -f1)
13+
place_holder_line=$(grep --line-number --no-filename "$place_holder" "$template_file_name" | cut -d: -f1)
1414

1515
if [[ -z "$place_holder_line" ]]; then
1616
(>&2 echo "Cannot find placeholder $place_holder in $template_file_name")
@@ -34,7 +34,7 @@ EOF
3434
# Template content before place holder
3535
head --lines="$((place_holder_line-1))" "$template_file_name" >> "$output_file_name"
3636

37-
for f in github/workflows/*.yaml; do
37+
for f in $(find github/workflows/ -name '*.yaml' | sort); do
3838
# Separator
3939
cat >> "$output_file_name" <<EOF
4040
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-php.yaml
1+
../../../../github/workflows/drupal/php.yaml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-site.yaml
1+
../../../../github/workflows/drupal/site.yaml

templates/drupal-10/phpcs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/drupal/php/phpcs.xml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-php.yaml
1+
../../../../github/workflows/drupal/php.yaml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-site.yaml
1+
../../../../github/workflows/drupal/site.yaml

templates/drupal-7/phpcs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/drupal/php/phpcs.xml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-php.yaml
1+
../../../../github/workflows/drupal/php.yaml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-site.yaml
1+
../../../../github/workflows/drupal/site.yaml

templates/drupal-8/phpcs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/drupal/php/phpcs.xml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-php.yaml
1+
../../../../github/workflows/drupal/php.yaml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/drupal-site.yaml
1+
../../../../github/workflows/drupal/site.yaml

templates/drupal-9/phpcs.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/drupal/php/phpcs.xml
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/symfony-php.yaml
1+
../../../../github/workflows/symfony/php.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/symfony/php/php-cs-fixer.php.dist
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/symfony-php.yaml
1+
../../../../github/workflows/symfony/php.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/symfony/php/php-cs-fixer.php.dist
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../../github/workflows/symfony-php.yaml
1+
../../../../github/workflows/symfony/php.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../config/symfony/php/php-cs-fixer.php.dist

0 commit comments

Comments
 (0)