From c4771fd84b589c40c50568ff0bf69007e77afc19 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 1 Feb 2025 14:26:50 +0000
Subject: [PATCH 01/50] Initial work

---
 assets/phpcs.xml.dist              |  5 ++++-
 includes/include.drupalci.main.yml | 17 ++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/assets/phpcs.xml.dist b/assets/phpcs.xml.dist
index cf640798..7c7e45ce 100644
--- a/assets/phpcs.xml.dist
+++ b/assets/phpcs.xml.dist
@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ruleset name="drupal-project">
   <description>Default PHP CodeSniffer configuration for Drupal project.</description>
-  <rule ref="vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml"/>
+
+  <!-- Include all rules in the Drupal ruleset. -->
+  <rule ref="Drupal"/>
+
   <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
 </ruleset>
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index d7cd1b8a..e4bd708a 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -627,13 +627,20 @@ phpcs:
   needs:
     - composer
   script:
+    # Show the versions of the applicable elements. This has to be done at top level.
+    - columns=130 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
+    # Change directory to the project folder, to allow relative paths, etc.
+    - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd && ls -l
     - test -f phpcs.xml.dist || curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
-    - vendor/bin/phpcs --version
-    - composer show | awk '$0 ~ /codesniffer|coder|coding-standard|variable-analysis/ {print $1 " " $2}';
+    - printf "This is for debug" && cat phpcs.xml.dist || true
+    - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     # Show the installed config file, the paths to the standards and actual coding standards groups being used.
-    - vendor/bin/phpcs --config-show installed_paths
-    - vendor/bin/phpcs -i
-    - vendor/bin/phpcs -s $_WEB_ROOT/modules/custom --report-junit=junit.xml --report-full --report-summary --report-source $_PHPCS_EXTRA
+    - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -i
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 $_PHPCS_EXTRA
+    # Move the xml report to the top level folder
+    - mv -v junit.xml $CI_PROJECT_DIR
   allow_failure: true
   artifacts:
     expose_as: junit
-- 
GitLab


From 7408f7117bfaa623863bc6c18bde60714decc152 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 1 Feb 2025 16:57:18 +0000
Subject: [PATCH 02/50] Show DrupalPractice rule (but comment out by default)

---
 assets/phpcs.xml.dist | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/assets/phpcs.xml.dist b/assets/phpcs.xml.dist
index 7c7e45ce..815de07b 100644
--- a/assets/phpcs.xml.dist
+++ b/assets/phpcs.xml.dist
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ruleset name="drupal-project">
-  <description>Default PHP CodeSniffer configuration for Drupal project.</description>
+  <description>Default PHP CodeSniffer configuration for a Drupal contrib project.</description>
 
   <!-- Include all rules in the Drupal ruleset. -->
   <rule ref="Drupal"/>
 
+  <!-- Include all rules in the DrupalPractice ruleset. Uncomment if required -->
+  <!-- <rule ref="DrupalPractice"/> -->
+
   <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
 </ruleset>
-- 
GitLab


From 44915a7879ae947c99acee70d6df947192377d0d Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 1 Feb 2025 17:00:10 +0000
Subject: [PATCH 03/50] Add temporary line limit of 40 to force phpcs faults
 for downstream testing

---
 assets/phpcs.xml.dist | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/assets/phpcs.xml.dist b/assets/phpcs.xml.dist
index 815de07b..8e6254c5 100644
--- a/assets/phpcs.xml.dist
+++ b/assets/phpcs.xml.dist
@@ -9,4 +9,12 @@
   <!-- <rule ref="DrupalPractice"/> -->
 
   <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
+
+  <!-- Temporary change to cause phpcs faults in downstream projects -->
+  <rule ref="Drupal.Files.LineLength">
+    <properties>
+      <property name="lineLimit" value="40"/>
+    </properties>
+  </rule>
+
 </ruleset>
-- 
GitLab


From 9e5175e227a4c8d70789699cfa2c31b4d6f84159 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 1 Feb 2025 17:19:36 +0000
Subject: [PATCH 04/50] Store exit code to allow processing to continue

---
 includes/include.drupalci.main.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index e4bd708a..95fef641 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -638,9 +638,12 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 $_PHPCS_EXTRA
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 $_PHPCS_EXTRA || EXIT_CODE=$?
+    - |
+      [[ $EXIT_CODE == "" ]] && echo "There are no PHPCS coding standards errors or warnings"
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
+    - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
   artifacts:
     expose_as: junit
-- 
GitLab


From e0ffa3cd965c525856395bc4efa27ca1cff32403 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 10:01:45 +0000
Subject: [PATCH 05/50] Check both phpcs.xml files. Better message. Add
 --basepath parameter

---
 includes/include.drupalci.main.yml | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 95fef641..9afce478 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -628,17 +628,27 @@ phpcs:
     - composer
   script:
     # Show the versions of the applicable elements. This has to be done at top level.
-    - columns=130 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
+    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
+    - columns=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
+    - composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
-    - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd && ls -l
-    - test -f phpcs.xml.dist || curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
+    - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd
+    - echo "ls for debug" && ls -l
+    - |
+      if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
+        echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+        curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
+      else
+        echo "Using the project's existing phpcs.xml(.dist) config file"
+      fi
+    - printf "This is for debug" && cat phpcs.xml || true
     - printf "This is for debug" && cat phpcs.xml.dist || true
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     # Show the installed config file, the paths to the standards and actual coding standards groups being used.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 $_PHPCS_EXTRA || EXIT_CODE=$?
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 --basepath=$CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $_PHPCS_EXTRA || EXIT_CODE=$?
     - |
       [[ $EXIT_CODE == "" ]] && echo "There are no PHPCS coding standards errors or warnings"
     # Move the xml report to the top level folder
-- 
GitLab


From 9d56418da7e8b3e7d978833f2967038abd479216 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 11:34:00 +0000
Subject: [PATCH 06/50] Remove temporary change to assets/phpcs.xml.dist

---
 assets/phpcs.xml.dist | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/assets/phpcs.xml.dist b/assets/phpcs.xml.dist
index 8e6254c5..b82572e0 100644
--- a/assets/phpcs.xml.dist
+++ b/assets/phpcs.xml.dist
@@ -10,11 +10,4 @@
 
   <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
 
-  <!-- Temporary change to cause phpcs faults in downstream projects -->
-  <rule ref="Drupal.Files.LineLength">
-    <properties>
-      <property name="lineLimit" value="40"/>
-    </properties>
-  </rule>
-
 </ruleset>
-- 
GitLab


From 12ece9157ac5effa70c818b5a21eab10f073113e Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 16:55:30 +0000
Subject: [PATCH 07/50] Test GTD MR1 from upstream

---
 .gitlab-ci.yml                     | 14 ++++++++++++--
 includes/include.drupalci.main.yml |  7 +++----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index deb03196..e759e68f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -93,8 +93,18 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
-    project: project/gitlab_templates_downstream
-    branch: d9-basic
+    # project: project/gitlab_templates_downstream
+    # branch: d9-basic
+    project: issue/gitlab_templates_downstream-3503851
+    branch: 3503851-customisable-before-script
+  variables:
+    OPT_IN_TEST_CURRENT: 1
+    OPT_IN_TEST_MAX_PHP: 0
+    OPT_IN_TEST_PREVIOUS_MINOR: 0
+    OPT_IN_TEST_PREVIOUS_MAJOR: 0
+    OPT_IN_TEST_NEXT_MINOR: 0
+    OPT_IN_TEST_DRUPAL9: 0
+    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml'
 
 '→ GTD D10+':
   extends: .downstream-base
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 9afce478..7730e6db 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -628,9 +628,8 @@ phpcs:
     - composer
   script:
     # Show the versions of the applicable elements. This has to be done at top level.
+    - COLUMNS=130 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
-    - columns=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
-    - composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd
     - echo "ls for debug" && ls -l
@@ -641,8 +640,8 @@ phpcs:
       else
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
-    - printf "This is for debug" && cat phpcs.xml || true
-    - printf "This is for debug" && cat phpcs.xml.dist || true
+    - echo "This is for debug" && cat phpcs.xml || true
+    - echo "This is for debug" && cat phpcs.xml.dist || true
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     # Show the installed config file, the paths to the standards and actual coding standards groups being used.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
-- 
GitLab


From 8b2eaf75e775c5964f5332c4dde3941c8a5e1b49 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 17:11:05 +0000
Subject: [PATCH 08/50] Try cd in PHPCS_BEFORE_SCRIPT

---
 .gitlab-ci.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e759e68f..f02da826 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -96,6 +96,7 @@ workflow:
     # project: project/gitlab_templates_downstream
     # branch: d9-basic
     project: issue/gitlab_templates_downstream-3503851
+    # cspell:disable-next-line
     branch: 3503851-customisable-before-script
   variables:
     OPT_IN_TEST_CURRENT: 1
@@ -104,7 +105,7 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml'
+    PHPCS_BEFORE_SCRIPT: 'cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd && mv -v phpcs-not-active.xml phpcs.xml'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From 895101ac222c24e6f0c2da1a5953c22e0c7c6566 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 17:17:56 +0000
Subject: [PATCH 09/50] Try \ to escape $

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f02da826..8e51d338 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -105,7 +105,7 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    PHPCS_BEFORE_SCRIPT: 'cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd && mv -v phpcs-not-active.xml phpcs.xml'
+    PHPCS_BEFORE_SCRIPT: 'cd \$CI_PROJECT_DIR/\$_WEB_ROOT/modules/custom/\$CI_PROJECT_NAME && pwd && mv -v phpcs-not-active.xml phpcs.xml'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From 34190a18383c29484cb9b33b0c87a290bbc0feec Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 17:32:22 +0000
Subject: [PATCH 10/50] Remove cd

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8e51d338..eb7dd327 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -105,7 +105,7 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    PHPCS_BEFORE_SCRIPT: 'cd \$CI_PROJECT_DIR/\$_WEB_ROOT/modules/custom/\$CI_PROJECT_NAME && pwd && mv -v phpcs-not-active.xml phpcs.xml'
+    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml && ls -l phpcs*'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From 8df1db6c779d96d06f2031534c66fdb089e8fcce Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 18:29:31 +0000
Subject: [PATCH 11/50] Remove ls

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index eb7dd327..5e589e2d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -105,7 +105,7 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml && ls -l phpcs*'
+    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From 8f7468066afa3b83f1664c09c4c1c18a66d7def4 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sun, 2 Feb 2025 19:16:43 +0000
Subject: [PATCH 12/50] ensure correct directory

---
 includes/include.drupalci.main.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 7730e6db..dcc7c2ad 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -628,6 +628,7 @@ phpcs:
     - composer
   script:
     # Show the versions of the applicable elements. This has to be done at top level.
+    - cd $CI_PROJECT_DIR
     - COLUMNS=130 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
-- 
GitLab


From 30c431bb5545ad28b8c8c0666bbac05f0faef64f Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 3 Feb 2025 14:17:46 +0000
Subject: [PATCH 13/50] use sed

---
 .gitlab-ci.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5e589e2d..e8871a9a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -105,7 +105,9 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    PHPCS_BEFORE_SCRIPT: 'mv -v phpcs-not-active.xml phpcs.xml'
+    # Use sed to edit phpcs.xml to force a coding standards fault if required.
+    PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
+    _PHPCS_EXTRA: '-v'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From a45d5f1113fcab7cfc978bfc10163e3c36d72c30 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 3 Feb 2025 14:24:28 +0000
Subject: [PATCH 14/50] remove PHPCS_BEFORE_SCRIPT from upstream trigger job

---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e8871a9a..e7a48b6e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -106,8 +106,8 @@ workflow:
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
     # Use sed to edit phpcs.xml to force a coding standards fault if required.
-    PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
-    _PHPCS_EXTRA: '-v'
+    # PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
+    # _PHPCS_EXTRA: '-v'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From 7e7f47a764397807413828a830351a063df22332 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 3 Feb 2025 17:05:10 +0000
Subject: [PATCH 15/50] Revert "remove PHPCS_BEFORE_SCRIPT from upstream
 trigger job" so that the downstream job fails again

This reverts commit a45d5f1113fcab7cfc978bfc10163e3c36d72c30.
---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e7a48b6e..e8871a9a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -106,8 +106,8 @@ workflow:
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
     # Use sed to edit phpcs.xml to force a coding standards fault if required.
-    # PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
-    # _PHPCS_EXTRA: '-v'
+    PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
+    _PHPCS_EXTRA: '-v'
 
 '→ GTD D10+':
   extends: .downstream-base
-- 
GitLab


From f7e1266f06fb07e8533288a6b00d08b238c45302 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Wed, 5 Feb 2025 17:58:08 +0000
Subject: [PATCH 16/50] use keyword make-phpcs-fail

---
 .gitlab-ci.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e8871a9a..cd38307b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -93,6 +93,7 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
+    # @todo reset this back to default repo and branch.
     # project: project/gitlab_templates_downstream
     # branch: d9-basic
     project: issue/gitlab_templates_downstream-3503851
@@ -105,8 +106,8 @@ workflow:
     OPT_IN_TEST_PREVIOUS_MAJOR: 0
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
-    # Use sed to edit phpcs.xml to force a coding standards fault if required.
-    PHPCS_BEFORE_SCRIPT: "sed -i 's/80/30/g' phpcs.xml"
+    # Force phpcs to fail, to demonstrate the xml report and artifacts.
+    PHPCS_BEFORE_SCRIPT: 'make-phpcs-fail'
     _PHPCS_EXTRA: '-v'
 
 '→ GTD D10+':
-- 
GitLab


From a0e5fa000a9a58ebe002d813324843c00fdcf8d6 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 10 Feb 2025 13:46:06 +0000
Subject: [PATCH 17/50] Use BEFORE_SCRIPT_ACTIONS variable

---
 .gitlab-ci.yml                     | 5 ++---
 includes/include.drupalci.main.yml | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cd38307b..98002b30 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -93,7 +93,7 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
-    # @todo reset this back to default repo and branch.
+    # @todo reset this back to default repo and branch when issue 3503851 is merged.
     # project: project/gitlab_templates_downstream
     # branch: d9-basic
     project: issue/gitlab_templates_downstream-3503851
@@ -107,8 +107,7 @@ workflow:
     OPT_IN_TEST_NEXT_MINOR: 0
     OPT_IN_TEST_DRUPAL9: 0
     # Force phpcs to fail, to demonstrate the xml report and artifacts.
-    PHPCS_BEFORE_SCRIPT: 'make-phpcs-fail'
-    _PHPCS_EXTRA: '-v'
+    BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
 
 '→ GTD D10+':
   extends: .downstream-base
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index f9f93f2c..870f1871 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -629,8 +629,8 @@ phpcs:
   needs:
     - composer
   script:
-    # Show the versions of the applicable elements. This has to be done at top level.
     - cd $CI_PROJECT_DIR && pwd
+    # Show the versions of the applicable elements. This has to be done at top level.
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd
-- 
GitLab


From e66da4e62f153fed9a21d29597ac4cd96bc4611d Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 11 Feb 2025 13:29:27 +0000
Subject: [PATCH 18/50] Test downstream d7-basic with custom phpcs-fail action

---
 .gitlab-ci.yml | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 98002b30..a78c09d4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,8 +79,13 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
-    project: project/gitlab_templates_downstream
-    branch: d7-basic
+    # @todo reset this back to default repo and branch when issue 3503851 is merged.
+    project: issue/gitlab_templates_downstream-3503851
+    # cspell:disable-next-line
+    branch: 3503851-customisable-before-script-d7
+  variables:
+    # Force phpcs to fail, to demonstrate the xml report and artifacts.
+    BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
 
 '→ GTD D7 Composer':
   extends: .downstream-base
-- 
GitLab


From 9ee75cf5ac9cfd306e652f24ebb17e4ccee816ac Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Thu, 13 Feb 2025 16:05:19 +0000
Subject: [PATCH 19/50] add @todo for D7 and align D7 composer backup log
 messages with D10

---
 includes/include.drupalci.main-d7.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index dc486242..045dd99c 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -328,9 +328,9 @@ stages:
     # If composer.json exists then make a backup before it gets modified. Otherwise create an empty file.
     - |
       if [[ -f composer.json ]]; then
-        cp composer.json composer.json.backup
+        cp -v composer.json composer.json.backup
       else
-        echo "{}" > composer.json
+        echo "{}" > composer.json && echo "Project has no composer.json so creating an empty one"
       fi
     # Get the composer version currently installed. Use space or . for delimiters to return the single digit top-level version.
     - COMPOSER_VERSION=$(composer --version  | awk -F'[ .]' "{print \$3}")
@@ -401,6 +401,7 @@ phpcs:
       allow_failure: false
     - when: on_success
   script:
+    # @todo in MR325 Run in DRUPAL_PROJECT_FOLDER
     - cd $CI_PROJECT_DIR && pwd
     - test -f phpcs.xml.dist || curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
     - vendor/bin/phpcs --version
-- 
GitLab


From 68e85637b4628160ad1b2d0bdb2a5e96d5081f11 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Thu, 13 Feb 2025 16:06:27 +0000
Subject: [PATCH 20/50] restore to default GTD branches

---
 .gitlab-ci.yml | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a78c09d4..b88fed48 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,11 +79,10 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
-    # @todo reset this back to default repo and branch when issue 3503851 is merged.
-    project: issue/gitlab_templates_downstream-3503851
-    # cspell:disable-next-line
-    branch: 3503851-customisable-before-script-d7
+    project: project/gitlab_templates_downstream
+    branch: d7-basic
   variables:
+    OPT_IN_TEST_MAX_PHP: 0
     # Force phpcs to fail, to demonstrate the xml report and artifacts.
     BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
 
@@ -98,12 +97,8 @@ workflow:
   extends: .downstream-base
   trigger:
     strategy: depend
-    # @todo reset this back to default repo and branch when issue 3503851 is merged.
-    # project: project/gitlab_templates_downstream
-    # branch: d9-basic
-    project: issue/gitlab_templates_downstream-3503851
-    # cspell:disable-next-line
-    branch: 3503851-customisable-before-script
+    project: project/gitlab_templates_downstream
+    branch: d9-basic
   variables:
     OPT_IN_TEST_CURRENT: 1
     OPT_IN_TEST_MAX_PHP: 0
-- 
GitLab


From fc6105d738edeb301e85a4f6bfcfa7c0a461248c Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 11:20:07 +0000
Subject: [PATCH 21/50] comment and message

---
 includes/include.drupalci.main.yml | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 534e2a1e..164c1665 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -648,14 +648,13 @@ phpcs:
       fi
     - echo "This is for debug" && cat phpcs.xml || true
     - echo "This is for debug" && cat phpcs.xml.dist || true
+    # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
-    # Show the installed config file, the paths to the standards and actual coding standards groups being used.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 --basepath=$CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $_PHPCS_EXTRA || EXIT_CODE=$?
-    - |
-      [[ $EXIT_CODE == "" ]] && echo "There are no PHPCS coding standards errors or warnings"
+    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
-- 
GitLab


From 759cf6eb7029ea71d274211c4e6e1bcd26ae735c Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 11:20:31 +0000
Subject: [PATCH 22/50] Use new $DRUPAL_PROJECT_FOLDER

---
 includes/include.drupalci.main.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 164c1665..d3aef16b 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -637,7 +637,7 @@ phpcs:
     # Show the versions of the applicable elements. This has to be done at top level.
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
-    - cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME && pwd
+    - cd $DRUPAL_PROJECT_FOLDER && pwd
     - echo "ls for debug" && ls -l
     - |
       if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
@@ -653,7 +653,7 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 --basepath=$CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $_PHPCS_EXTRA || EXIT_CODE=$?
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
-- 
GitLab


From 3ef9c14b4c279fc6ed9c4352f68ca862627b6e17 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 16:50:19 +0000
Subject: [PATCH 23/50] check that options are not already added in
 _PHPCS_EXTRA

---
 includes/include.drupalci.main.yml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index d3aef16b..d6f01a80 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -646,6 +646,11 @@ phpcs:
       else
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
+      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
+      [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
+      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
+      [[ ${_PHPCS_EXTRA,,} =~ /--report-width/ ]] || _PHPCS_EXTRA+=" --report-width=120"
+      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
     - echo "This is for debug" && cat phpcs.xml || true
     - echo "This is for debug" && cat phpcs.xml.dist || true
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
@@ -653,7 +658,7 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --colors --report-width=120 --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
-- 
GitLab


From 4d93cf3a7ac6244d3606f73057334dafd36028d7 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 17:19:08 +0000
Subject: [PATCH 24/50] add echo to show the exact phpcs statement being
 executed

---
 includes/include.drupalci.main.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index d6f01a80..52786391 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -658,6 +658,7 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
-- 
GitLab


From d8351c6f3328cd613f66c3a910bd18a4069d75f9 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 17:22:16 +0000
Subject: [PATCH 25/50] add temp values to test _PHPCS_EXTRA

---
 .gitlab-ci.yml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b88fed48..70edfb55 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -42,6 +42,7 @@ workflow:
 # testing merge requests and commits. Each of these pipelines has to be
 # triggered manually which can only be done by a maintainer of that project.
 
+# KeyCDN 8.x-1.x has 'current', 'previous major' and 'next major' variants.
 # Testing via phpunit binary directly.
 '→ Key CDN':
   extends: .downstream-base
@@ -50,6 +51,7 @@ workflow:
     project: project/keycdn
     branch: 8.x-1.x
 
+# API 2.x has 'current' and 'previous major' variants.
 # Testing via run-tests.sh.
 '→ API D10+':
   extends: .downstream-base
@@ -58,6 +60,7 @@ workflow:
     project: project/api
     branch: 2.x
 
+# Decoupled Pages 8.x-1.x has 'current', 'previous minor', 'previous major', 'next minor' and 'next major' variants.
 # For Nightwatch testing.
 '→ Decoupled Pages':
   extends: .downstream-base
@@ -66,6 +69,7 @@ workflow:
     project: project/decoupled_pages
     branch: 8.x-1.x
 
+# API 7.x-2.x has 'current' variant only.
 # For Drupal 7.
 '→ API D7':
   extends: .downstream-base
@@ -108,6 +112,7 @@ workflow:
     OPT_IN_TEST_DRUPAL9: 0
     # Force phpcs to fail, to demonstrate the xml report and artifacts.
     BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
+    _PHPCS_EXTRA: --report-width=70
 
 '→ GTD D10+':
   extends: .downstream-base
@@ -115,6 +120,8 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d10-plus
+  variables:
+    _PHPCS_EXTRA: --no-colors
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
-- 
GitLab


From 175106db316e1da8ab221b21f3dc420c4283e4f2 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 14 Feb 2025 19:18:33 +0000
Subject: [PATCH 26/50] use ( ) around pattern

---
 includes/include.drupalci.main.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 52786391..313e3fab 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -649,7 +649,7 @@ phpcs:
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
-      [[ ${_PHPCS_EXTRA,,} =~ /--report-width/ ]] || _PHPCS_EXTRA+=" --report-width=120"
+      [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
       echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
     - echo "This is for debug" && cat phpcs.xml || true
     - echo "This is for debug" && cat phpcs.xml.dist || true
-- 
GitLab


From e7cbc720d81d50cef4b77e842907f34660b33868 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 15 Feb 2025 09:36:30 +0000
Subject: [PATCH 27/50] swap test values

---
 .gitlab-ci.yml                     | 4 ++--
 includes/include.drupalci.main.yml | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 70edfb55..758c4000 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -112,7 +112,7 @@ workflow:
     OPT_IN_TEST_DRUPAL9: 0
     # Force phpcs to fail, to demonstrate the xml report and artifacts.
     BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
-    _PHPCS_EXTRA: --report-width=70
+    _PHPCS_EXTRA: -v --no-colors
 
 '→ GTD D10+':
   extends: .downstream-base
@@ -121,7 +121,7 @@ workflow:
     project: project/gitlab_templates_downstream
     branch: d10-plus
   variables:
-    _PHPCS_EXTRA: --no-colors
+    _PHPCS_EXTRA: --report-width=70
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 313e3fab..7a6a9311 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -647,6 +647,7 @@ phpcs:
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
+      echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
-- 
GitLab


From 3a899c019af9e952cff783725ef5305ae19fd8f5 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 15 Feb 2025 10:00:52 +0000
Subject: [PATCH 28/50] Replicate in main-d7

---
 includes/include.drupalci.main-d7.yml | 39 +++++++++++++++++++++------
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 045dd99c..3daa2b08 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -401,15 +401,38 @@ phpcs:
       allow_failure: false
     - when: on_success
   script:
-    # @todo in MR325 Run in DRUPAL_PROJECT_FOLDER
     - cd $CI_PROJECT_DIR && pwd
-    - test -f phpcs.xml.dist || curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
-    - vendor/bin/phpcs --version
-    - composer show | awk '$0 ~ /codesniffer|coder|coding-standard|variable-analysis/ {print $1 " " $2}';
-    # Show the installed config file, the paths to the standards and actual coding standards groups being used.
-    - vendor/bin/phpcs --config-show installed_paths
-    - vendor/bin/phpcs -i
-    - vendor/bin/phpcs --basepath=$CI_PROJECT_DIR -s $_WEB_ROOT/sites/all/modules/custom --report-junit=junit.xml --report-full --report-summary --report-source $_PHPCS_EXTRA
+    # Show the versions of the applicable elements. This has to be done at top level.
+    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
+    # Change directory to the project folder, to allow relative paths, etc.
+    - cd $DRUPAL_PROJECT_FOLDER && pwd
+    - echo "ls for debug" && ls -l
+    - |
+      if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
+        echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+        curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
+      else
+        echo "Using the project's existing phpcs.xml(.dist) config file"
+      fi
+      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
+      echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
+      [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
+      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
+      [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
+      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
+    - echo "This is for debug" && cat phpcs.xml || true
+    - echo "This is for debug" && cat phpcs.xml.dist || true
+    # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
+    - $CI_PROJECT_DIR/vendor/bin/phpcs --version
+    - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -i
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
+    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
+    # Move the xml report to the top level folder
+    - mv -v junit.xml $CI_PROJECT_DIR
+    - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
   artifacts:
     expose_as: junit
-- 
GitLab


From 0ae638af39321430bca9aa55e9a8efe123c795d1 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 15 Feb 2025 14:01:15 +0000
Subject: [PATCH 29/50] Comments. Better ruleset name

---
 .gitlab-ci.yml                        | 2 ++
 assets/phpcs.xml.dist                 | 3 ++-
 includes/include.drupalci.main-d7.yml | 2 +-
 includes/include.drupalci.main.yml    | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 758c4000..7c0bf57c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -96,6 +96,8 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d7-composer
+  variables:
+    _PHPCS_EXTRA: --no-colors -v
 
 '→ GTD D9 Basic':
   extends: .downstream-base
diff --git a/assets/phpcs.xml.dist b/assets/phpcs.xml.dist
index b82572e0..471c29ae 100644
--- a/assets/phpcs.xml.dist
+++ b/assets/phpcs.xml.dist
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<ruleset name="drupal-project">
+<ruleset name="drupal-contrib-project">
+  <!-- Change the name and description if you copy this file to your project to make customizations. -->
   <description>Default PHP CodeSniffer configuration for a Drupal contrib project.</description>
 
   <!-- Include all rules in the Drupal ruleset. -->
diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 3daa2b08..717b03b4 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -414,7 +414,7 @@ phpcs:
       else
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
-      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
+      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 7a6a9311..3de63f8f 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -646,7 +646,7 @@ phpcs:
       else
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
-      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA.
+      # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
-- 
GitLab


From f56b032ac28ff9ce52684ada733fadf71c70b58c Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 17 Feb 2025 16:10:23 +0000
Subject: [PATCH 30/50] Move success message to end of job, remove debug,
 remove downstream override variables

---
 .gitlab-ci.yml                        | 18 ------------------
 includes/include.drupalci.main-d7.yml |  8 +-------
 includes/include.drupalci.main.yml    |  8 +-------
 3 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7c0bf57c..5ffbbce3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -85,10 +85,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d7-basic
-  variables:
-    OPT_IN_TEST_MAX_PHP: 0
-    # Force phpcs to fail, to demonstrate the xml report and artifacts.
-    BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
 
 '→ GTD D7 Composer':
   extends: .downstream-base
@@ -96,8 +92,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d7-composer
-  variables:
-    _PHPCS_EXTRA: --no-colors -v
 
 '→ GTD D9 Basic':
   extends: .downstream-base
@@ -105,16 +99,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d9-basic
-  variables:
-    OPT_IN_TEST_CURRENT: 1
-    OPT_IN_TEST_MAX_PHP: 0
-    OPT_IN_TEST_PREVIOUS_MINOR: 0
-    OPT_IN_TEST_PREVIOUS_MAJOR: 0
-    OPT_IN_TEST_NEXT_MINOR: 0
-    OPT_IN_TEST_DRUPAL9: 0
-    # Force phpcs to fail, to demonstrate the xml report and artifacts.
-    BEFORE_SCRIPT_ACTIONS: 'phpcs-fail'
-    _PHPCS_EXTRA: -v --no-colors
 
 '→ GTD D10+':
   extends: .downstream-base
@@ -122,8 +106,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d10-plus
-  variables:
-    _PHPCS_EXTRA: --report-width=70
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 717b03b4..cfd93c49 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -406,7 +406,6 @@ phpcs:
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $DRUPAL_PROJECT_FOLDER && pwd
-    - echo "ls for debug" && ls -l
     - |
       if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
         echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
@@ -415,13 +414,8 @@ phpcs:
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
-      echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
-      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
-      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
-    - echo "This is for debug" && cat phpcs.xml || true
-    - echo "This is for debug" && cat phpcs.xml.dist || true
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
@@ -429,9 +423,9 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
-    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
+    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
   artifacts:
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 3de63f8f..d6e1ae38 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -638,7 +638,6 @@ phpcs:
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $DRUPAL_PROJECT_FOLDER && pwd
-    - echo "ls for debug" && ls -l
     - |
       if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
         echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
@@ -647,13 +646,8 @@ phpcs:
         echo "Using the project's existing phpcs.xml(.dist) config file"
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
-      echo "for debug at start _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
-      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
-      echo "for debug _PHPCS_EXTRA=$_PHPCS_EXTRA"
-    - echo "This is for debug" && cat phpcs.xml || true
-    - echo "This is for debug" && cat phpcs.xml.dist || true
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
@@ -661,9 +655,9 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
-    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     # Move the xml report to the top level folder
     - mv -v junit.xml $CI_PROJECT_DIR
+    - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
   artifacts:
-- 
GitLab


From 16d355fbbf2911d7cb73a1f11b3ff0b0e22f6219 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 18 Feb 2025 10:40:53 +0000
Subject: [PATCH 31/50] Add debug for phpcs -e | grep

---
 .gitlab-ci.yml                     | 3 +++
 includes/include.drupalci.main.yml | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5ffbbce3..ff2d5d94 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -59,6 +59,9 @@ workflow:
     strategy: depend
     project: project/api
     branch: 2.x
+  # Add verbose for debug. @todo remove.
+  variables:
+    _PHPCS_EXTRA: -v
 
 # Decoupled Pages 8.x-1.x has 'current', 'previous minor', 'previous major', 'next minor' and 'next major' variants.
 # For Nightwatch testing.
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index d6e1ae38..659c9346 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -652,7 +652,9 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
-    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+    # Extra for debug. @todo remove next line
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     # Move the xml report to the top level folder
-- 
GitLab


From 33ff5dc9944bbc6647bcdb35fc7db01f1787edd7 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 18 Feb 2025 13:56:08 +0000
Subject: [PATCH 32/50] remove debug. update d7 to match

---
 .gitlab-ci.yml                        | 3 ---
 includes/include.drupalci.main-d7.yml | 2 +-
 includes/include.drupalci.main.yml    | 2 --
 3 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ff2d5d94..5ffbbce3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -59,9 +59,6 @@ workflow:
     strategy: depend
     project: project/api
     branch: 2.x
-  # Add verbose for debug. @todo remove.
-  variables:
-    _PHPCS_EXTRA: -v
 
 # Decoupled Pages 8.x-1.x has 'current', 'previous minor', 'previous major', 'next minor' and 'next major' variants.
 # For Nightwatch testing.
diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index cfd93c49..24d36be8 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -420,7 +420,7 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
-    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniffs'
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     # Move the xml report to the top level folder
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 659c9346..1c1f256e 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -653,8 +653,6 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
-    # Extra for debug. @todo remove next line
-    - $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     # Move the xml report to the top level folder
-- 
GitLab


From 7e2673973238e53aee59050736b2d806096947f7 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Fri, 21 Feb 2025 11:25:55 +0000
Subject: [PATCH 33/50] Add sed to adjust project phpcs.xml

---
 includes/include.drupalci.main.yml | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 1c1f256e..cd57c4dc 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -638,12 +638,23 @@ phpcs:
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $DRUPAL_PROJECT_FOLDER && pwd
+    # Does the project have its own phpcs config file?
+    - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
     - |
-      if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
+      if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
         echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
-        echo "Using the project's existing phpcs.xml(.dist) config file"
+        echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
+        echo ">>> for debug, show the standards. This may fail."
+        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+        echo ">>> debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
+        # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
+        # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
+        sed -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/Drupal\/ruleset.xml.*/rule ref="Drupal"\/>/' $PHPCS_CONFIG_FILE
+        sed -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/DrupalPractice\/ruleset.xml.*/rule ref="DrupalPractice"\/>/' $PHPCS_CONFIG_FILE
+        echo ">>> debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
+        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
-- 
GitLab


From 0168131b86a568302e637e5189c2c10dfa814be7 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 22 Feb 2025 13:36:52 +0000
Subject: [PATCH 34/50] Show the changed lines

---
 includes/include.drupalci.main.yml | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index cd57c4dc..b4971320 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -642,19 +642,30 @@ phpcs:
     - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
-        echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+        echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
+        echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
         echo ">>> for debug, show the standards. This may fail."
         $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
-        echo ">>> debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
         # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
         # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
-        sed -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/Drupal\/ruleset.xml.*/rule ref="Drupal"\/>/' $PHPCS_CONFIG_FILE
-        sed -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/DrupalPractice\/ruleset.xml.*/rule ref="DrupalPractice"\/>/' $PHPCS_CONFIG_FILE
-        echo ">>> debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
-        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE)
+        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
+        if [[ $LONG_PATHS ]]; then
+          sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
+          printf "$DIVIDER\nIn $PHPCS_CONFIG_FILE the following\n$LONG_PATHS\n \nhas been edited to just the short name\n"
+          # Use only newline, not spaces, to split the grep array.
+          IFS=$'\n'
+          for line in $LONG_PATHS; do
+            echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
+          done
+          unset IFS
+          printf "$DIVIDER\n"
+          echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
+          $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+        fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
-- 
GitLab


From f839fe021487bc858c9a2f87a45e721683ef5383 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Sat, 22 Feb 2025 17:21:19 +0000
Subject: [PATCH 35/50] replicate in main-d7

---
 includes/include.drupalci.main-d7.yml | 29 ++++++++++++++++++++++++---
 includes/include.drupalci.main.yml    |  3 ++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 24d36be8..eef976c6 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -406,12 +406,35 @@ phpcs:
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $DRUPAL_PROJECT_FOLDER && pwd
+    # Does the project have its own phpcs config file?
+    - echo ">> for debug" && ls phpcs.xml* || true
+    - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
     - |
-      if [[ ! -e phpcs.xml && ! -e phpcs.xml.dist ]]; then
-        echo 'Project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+      if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
+        echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
-        echo "Using the project's existing phpcs.xml(.dist) config file"
+        echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
+        echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
+        echo ">>> for debug, show the standards. This may fail."
+        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+        # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
+        # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
+        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE)
+        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
+        if [[ $LONG_PATHS ]]; then
+          sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
+          printf "$DIVIDER\nIn $PHPCS_CONFIG_FILE the following\n$LONG_PATHS\n \nhas been edited to just the short name\n"
+          # Use only newline, not spaces, to split the grep array.
+          IFS=$'\n'
+          for line in $LONG_PATHS; do
+            echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
+          done
+          unset IFS
+          printf "$DIVIDER\n"
+          echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
+          $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+        fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index b4971320..a23ce534 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -639,6 +639,7 @@ phpcs:
     # Change directory to the project folder, to allow relative paths, etc.
     - cd $DRUPAL_PROJECT_FOLDER && pwd
     # Does the project have its own phpcs config file?
+    - echo ">> for debug" && ls phpcs.xml* || true
     - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
@@ -664,7 +665,7 @@ phpcs:
           unset IFS
           printf "$DIVIDER\n"
           echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
-          $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+          $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
         fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
-- 
GitLab


From b1f86a10ebd808b72821b37af760c3d4b30948ac Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 24 Feb 2025 12:07:08 +0000
Subject: [PATCH 36/50] Add extra message

---
 includes/include.drupalci.main-d7.yml | 2 +-
 includes/include.drupalci.main.yml    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index eef976c6..499af539 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -431,7 +431,7 @@ phpcs:
             echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
           done
           unset IFS
-          printf "$DIVIDER\n"
+          printf "\nWe recommend using the latter syntax in the project $PHPCS_CONFIG_FILE file.$DIVIDER\n"
           echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
           $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
         fi
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index a23ce534..2354a57b 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -663,7 +663,7 @@ phpcs:
             echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
           done
           unset IFS
-          printf "$DIVIDER\n"
+          printf "\nWe recommend using the latter syntax in the project $PHPCS_CONFIG_FILE file.$DIVIDER\n"
           echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
           $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
         fi
-- 
GitLab


From 49a8b4c76a9c024fc7c3a20f6a5b16559892d6f8 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 24 Feb 2025 13:07:54 +0000
Subject: [PATCH 37/50] newline needs space. grep need || true

---
 includes/include.drupalci.main-d7.yml | 4 ++--
 includes/include.drupalci.main.yml    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 499af539..96b7e27c 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -420,7 +420,7 @@ phpcs:
         $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
         # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
         # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
-        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE)
+        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
         echo ">>> for debug LONG_PATHS=$LONG_PATHS"
         if [[ $LONG_PATHS ]]; then
           sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
@@ -431,7 +431,7 @@ phpcs:
             echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
           done
           unset IFS
-          printf "\nWe recommend using the latter syntax in the project $PHPCS_CONFIG_FILE file.$DIVIDER\n"
+          printf "\n \nWe recommend using the latter syntax in the project's $PHPCS_CONFIG_FILE file.$DIVIDER\n"
           echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
           $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
         fi
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 2354a57b..389b2fcf 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -652,7 +652,7 @@ phpcs:
         $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
         # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
         # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
-        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE)
+        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
         echo ">>> for debug LONG_PATHS=$LONG_PATHS"
         if [[ $LONG_PATHS ]]; then
           sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
@@ -663,7 +663,7 @@ phpcs:
             echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
           done
           unset IFS
-          printf "\nWe recommend using the latter syntax in the project $PHPCS_CONFIG_FILE file.$DIVIDER\n"
+          printf "\n \nWe recommend using the latter syntax in the project's $PHPCS_CONFIG_FILE file.$DIVIDER\n"
           echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
           $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
         fi
-- 
GitLab


From fd932f34dc653b00a3c53188100def6df29526a8 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 24 Feb 2025 15:21:31 +0000
Subject: [PATCH 38/50] run from top-level directory

---
 includes/include.drupalci.main.yml | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 389b2fcf..dc63dad9 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -634,10 +634,6 @@ phpcs:
     - composer
   script:
     - cd $CI_PROJECT_DIR && pwd
-    # Show the versions of the applicable elements. This has to be done at top level.
-    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
-    # Change directory to the project folder, to allow relative paths, etc.
-    - cd $DRUPAL_PROJECT_FOLDER && pwd
     # Does the project have its own phpcs config file?
     - echo ">> for debug" && ls phpcs.xml* || true
     - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
@@ -650,36 +646,19 @@ phpcs:
         echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
         echo ">>> for debug, show the standards. This may fail."
         $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
-        # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
-        # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
-        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
-        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
-        if [[ $LONG_PATHS ]]; then
-          sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
-          printf "$DIVIDER\nIn $PHPCS_CONFIG_FILE the following\n$LONG_PATHS\n \nhas been edited to just the short name\n"
-          # Use only newline, not spaces, to split the grep array.
-          IFS=$'\n'
-          for line in $LONG_PATHS; do
-            echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
-          done
-          unset IFS
-          printf "\n \nWe recommend using the latter syntax in the project's $PHPCS_CONFIG_FILE file.$DIVIDER\n"
-          echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
-          $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
-        fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
+    # Show the versions of the applicable elements. This has to be done at top level.
+    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
-    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
-    # Move the xml report to the top level folder
-    - mv -v junit.xml $CI_PROJECT_DIR
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
-- 
GitLab


From c76d5398d5c6901baad658369a4a6b94e2863f6a Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 09:16:51 +0000
Subject: [PATCH 39/50] Add long paths message

---
 includes/include.drupalci.main.yml | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index dc63dad9..397c9a09 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -644,13 +644,24 @@ phpcs:
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
         echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
-        echo ">>> for debug, show the standards. This may fail."
-        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
+        # If the file has hard-coded paths to the Drupal and/or DrupalPractice ruleset give a message recommending they are changed.
+        LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
+        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
+        if [[ $LONG_PATHS ]]; then
+          printf "$DIVIDER\nThe project's $PHPCS_CONFIG_FILE file contains the following long path(s)\n$LONG_PATHS\n \nWe recommend that this is changed to the short syntax\n"
+          # Use only newline, not spaces, to split the grep array for sed.
+          IFS=$'\n'
+          for line in $LONG_PATHS; do
+            echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
+          done
+          unset IFS
+          printf "\n $DIVIDER\n"
+        fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
-    # Show the versions of the applicable elements. This has to be done at top level.
+    # Show the versions of the applicable elements.
     - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
-- 
GitLab


From 150bea07fbfe2a6d3dc951c8a69aea954d808596 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 09:17:54 +0000
Subject: [PATCH 40/50] Replicate in d7

---
 includes/include.drupalci.main-d7.yml | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 96b7e27c..1bcc5e12 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -402,10 +402,6 @@ phpcs:
     - when: on_success
   script:
     - cd $CI_PROJECT_DIR && pwd
-    # Show the versions of the applicable elements. This has to be done at top level.
-    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
-    # Change directory to the project folder, to allow relative paths, etc.
-    - cd $DRUPAL_PROJECT_FOLDER && pwd
     # Does the project have its own phpcs config file?
     - echo ">> for debug" && ls phpcs.xml* || true
     - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
@@ -416,38 +412,32 @@ phpcs:
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
         echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
-        echo ">>> for debug, show the standards. This may fail."
-        $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
-        # If the project's own config file has hard-coded paths to the Drupal and/or DrupalPractice ruleset these
-        # need to be replaced by just the name, so that they can be found in the full directory hierarchy.
+        # If the file has hard-coded paths to the Drupal and/or DrupalPractice ruleset give a message recommending they are changed.
         LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
         echo ">>> for debug LONG_PATHS=$LONG_PATHS"
         if [[ $LONG_PATHS ]]; then
-          sed -E -i 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/' $PHPCS_CONFIG_FILE
-          printf "$DIVIDER\nIn $PHPCS_CONFIG_FILE the following\n$LONG_PATHS\n \nhas been edited to just the short name\n"
-          # Use only newline, not spaces, to split the grep array.
+          printf "$DIVIDER\nThe project's $PHPCS_CONFIG_FILE file contains the following long path(s)\n$LONG_PATHS\n \nWe recommend that this is changed to the short syntax\n"
+          # Use only newline, not spaces, to split the grep array for sed.
           IFS=$'\n'
           for line in $LONG_PATHS; do
             echo $line | sed -E 's/rule.*vendor\/drupal\/coder\/coder_sniffer\/(Drupal|DrupalPractice)\/ruleset.xml.*/rule ref="\1"\/>/'
           done
           unset IFS
-          printf "\n \nWe recommend using the latter syntax in the project's $PHPCS_CONFIG_FILE file.$DIVIDER\n"
-          echo ">>> for debug $PHPCS_CONFIG_FILE after sed" && cat $PHPCS_CONFIG_FILE
-          $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+          printf "\n $DIVIDER\n"
         fi
       fi
       # Add --colors and --report-width=120 if those options are not already in _PHPCS_EXTRA. Use ,, for lower-case matching.
       [[ ${_PHPCS_EXTRA,,} =~ (--colors|--no-colors) ]] || _PHPCS_EXTRA+=" --colors"
       [[ ${_PHPCS_EXTRA,,} =~ (--report-width) ]] || _PHPCS_EXTRA+=" --report-width=120"
+    # Show the versions of the applicable elements.
+    - COLUMNS=120 composer show | grep -E '(codesniffer|coder|coding-standard|variable-analysis)'
     # Show the phpcs version, config file, the paths, the installed coding standards and actual number of sniffs being used in this job.
     - $CI_PROJECT_DIR/vendor/bin/phpcs --version
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
-    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs . -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
-    # Move the xml report to the top level folder
-    - mv -v junit.xml $CI_PROJECT_DIR
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
-- 
GitLab


From 09ea41e72009b1ea9504996b87a9d4b843c1f7cc Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 09:23:43 +0000
Subject: [PATCH 41/50] For testing, force downstream failures in d7-composer
 and d10-plus

---
 .gitlab-ci.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5ffbbce3..80322d9c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -92,6 +92,8 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d7-composer
+  variables:
+    BEFORE_SCRIPT_ACTIONS: phpcs-fail
 
 '→ GTD D9 Basic':
   extends: .downstream-base
@@ -106,6 +108,8 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d10-plus
+  variables:
+    BEFORE_SCRIPT_ACTIONS: phpcs-fail
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
-- 
GitLab


From 3964905277f2f4e4204dcb7928acb790aa9dea59 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <20701-jonathan1055@users.noreply.drupalcode.org>
Date: Tue, 25 Feb 2025 10:10:51 +0000
Subject: [PATCH 42/50] Update phpcs page

---
 docs/jobs/phpcs.md | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/docs/jobs/phpcs.md b/docs/jobs/phpcs.md
index 179a4dfd..b8821734 100644
--- a/docs/jobs/phpcs.md
+++ b/docs/jobs/phpcs.md
@@ -1,9 +1,22 @@
-# PHP_CodeSniffer
+# PHPCS
 
-This job will validate the module's code against Drupal coding standards.
+The `phpcs` job validates the project's source code against the [Drupal PHP coding standards](https://www.drupal.org/docs/develop/standards/php).
 
-It uses [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) library and configures the Drupal coding standards.
+[PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is used to perform the checks that are configured in the Drupal standards as specified in the [Drupal Coder module](https://www.drupal.org/project/coder).
 
-If the module does not have a default `phpcs.xml` or `phpcs.xml.dist`, it will use [this one](https://git.drupalcode.org/project/gitlab_templates/-/blob/main/assets/phpcs.xml.dist). If it has one, then it will use it.
+## Customized configuration file
+By default the full set of `Drupal` coding standards are checked, using this 
+[default phpcs.xml configuration file](https://git.drupalcode.org/project/gitlab_templates/-/blob/main/assets/phpcs.xml.dist).
 
-You can also use the variable `_PHPCS_EXTRA` in the `variables` section of the `.gitlab-ci.yml` file to pass additional arguments to the call.
+The `DrupalPractice` set of best practices are not enforced by default.
+
+A project may have its own `phpcs.xml` or `phpcs.xml.dist` configuration file which will be used instead of the default file.
+
+The set of coding standards should be defined using the short path with just the name:
+```
+  <rule ref="Drupal"/>
+  <rule ref="DrupalPractice"/>
+```
+
+## Custom options
+You can use the pipeline variable `_PHPCS_EXTRA` in the `variables` section of the `.gitlab-ci.yml` file to pass additional arguments to the call. An example is ` -v ` to add verbose output to the log.
-- 
GitLab


From fde83c3642620a3f9b70722b610f063def60eaf9 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 11:10:19 +0000
Subject: [PATCH 43/50] List all sniffs in collapsed section

---
 includes/include.drupalci.main-d7.yml | 3 +++
 includes/include.drupalci.main.yml    | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 1bcc5e12..67d87120 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -436,6 +436,9 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+    - echo -e "\e[0Ksection_start:`date +%s`:phpcs_sniffs[collapsed=true]\r\e[0KList of all PHPCS sniffs used in this job"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e
+    - echo -e "\e[0Ksection_end:`date +%s`:phpcs_sniffs\r\e[0K"
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 397c9a09..9d8625dd 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -668,6 +668,9 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+    - echo -e "\e[0Ksection_start:`date +%s`:phpcs_sniffs[collapsed=true]\r\e[0KList of all PHPCS sniffs used in this job"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e
+    - echo -e "\e[0Ksection_end:`date +%s`:phpcs_sniffs\r\e[0K"
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
-- 
GitLab


From 04f99b66983b924120706371064ed4db0c5640bd Mon Sep 17 00:00:00 2001
From: Jonathan Smith <20701-jonathan1055@users.noreply.drupalcode.org>
Date: Tue, 25 Feb 2025 11:34:50 +0000
Subject: [PATCH 44/50] Add default extensions to doc. Refer to Coding
 Standards project.

---
 docs/jobs/phpcs.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/jobs/phpcs.md b/docs/jobs/phpcs.md
index b8821734..035c9277 100644
--- a/docs/jobs/phpcs.md
+++ b/docs/jobs/phpcs.md
@@ -2,13 +2,13 @@
 
 The `phpcs` job validates the project's source code against the [Drupal PHP coding standards](https://www.drupal.org/docs/develop/standards/php).
 
-[PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is used to perform the checks that are configured in the Drupal standards as specified in the [Drupal Coder module](https://www.drupal.org/project/coder).
+[PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is used to perform the checks that are configured in the Drupal standards as specified in the [Drupal Coder module](https://www.drupal.org/project/coder). The standards are curated by the [Drupal Coding Standards project](https://www.drupal.org/project/coding_standards).
 
 ## Customized configuration file
 By default the full set of `Drupal` coding standards are checked, using this 
-[default phpcs.xml configuration file](https://git.drupalcode.org/project/gitlab_templates/-/blob/main/assets/phpcs.xml.dist).
+[default phpcs.xml configuration file](https://git.drupalcode.org/project/gitlab_templates/-/blob/main/assets/phpcs.xml.dist). The `DrupalPractice` set of best practices are not enforced by default.
 
-The `DrupalPractice` set of best practices are not enforced by default.
+This job checks files with the following extensions: `.php`, `.inc`, `.module`, `.install`, `.info`, `.test`, `.profile`, `.theme`
 
 A project may have its own `phpcs.xml` or `phpcs.xml.dist` configuration file which will be used instead of the default file.
 
-- 
GitLab


From 5b6a02de88c929f1d5d034ad4b78fcdd8536dd78 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 13:58:15 +0000
Subject: [PATCH 45/50] Restrict ls expansion. Test with BEFORE_SCRIPT_ACTIONS:
 phpcs-duplicate-files

---
 .gitlab-ci.yml                        | 3 ++-
 includes/include.drupalci.main-d7.yml | 4 ++--
 includes/include.drupalci.main.yml    | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 80322d9c..cab66d25 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -101,6 +101,7 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d9-basic
+    BEFORE_SCRIPT_ACTIONS: phpcs-duplicate-files
 
 '→ GTD D10+':
   extends: .downstream-base
@@ -109,7 +110,7 @@ workflow:
     project: project/gitlab_templates_downstream
     branch: d10-plus
   variables:
-    BEFORE_SCRIPT_ACTIONS: phpcs-fail
+    BEFORE_SCRIPT_ACTIONS: phpcs-fail phpcs-duplicate-files
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 67d87120..fb5f14f6 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -403,8 +403,8 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls phpcs.xml* || true
-    - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
+    - echo ">> for debug" && ls {.,}phpcs.xml{.dist,} || true
+    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
         echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 9d8625dd..575517bb 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -635,8 +635,8 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls phpcs.xml* || true
-    - PHPCS_CONFIG_FILE=($(ls phpcs.xml* | head -1 || true))
+    - echo ">> for debug" && ls {.,}phpcs.xml{.dist,} || true
+    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
         echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
-- 
GitLab


From 8a6c88a8a0a954e34823fc44f7503ed6579ee72d Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 14:01:11 +0000
Subject: [PATCH 46/50] variables: keyword

---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cab66d25..0eb6930b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -101,6 +101,7 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d9-basic
+  variables:
     BEFORE_SCRIPT_ACTIONS: phpcs-duplicate-files
 
 '→ GTD D10+':
-- 
GitLab


From f0b89286ced35c647c2fe8ed2797743f0211fd47 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 14:55:27 +0000
Subject: [PATCH 47/50] silent ls to avoid confusing messages in log

---
 includes/include.drupalci.main-d7.yml | 4 ++--
 includes/include.drupalci.main.yml    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index fb5f14f6..bd7ec457 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -403,8 +403,8 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls {.,}phpcs.xml{.dist,} || true
-    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} | head -1 || true))
+    - echo ">> for debug" && ls {.,}phpcs.xml* || true
+    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
         echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 575517bb..061c1d90 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -635,8 +635,8 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls {.,}phpcs.xml{.dist,} || true
-    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} | head -1 || true))
+    - echo ">> for debug" && ls {.,}phpcs.xml* || true
+    - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
         echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
-- 
GitLab


From ba49276c9e13a26ff3d6d88d54528eb8f5706866 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Wed, 26 Feb 2025 11:26:25 +0000
Subject: [PATCH 48/50] Move phpcs -e to the end

---
 includes/include.drupalci.main-d7.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index bd7ec457..59e2f1e7 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -407,7 +407,7 @@ phpcs:
     - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
-        echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+        echo 'This project has no (.)phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
@@ -436,11 +436,11 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - echo -e "\e[0Ksection_start:`date +%s`:phpcs_sniffs[collapsed=true]\r\e[0KList of all PHPCS sniffs used in this job"
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e
     - echo -e "\e[0Ksection_end:`date +%s`:phpcs_sniffs\r\e[0K"
-    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
-- 
GitLab


From e476e6e78e272112e9d93a8a307baffdd0f6453d Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Wed, 26 Feb 2025 11:51:43 +0000
Subject: [PATCH 49/50] add || true

---
 includes/include.drupalci.main-d7.yml | 6 +++---
 includes/include.drupalci.main.yml    | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index 59e2f1e7..ea769e5d 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -436,11 +436,11 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs --config-show installed_paths
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
-    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - echo -e "\e[0Ksection_start:`date +%s`:phpcs_sniffs[collapsed=true]\r\e[0KList of all PHPCS sniffs used in this job"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs -e
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
     - echo -e "\e[0Ksection_end:`date +%s`:phpcs_sniffs\r\e[0K"
+    - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
+    - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
     - if [[ $EXIT_CODE == "" ]]; then echo "There are no PHPCS coding standards errors or warnings"; fi
     - echo "Exiting with EXIT_CODE=$EXIT_CODE" && exit $EXIT_CODE
   allow_failure: true
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 061c1d90..54844a54 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -639,7 +639,7 @@ phpcs:
     - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
-        echo 'This project has no phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
+        echo 'This project has no (.)phpcs.xml(.dist), getting default from assets/phpcs.xml.dist'
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
@@ -669,7 +669,7 @@ phpcs:
     - $CI_PROJECT_DIR/vendor/bin/phpcs -i
     - $CI_PROJECT_DIR/vendor/bin/phpcs -e | grep -E 'contains.*sniff' || true
     - echo -e "\e[0Ksection_start:`date +%s`:phpcs_sniffs[collapsed=true]\r\e[0KList of all PHPCS sniffs used in this job"
-    - $CI_PROJECT_DIR/vendor/bin/phpcs -e
+    - $CI_PROJECT_DIR/vendor/bin/phpcs -e || true
     - echo -e "\e[0Ksection_end:`date +%s`:phpcs_sniffs\r\e[0K"
     - echo "executing $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA"
     - $CI_PROJECT_DIR/vendor/bin/phpcs $DRUPAL_PROJECT_FOLDER -s --report-junit=junit.xml --report-full --report-summary --report-source --basepath=$DRUPAL_PROJECT_FOLDER $_PHPCS_EXTRA || EXIT_CODE=$?
-- 
GitLab


From 820a73a8cabdf02c741b1059f6ff1d853bc0db84 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Mon, 3 Mar 2025 10:48:33 +0000
Subject: [PATCH 50/50] Remove debug

---
 .gitlab-ci.yml                        | 6 ------
 docs/jobs/phpcs.md                    | 2 +-
 includes/include.drupalci.main-d7.yml | 3 ---
 includes/include.drupalci.main.yml    | 3 ---
 4 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0eb6930b..5ffbbce3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -92,8 +92,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d7-composer
-  variables:
-    BEFORE_SCRIPT_ACTIONS: phpcs-fail
 
 '→ GTD D9 Basic':
   extends: .downstream-base
@@ -101,8 +99,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d9-basic
-  variables:
-    BEFORE_SCRIPT_ACTIONS: phpcs-duplicate-files
 
 '→ GTD D10+':
   extends: .downstream-base
@@ -110,8 +106,6 @@ workflow:
     strategy: depend
     project: project/gitlab_templates_downstream
     branch: d10-plus
-  variables:
-    BEFORE_SCRIPT_ACTIONS: phpcs-fail phpcs-duplicate-files
 
 # ----------------------------- INTERNAL VALIDATION ----------------------------
 
diff --git a/docs/jobs/phpcs.md b/docs/jobs/phpcs.md
index 035c9277..3d835b05 100644
--- a/docs/jobs/phpcs.md
+++ b/docs/jobs/phpcs.md
@@ -5,7 +5,7 @@ The `phpcs` job validates the project's source code against the [Drupal PHP codi
 [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) is used to perform the checks that are configured in the Drupal standards as specified in the [Drupal Coder module](https://www.drupal.org/project/coder). The standards are curated by the [Drupal Coding Standards project](https://www.drupal.org/project/coding_standards).
 
 ## Customized configuration file
-By default the full set of `Drupal` coding standards are checked, using this 
+By default the full set of `Drupal` coding standards are checked, using this
 [default phpcs.xml configuration file](https://git.drupalcode.org/project/gitlab_templates/-/blob/main/assets/phpcs.xml.dist). The `DrupalPractice` set of best practices are not enforced by default.
 
 This job checks files with the following extensions: `.php`, `.inc`, `.module`, `.install`, `.info`, `.test`, `.profile`, `.theme`
diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml
index ea769e5d..f7aa2012 100644
--- a/includes/include.drupalci.main-d7.yml
+++ b/includes/include.drupalci.main-d7.yml
@@ -403,7 +403,6 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls {.,}phpcs.xml* || true
     - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
@@ -411,10 +410,8 @@ phpcs:
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
-        echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
         # If the file has hard-coded paths to the Drupal and/or DrupalPractice ruleset give a message recommending they are changed.
         LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
-        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
         if [[ $LONG_PATHS ]]; then
           printf "$DIVIDER\nThe project's $PHPCS_CONFIG_FILE file contains the following long path(s)\n$LONG_PATHS\n \nWe recommend that this is changed to the short syntax\n"
           # Use only newline, not spaces, to split the grep array for sed.
diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml
index 54844a54..930b8330 100644
--- a/includes/include.drupalci.main.yml
+++ b/includes/include.drupalci.main.yml
@@ -635,7 +635,6 @@ phpcs:
   script:
     - cd $CI_PROJECT_DIR && pwd
     # Does the project have its own phpcs config file?
-    - echo ">> for debug" && ls {.,}phpcs.xml* || true
     - PHPCS_CONFIG_FILE=($(ls {.,}phpcs.xml{.dist,} 2>/dev/null | head -1 || true))
     - |
       if [[ ! "$PHPCS_CONFIG_FILE" ]]; then
@@ -643,10 +642,8 @@ phpcs:
         curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/assets/phpcs.xml.dist
       else
         echo "Using the project's existing $PHPCS_CONFIG_FILE config file"
-        echo ">>> for debug $PHPCS_CONFIG_FILE before" && cat $PHPCS_CONFIG_FILE
         # If the file has hard-coded paths to the Drupal and/or DrupalPractice ruleset give a message recommending they are changed.
         LONG_PATHS=$(grep -inE "vendor\/drupal\/coder\/coder_sniffer\/Drupal(Practice)?\/ruleset.xml" $PHPCS_CONFIG_FILE) || true
-        echo ">>> for debug LONG_PATHS=$LONG_PATHS"
         if [[ $LONG_PATHS ]]; then
           printf "$DIVIDER\nThe project's $PHPCS_CONFIG_FILE file contains the following long path(s)\n$LONG_PATHS\n \nWe recommend that this is changed to the short syntax\n"
           # Use only newline, not spaces, to split the grep array for sed.
-- 
GitLab