diff --git a/config/drupal-module-ddev/markdown/.markdownlintignore b/config/drupal-module-ddev/markdown/.markdownlintignore new file mode 100644 index 0000000..747414b --- /dev/null +++ b/config/drupal-module-ddev/markdown/.markdownlintignore @@ -0,0 +1,17 @@ +# This file is copied from config/drupal-module-ddev/markdown/.markdownlintignore in https://github.com/itk-dev/devops_itkdev-docker. +# Feel free to edit the file, but consider making a pull request if you find a general issue with the file. + +# https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#ignoring-files +vendor/ +node_modules/ +LICENSE.md +# Python +.venv/ +# Drupal +web/*.md +web/core/ +web/libraries/ +web/*/contrib/ +# DDEV stuff +/web/ +/recipes/ diff --git a/config/drupal-module-ddev/php/.phpcs.xml.dist b/config/drupal-module-ddev/php/.phpcs.xml.dist new file mode 100644 index 0000000..ed57053 --- /dev/null +++ b/config/drupal-module-ddev/php/.phpcs.xml.dist @@ -0,0 +1,33 @@ + + + + + + The coding standard. + + . + + + node_modules + vendor + *.css + *.js + + web + + + + + + + + + + + + + + + + + diff --git a/config/drupal-module-ddev/prettier/.prettierignore b/config/drupal-module-ddev/prettier/.prettierignore new file mode 100644 index 0000000..fc24e0c --- /dev/null +++ b/config/drupal-module-ddev/prettier/.prettierignore @@ -0,0 +1,7 @@ +# This file is copied from config/drupal-module-ddev/prettier/.prettierignore in https://github.com/itk-dev/devops_itkdev-docker. +# Feel free to edit the file, but consider making a pull request if you find a general issue with the file. + +# Ignore all Drupal config since it is nearly all autogenerated by config-export +config/ +# Ignore all ddev files +.ddev/ diff --git a/config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php b/config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php new file mode 100644 index 0000000..d13be9e --- /dev/null +++ b/config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php @@ -0,0 +1,16 @@ +in(__DIR__); +// … that are not ignored by VCS +$finder->ignoreVCSIgnored(true); + +$config = new TwigCsFixer\Config\Config(); +$config->setFinder($finder); + +return $config; diff --git a/scripts/itkdev-docker-compose b/scripts/itkdev-docker-compose index 87e5547..09a9d16 100755 --- a/scripts/itkdev-docker-compose +++ b/scripts/itkdev-docker-compose @@ -123,6 +123,11 @@ function template_install { # https://linux.die.net/man/1/rsync#:~:text=%2DL%2C-,%2D%2Dcopy%2Dlinks,-When%20symlinks%20are) rsync --archive --copy-links "$source_dir" "$target_dir" + # We don't make .env files for drupal modules + if [[ "$name" =~ ^drupal-module ]]; then + exit + fi + local project_name_default=$(basename $target_dir) # Help user set up a .env file diff --git a/task/scripts/github-actions-link b/task/scripts/github-actions-link index c5951eb..83b59a8 100755 --- a/task/scripts/github-actions-link +++ b/task/scripts/github-actions-link @@ -11,7 +11,7 @@ cd "$project_dir" || exit function strip-project-type() { name=$1 - if [[ "$name" =~ ^(drupal(-module)?|symfony)/(.+) ]]; then + if [[ "$name" =~ ^(drupal(-[a-z-]+)?|symfony)/(.+) ]]; then name="${BASH_REMATCH[3]}" fi @@ -25,7 +25,10 @@ for template_dir in templates/*; do echo project_type="" - if [[ "$template_name" =~ ^drupal-module$ ]]; then + if [[ "$template_name" =~ ^drupal-module-ddev$ ]]; then + # The drupal-module-ddev template has its own workflow files; nothing to link. + continue + elif [[ "$template_name" =~ ^drupal-module$ ]]; then project_type="drupal-module" elif [[ "$template_name" =~ ^drupal(-|$) ]]; then project_type="drupal" @@ -42,7 +45,11 @@ for template_dir in templates/*; do for f in $(find github/workflows/ -name '*.yaml' | sort); do source_file_name='' # Note: / is NOT a regex delimiter here, but an actual /, i.e. a directory separator. - if [[ "$f" =~ /drupal-module/ ]]; then + if [[ "$f" =~ /drupal-module-ddev/ ]]; then + if [[ "$project_type" == "drupal-module-ddev" ]]; then + source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" + fi + elif [[ "$f" =~ /drupal-module/ ]]; then if [[ "$project_type" == "drupal-module" ]]; then source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")" fi diff --git a/templates/drupal-module-ddev/.github/workflows/changelog.yaml b/templates/drupal-module-ddev/.github/workflows/changelog.yaml new file mode 120000 index 0000000..5ffe5c3 --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/changelog.yaml @@ -0,0 +1 @@ +../../../../github/workflows/changelog.yaml \ No newline at end of file diff --git a/templates/drupal-module-ddev/.github/workflows/javascript.yaml b/templates/drupal-module-ddev/.github/workflows/javascript.yaml new file mode 120000 index 0000000..09fb93c --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/javascript.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal-module/javascript.yaml \ No newline at end of file diff --git a/templates/drupal-module-ddev/.github/workflows/markdown.yaml b/templates/drupal-module-ddev/.github/workflows/markdown.yaml new file mode 120000 index 0000000..ab3eafa --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/markdown.yaml @@ -0,0 +1 @@ +../../../../github/workflows/markdown.yaml \ No newline at end of file diff --git a/templates/drupal-module-ddev/.github/workflows/module.yaml b/templates/drupal-module-ddev/.github/workflows/module.yaml new file mode 100644 index 0000000..7daad43 --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/module.yaml @@ -0,0 +1,53 @@ +name: Module + +env: + COMPOSE_USER: runner + # https://getcomposer.org/doc/03-cli.md#composer-auth + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"} }' + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + php: + name: PHP + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: go-task/setup-task@v2 + # https://github.com/ddev/github-action-setup-ddev + - uses: ddev/github-action-setup-ddev@v1 + with: + autostart: false + + - name: Start DDEV + # https://github.com/ddev/ddev-drupal-contrib + run: | + ddev start + ddev poser --no-interaction --no-security-blocking + ddev symlink-project + + - name: Composer - validate + run: ddev composer validate --strict + + - name: Composer - normalize + run: ddev composer normalize --dry-run + + - name: PHP coding standards + run: ddev phpcs + + - name: Twig coding standards + run: ddev exec ./vendor/bin/twig-cs-fixer + + - name: Code analysis + run: ddev phpstan + + - name: Rector + run: ddev php vendor/bin/rector --dry-run + + - name: Composer - audit + run: ddev composer audit diff --git a/templates/drupal-module-ddev/.github/workflows/styles.yaml b/templates/drupal-module-ddev/.github/workflows/styles.yaml new file mode 120000 index 0000000..31ec030 --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/styles.yaml @@ -0,0 +1 @@ +../../../../github/workflows/drupal-module/styles.yaml \ No newline at end of file diff --git a/templates/drupal-module-ddev/.github/workflows/yaml.yaml b/templates/drupal-module-ddev/.github/workflows/yaml.yaml new file mode 120000 index 0000000..725a7d6 --- /dev/null +++ b/templates/drupal-module-ddev/.github/workflows/yaml.yaml @@ -0,0 +1 @@ +../../../../github/workflows/yaml.yaml \ No newline at end of file diff --git a/templates/drupal-module-ddev/.markdownlint.jsonc b/templates/drupal-module-ddev/.markdownlint.jsonc new file mode 120000 index 0000000..1a3d9af --- /dev/null +++ b/templates/drupal-module-ddev/.markdownlint.jsonc @@ -0,0 +1 @@ +../../config/markdown/.markdownlint.jsonc \ No newline at end of file diff --git a/templates/drupal-module-ddev/.markdownlintignore b/templates/drupal-module-ddev/.markdownlintignore new file mode 120000 index 0000000..d45d38f --- /dev/null +++ b/templates/drupal-module-ddev/.markdownlintignore @@ -0,0 +1 @@ +../../config/drupal-module-ddev/markdown/.markdownlintignore \ No newline at end of file diff --git a/templates/drupal-module-ddev/.phpcs.xml.dist b/templates/drupal-module-ddev/.phpcs.xml.dist new file mode 120000 index 0000000..a15ec36 --- /dev/null +++ b/templates/drupal-module-ddev/.phpcs.xml.dist @@ -0,0 +1 @@ +../../config/drupal-module-ddev/php/.phpcs.xml.dist \ No newline at end of file diff --git a/templates/drupal-module-ddev/.prettierignore b/templates/drupal-module-ddev/.prettierignore new file mode 120000 index 0000000..ccd1665 --- /dev/null +++ b/templates/drupal-module-ddev/.prettierignore @@ -0,0 +1 @@ +../../config/drupal-module-ddev/prettier/.prettierignore \ No newline at end of file diff --git a/templates/drupal-module-ddev/.twig-cs-fixer.dist.php b/templates/drupal-module-ddev/.twig-cs-fixer.dist.php new file mode 120000 index 0000000..41c460e --- /dev/null +++ b/templates/drupal-module-ddev/.twig-cs-fixer.dist.php @@ -0,0 +1 @@ +../../config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php \ No newline at end of file diff --git a/templates/drupal-module-ddev/docker-compose.yml b/templates/drupal-module-ddev/docker-compose.yml new file mode 100644 index 0000000..207b294 --- /dev/null +++ b/templates/drupal-module-ddev/docker-compose.yml @@ -0,0 +1,21 @@ +# itk-version: 3.2.4 + +services: + # Code checks tools + markdownlint: + image: itkdev/markdownlint + profiles: + - dev + volumes: + - ./:/md + + prettier: + # Prettier does not (yet, fcf. + # https://github.com/prettier/prettier/issues/15206) have an official + # docker image. + # https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc) + image: jauderho/prettier + profiles: + - dev + volumes: + - ./:/work