From 6c642daa0060fcd98b401a796d992932a8286b53 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Nov 2023 22:57:51 +0100 Subject: [PATCH 1/6] GH Actions: don't ignore markdown-only changes ... on pull requests as it doesn't play nice with required statuses. --- .github/workflows/phpstan.yml | 2 -- .github/workflows/test.yml | 2 -- .github/workflows/validate.yml | 2 -- 3 files changed, 6 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 19d45d1ee4..874e3e076c 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -7,8 +7,6 @@ on: paths-ignore: - '**.md' pull_request: - paths-ignore: - - '**.md' # Allow manually triggering the workflow. workflow_dispatch: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53bd6bf782..9f2e16fac8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,6 @@ on: paths-ignore: - '**.md' pull_request: - paths-ignore: - - '**.md' # Allow manually triggering the workflow. workflow_dispatch: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 366dc7ace4..4276370141 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -7,8 +7,6 @@ on: paths-ignore: - '**.md' pull_request: - paths-ignore: - - '**.md' # Allow manually triggering the workflow. workflow_dispatch: From 218fed89aa74b8b970d63f15b39d9432f2fe8ca0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Nov 2023 20:59:40 +0100 Subject: [PATCH 2/6] GH Actions: auto-cancel previous builds for same branch Previously, in Travis, when the same branch was pushed again and the "Auto cancellation" option on the "Settings" page had been turned on (as it was for most repos), any still running builds for the same branch would be stopped in favour of starting the build for the newly pushed version of the branch. To enable this behaviour in GH Actions, a `concurrency` configuration needs to be added to each workflow for which this should applied to. More than anything, this is a way to be kind to GitHub by not wasting resources which they so kindly provide to us for free. Refs: * https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/ * https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency --- .github/workflows/label-merge-conflicts.yml | 6 ++++++ .github/workflows/phpstan.yml | 6 ++++++ .github/workflows/test.yml | 6 ++++++ .github/workflows/validate.yml | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/.github/workflows/label-merge-conflicts.yml b/.github/workflows/label-merge-conflicts.yml index 28f0ecf8d2..d3d6927281 100644 --- a/.github/workflows/label-merge-conflicts.yml +++ b/.github/workflows/label-merge-conflicts.yml @@ -5,6 +5,12 @@ on: branches: - master +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: check-prs: runs-on: ubuntu-latest diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 874e3e076c..413c17d321 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: phpstan: name: "PHP: 7.4 | PHPStan" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f2e16fac8..a99ee23026 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 4276370141..00fee90d53 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: checkxml: name: Check XML files From 57c8551b379a0439ac98d6c82c85154db8381518 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Nov 2023 21:01:55 +0100 Subject: [PATCH 3/6] GH Actions: remove the `composer validate` step ... as Composer will always validate when installing anyway. --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a99ee23026..7a514254ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -162,10 +162,6 @@ jobs: if: ${{ matrix.custom_ini == false && matrix.php == '7.4' }} run: cs2pr ./phpcs-report.xml - - name: 'Composer: validate config' - if: ${{ matrix.custom_ini == false }} - run: composer validate --no-check-all --strict - - name: Download the PHPCS phar uses: actions/download-artifact@v3 with: From 15f49eb56a28b0b0706a6b6666aec3827e17c29d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 23 Oct 2022 10:53:42 +0200 Subject: [PATCH 4/6] GH Actions: harden the workflow against PHPCS ruleset errors If there is a ruleset error, the `cs2pr` action doesn't receive an `xml` report and exits with a `0` error code, even though the PHPCS run failed (though not on CS errors, but on a ruleset error). This changes the GH Actions workflow to allow for that situation and still fail the build in that case. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a514254ee..a4a51acb4d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -155,11 +155,11 @@ jobs: - name: 'PHPCS: check code style to show results in PR' if: ${{ matrix.custom_ini == false && matrix.php == '7.4' }} - continue-on-error: true + id: phpcs run: php bin/phpcs --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml - name: Show PHPCS results in PR - if: ${{ matrix.custom_ini == false && matrix.php == '7.4' }} + if: ${{ always() && steps.phpcs.outcome == 'failure' && matrix.php == '7.4' }} run: cs2pr ./phpcs-report.xml - name: Download the PHPCS phar From 5ebe9ee79188716a1027ef041b2bfbc921a20f78 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 18 Apr 2023 16:15:50 +0200 Subject: [PATCH 5/6] GH Actions: skip fewer tests Install some external tooling which is required for certain tests to be able to run. --- .github/workflows/test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4a51acb4d..7e29734526 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -116,6 +116,19 @@ jobs: coverage: none tools: cs2pr + # This action also handles the caching of the dependencies. + - name: Set up node and enable caching of dependencies + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install external tools used in tests + run: > + npm install -g --fund false + csslint + eslint + jshint + # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - normal From 3f42c8adf5e4a430fac2242575314aac158e92d6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Nov 2023 21:08:56 +0100 Subject: [PATCH 6/6] GH Actions: various other small tweaks * Ensure all steps have a name. * Update a few links in inline comments as the old URLs are no longer valid. * Fix a non-LF line ending. * Small indentation fix. * Be more specific about what Composer can ignore when installing. Ref: https://blog.packagist.com/composer-2-2/#-ignore-platform-req-improvements --- .github/workflows/label-new-prs.yml | 6 +++--- .github/workflows/phpstan.yml | 2 +- .github/workflows/test.yml | 4 ++-- .github/workflows/validate.yml | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/label-new-prs.yml b/.github/workflows/label-new-prs.yml index 986fcf654e..f110da6bd5 100644 --- a/.github/workflows/label-new-prs.yml +++ b/.github/workflows/label-new-prs.yml @@ -12,6 +12,6 @@ jobs: runs-on: ubuntu-latest steps: - - uses: srvaroa/labeler@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - uses: srvaroa/labeler@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 413c17d321..fe5e8f2127 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -35,7 +35,7 @@ jobs: # Install dependencies and handle caching in one go. # Dependencies need to be installed to make sure the PHPUnit classes are recognized. - # @link https://github.com/marketplace/actions/install-composer-dependencies + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies uses: "ramsey/composer-install@v2" with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e29734526..1a26084c03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,7 +130,7 @@ jobs: jshint # Install dependencies and handle caching in one go. - # @link https://github.com/marketplace/actions/install-composer-dependencies + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies - normal if: ${{ matrix.php < '8.0' }} uses: "ramsey/composer-install@v2" @@ -143,7 +143,7 @@ jobs: if: ${{ matrix.php >= '8.0' }} uses: "ramsey/composer-install@v2" with: - composer-options: --ignore-platform-reqs + composer-options: --ignore-platform-req=php+ custom-cache-suffix: $(date -u "+%Y-%m") # Note: The code style check is run multiple times against every PHP version diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 00fee90d53..f2bd3555d5 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -29,8 +29,8 @@ jobs: uses: actions/checkout@v3 - name: Install xmllint - run: | - sudo apt-get update + run: | + sudo apt-get update sudo apt-get install --no-install-recommends -y libxml2-utils - name: Retrieve XML Schema @@ -38,7 +38,8 @@ jobs: # Show XML violations inline in the file diff. # @link https://github.com/marketplace/actions/xmllint-problem-matcher - - uses: korelstar/xmllint-problem-matcher@v1 + - name: Enable showing XML issues inline + uses: korelstar/xmllint-problem-matcher@v1 # Validate the XML ruleset files. # @link http://xmlsoft.org/xmllint.html