The PHPCS job overwrites the projects own phpcs.xml.dist file

Migrated issue

Reported by: jonathan1055

Related to !28 (merged)

Problem/Motivation

The PHPCS job overwrites the projects own phpcs.xml.dist file. In the phpcs job, the script is

  script:
    - curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/$_GITLAB_TEMPLATES_REF/scripts/phpcs.xml.dist
    - vendor/bin/phpcs -s $_WEB_ROOT/modules/custom --report-junit=junit.xml --report-full --report-summary

This copies the gitlab_template scripts/phpcs.xml.dist file into the root folder of the project being tested. This is OK if that project did not have their own custom phpcs.xml.dist, but if the project does have their own then this gets trashed, leading to incorrect phpcs results for the project being tested.

Steps to reproduce

Scheduler has it's own phpcs.xml.dist to make a few customisations, such as extending the array definition line length and ignoring the rule that an inline comment cannot have a blank line afer it. With the step as-is
template as-is

With a customised step simply deleting the curl copy, the job passes as expected
without copying phpcs.xml.dist

Proposed resolution

Add some conditional check before copying the file.