Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config/drupal-module-ddev/markdown/.markdownlintignore
Original file line number Diff line number Diff line change
@@ -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/
33 changes: 33 additions & 0 deletions config/drupal-module-ddev/php/.phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!-- This file is copied from config/drupal-module-ddev/php/.phpcs.xml.dist 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. -->

<ruleset name="PHP_CodeSniffer">
<description>The coding standard.</description>

<file>.</file>

<!-- Exclude generated files -->
<exclude-pattern>node_modules</exclude-pattern>
<exclude-pattern>vendor</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<!-- DDEV -->
<exclude-pattern>web</exclude-pattern>

<arg value="p"/>

<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/>

<config name="drupal_core_version" value="11"/>

<rule ref="Drupal">
<!-- <exclude name="Drupal.Files.TxtFileLineLength.TooLong"/> -->
<!-- We want to be able to use "package" and "version" in our custom modules -->
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/>
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>
<exclude name="Drupal.NamingConventions.ValidEnumCase.NoUpperAcronyms" />
<exclude name="Drupal.NamingConventions.ValidEnumCase.NoUnderscores" />
</rule>
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
</ruleset>
7 changes: 7 additions & 0 deletions config/drupal-module-ddev/prettier/.prettierignore
Original file line number Diff line number Diff line change
@@ -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/
16 changes: 16 additions & 0 deletions config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// This file is copied from config/drupal-module-ddev/twig/.twig-cs-fixer.dist.php 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/VincentLanglet/Twig-CS-Fixer/blob/main/docs/configuration.md#configuration-file

$finder = new TwigCsFixer\File\Finder();
// Check all files …
$finder->in(__DIR__);
// … that are not ignored by VCS
$finder->ignoreVCSIgnored(true);

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

return $config;
5 changes: 5 additions & 0 deletions scripts/itkdev-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions task/scripts/github-actions-link
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
Expand Down
53 changes: 53 additions & 0 deletions templates/drupal-module-ddev/.github/workflows/module.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.github/workflows/styles.yaml
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.github/workflows/yaml.yaml
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.markdownlint.jsonc
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.markdownlintignore
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.phpcs.xml.dist
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.prettierignore
1 change: 1 addition & 0 deletions templates/drupal-module-ddev/.twig-cs-fixer.dist.php
21 changes: 21 additions & 0 deletions templates/drupal-module-ddev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Loading