From 928c797c442ffe181d9024a19c720e09066c8440 Mon Sep 17 00:00:00 2001
From: Jonathan Smith <jonathan1055@sandfordsolutions.com>
Date: Tue, 25 Feb 2025 13:39:10 +0000
Subject: [PATCH] Implement $BEFORE_SCRIPT_ACTIONS=phpcs-duplicate-files

---
 .gitlab-ci.yml         |  8 ++++++++
 .gitlab/anything.txt   |  2 ++
 .gitlab/phpcs-fail.xml |  2 +-
 .gitlab/phpcs-ok.xml   | 13 +++++++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 .gitlab/phpcs-ok.xml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index be9f1fe..20f3048 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -48,3 +48,11 @@ phpcs:
         # @todo remove when https://www.drupal.org/project/gitlab_templates/issues/3380694 is merged.
         cp -v phpcs.xml $CI_PROJECT_DIR
       fi
+    - |
+      if [[ $BEFORE_SCRIPT_ACTIONS =~ "phpcs-duplicate-files" ]]; then
+        echo "Executing phpcs-duplicate-files"
+        cp -v .gitlab/phpcs-ok.xml .phpcs.xml
+        cp -v .gitlab/phpcs-ok.xml .phpcs.xml.dist
+        cp -v .gitlab/phpcs-ok.xml phpcs.xml.dist
+        cp -v .gitlab/phpcs-ok.xml phpcs.xml.old
+      fi
diff --git a/.gitlab/anything.txt b/.gitlab/anything.txt
index 15b5c72..4d703fb 100644
--- a/.gitlab/anything.txt
+++ b/.gitlab/anything.txt
@@ -1,2 +1,4 @@
+This is the d7-composer branch.
+
 This file has been added so that changes to it can be used to trigger a pipeline.
 It can contain anything, and there is no need to cherry-pick any changes to the other branches.
diff --git a/.gitlab/phpcs-fail.xml b/.gitlab/phpcs-fail.xml
index 05a045e..600d7e6 100644
--- a/.gitlab/phpcs-fail.xml
+++ b/.gitlab/phpcs-fail.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<ruleset name="gtd-d7-composer">
+<ruleset name="gitlab-templates-downstream-fail">
   <description>This file is inactive by default, but can be renamed in a before_script to test downstream failures</description>
 
   <!-- Include all rules in the Drupal ruleset. -->
diff --git a/.gitlab/phpcs-ok.xml b/.gitlab/phpcs-ok.xml
new file mode 100644
index 0000000..dcf258c
--- /dev/null
+++ b/.gitlab/phpcs-ok.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset name="gitlab-templates-downstream-ok">
+  <description>This file is inactive by default, but can be renamed in a before_script to test downstream failures</description>
+
+  <!-- Include all rules in the Drupal ruleset. -->
+  <rule ref="Drupal"/>
+
+  <!-- Include all rules in the DrupalPractice ruleset. -->
+  <rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice/ruleset.xml"/>
+
+  <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/>
+
+</ruleset>
-- 
GitLab