From 6f20ffd0b3c6d3230d4aa1661ad20ecc45379f60 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 11:24:05 +0100 Subject: [PATCH 1/8] Update test-module.yml --- .github/workflows/test-module.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 297a564..9a232e2 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -38,10 +38,10 @@ jobs: - localgov-version: '3.x' drupal-version: '~10.0' php-version: '8.4' - - localgov-version: '3.x' + - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' - - localgov-version: '3.x' + - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.4' @@ -144,9 +144,9 @@ jobs: fail-fast: false matrix: localgov-version: - - '3.x' + - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - '8.4' @@ -181,9 +181,9 @@ jobs: fail-fast: false matrix: localgov-version: - - '3.x' + - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - '8.4' @@ -218,9 +218,9 @@ jobs: fail-fast: false matrix: localgov-version: - - '3.x' + - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - '8.4' @@ -255,7 +255,7 @@ jobs: fail-fast: false matrix: localgov-version: - - '3.x' + - '4.x' drupal-version: - '~11.0' php-version: @@ -291,7 +291,7 @@ jobs: fail-fast: false matrix: localgov-version: - - '3.x' + - '4.x' drupal-version: - '~11.0' php-version: @@ -342,10 +342,10 @@ jobs: - localgov-version: '3.x' drupal-version: '~10.0' php-version: '8.4' - - localgov-version: '3.x' + - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' - - localgov-version: '3.x' + - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.4' From be6d72f76b7e4bdceeedf6a14c023dd788b292ef Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 11:43:30 +0100 Subject: [PATCH 2/8] Drop support for Drupal 10 --- .github/workflows/test-microsites.yml | 18 ++++++++---------- .github/workflows/test-module.yml | 24 ------------------------ 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test-microsites.yml b/.github/workflows/test-microsites.yml index 5a6e13f..58caa89 100644 --- a/.github/workflows/test-microsites.yml +++ b/.github/workflows/test-microsites.yml @@ -28,11 +28,10 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - - '8.1' - - '8.2' - '8.3' + - '8.4' steps: - name: Save git branch and git repo names to env if this is not a pull request @@ -119,9 +118,9 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - - '8.3' + - '8.4' steps: - name: Cached workspace @@ -155,9 +154,9 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - - '8.3' + - '8.4' steps: - name: Cached workspace @@ -193,11 +192,10 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~10.0' + - '~11.0' php-version: - - '8.1' - - '8.2' - '8.3' + - '8.4' steps: - name: Clone Drupal container diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 9a232e2..36b1505 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -26,18 +26,6 @@ jobs: fail-fast: false matrix: include: - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.2' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.3' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.4' - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' @@ -330,18 +318,6 @@ jobs: fail-fast: false matrix: include: - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.2' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.3' - - localgov-version: '3.x' - drupal-version: '~10.0' - php-version: '8.4' - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' From 2431ff1a671e3fbbf7d8e04213908ec8bb748b06 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:10:49 +0100 Subject: [PATCH 3/8] Add back D10 support --- .github/workflows/test-microsites.yml | 18 ++++++----- .github/workflows/test-module.yml | 44 ++++++++++++++++++--------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test-microsites.yml b/.github/workflows/test-microsites.yml index 58caa89..5a6e13f 100644 --- a/.github/workflows/test-microsites.yml +++ b/.github/workflows/test-microsites.yml @@ -28,10 +28,11 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~11.0' + - '~10.0' php-version: + - '8.1' + - '8.2' - '8.3' - - '8.4' steps: - name: Save git branch and git repo names to env if this is not a pull request @@ -118,9 +119,9 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~11.0' + - '~10.0' php-version: - - '8.4' + - '8.3' steps: - name: Cached workspace @@ -154,9 +155,9 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~11.0' + - '~10.0' php-version: - - '8.4' + - '8.3' steps: - name: Cached workspace @@ -192,10 +193,11 @@ jobs: localgov-version: - '4.x' drupal-version: - - '~11.0' + - '~10.0' php-version: + - '8.1' + - '8.2' - '8.3' - - '8.4' steps: - name: Clone Drupal container diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 36b1505..d86be54 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -26,6 +26,18 @@ jobs: fail-fast: false matrix: include: + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.1' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.2' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.3' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.4' - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' @@ -80,29 +92,21 @@ jobs: repository: localgovdrupal/drupal-container ref: php${{ matrix.php-version }} - # Split project creation to make debugging easier for now - - name: Create LocalGov Drupal 10 project - if: matrix.drupal-version == '~10.0' + - name: Authenticate with Github + run: | + composer --working-dir=html config repositories.1 vcs git@github.com:${{inputs.project}}.git + composer global config github-oauth.github.com ${{ github.token }} + + - name: Create LocalGov Drupal project run: | composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}" composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }} composer --working-dir=./html install - # Split project creation to make debugging easier for now - - name: Create LocalGov Drupal 11 project - if: matrix.drupal-version == '~11.0' - run: | - composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "3.2.x" - composer require --working-dir=./html --no-install --with-all-dependencies localgovdrupal/localgov:3.2.x-dev - composer require --working-dir=./html --no-install --with-all-dependencies drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }} - composer install --working-dir=./html - - name: Obtain the test target using Composer if: env.HEAD_USER == 'localgovdrupal' run: | - composer --working-dir=html config repositories.1 vcs git@github.com:${{inputs.project}}.git - composer global config github-oauth.github.com ${{ github.token }} composer --working-dir=./html require --with-all-dependencies ${{inputs.project}}:"${COMPOSER_REF} as ${LATEST_RELEASE}" - name: Obtain the test target using Git @@ -318,6 +322,18 @@ jobs: fail-fast: false matrix: include: + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.1' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.2' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.3' + - localgov-version: '3.x' + drupal-version: '~10.0' + php-version: '8.4' - localgov-version: '4.x' drupal-version: '~11.0' php-version: '8.3' From ab5e6ac82a8be3fc163a2a5f65547f3e651d9471 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:21:45 +0100 Subject: [PATCH 4/8] Fixed authenticate with github --- .github/workflows/test-module.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index d86be54..c2073aa 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -94,14 +94,14 @@ jobs: - name: Authenticate with Github run: | - composer --working-dir=html config repositories.1 vcs git@github.com:${{inputs.project}}.git - composer global config github-oauth.github.com ${{ github.token }} - name: Create LocalGov Drupal project run: | composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}" composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }} + composer --working-dir=html config repositories.1 vcs git@github.com:${{inputs.project}}.git + composer global config github-oauth.github.com ${{ github.token }} composer --working-dir=./html install - name: Obtain the test target using Composer From 8384851512a209e0073e2116ede902866b2f51ae Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:29:13 +0100 Subject: [PATCH 5/8] Fix github authentication --- .github/workflows/test-module.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index c2073aa..7eed7b1 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -21,6 +21,9 @@ jobs: build: name: Install LocalGov Drupal runs-on: ubuntu-latest + + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false @@ -92,16 +95,11 @@ jobs: repository: localgovdrupal/drupal-container ref: php${{ matrix.php-version }} - - name: Authenticate with Github - run: | - - name: Create LocalGov Drupal project run: | composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}" composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }} - composer --working-dir=html config repositories.1 vcs git@github.com:${{inputs.project}}.git - composer global config github-oauth.github.com ${{ github.token }} composer --working-dir=./html install - name: Obtain the test target using Composer From 676bab7bcf47b0e4a2caf5a2bd89571c04c4be64 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:30:34 +0100 Subject: [PATCH 6/8] Fix github actioisn authentication --- .github/workflows/test-module.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 7eed7b1..6f66475 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -21,9 +21,9 @@ jobs: build: name: Install LocalGov Drupal runs-on: ubuntu-latest - - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false From de880ecbed87dce92f5aed6768572e66505cf975 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:41:22 +0100 Subject: [PATCH 7/8] Fix trying to install profile over different version --- .github/workflows/test-module.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 6f66475..4ddbcd1 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -103,12 +103,12 @@ jobs: composer --working-dir=./html install - name: Obtain the test target using Composer - if: env.HEAD_USER == 'localgovdrupal' + if: env.HEAD_USER == 'localgovdrupal' && ${{ inputs.project }} != 'localgovdrupal/localgov' run: | - composer --working-dir=./html require --with-all-dependencies ${{inputs.project}}:"${COMPOSER_REF} as ${LATEST_RELEASE}" + composer --working-dir=./html require --with-all-dependencies ${{ inputs.project }}:"${COMPOSER_REF} as ${LATEST_RELEASE}" - name: Obtain the test target using Git - if: env.HEAD_USER != 'localgovdrupal' + if: env.HEAD_USER != 'localgovdrupal' && ${{ inputs.project }} != 'localgovdrupal/localgov' uses: actions/checkout@v4 with: path: ${{inputs.project_path}} From 0b5717b7cce8b924534553fc7fa9b81eea5e39d3 Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Tue, 23 Sep 2025 12:51:48 +0100 Subject: [PATCH 8/8] Added test profile file --- .github/workflows/test-module.yml | 4 +- .github/workflows/test-profile-4.x.yml | 341 +++++++++++++++++++++++++ 2 files changed, 343 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-profile-4.x.yml diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml index 4ddbcd1..93a2d7c 100644 --- a/.github/workflows/test-module.yml +++ b/.github/workflows/test-module.yml @@ -103,12 +103,12 @@ jobs: composer --working-dir=./html install - name: Obtain the test target using Composer - if: env.HEAD_USER == 'localgovdrupal' && ${{ inputs.project }} != 'localgovdrupal/localgov' + if: env.HEAD_USER == 'localgovdrupal' run: | composer --working-dir=./html require --with-all-dependencies ${{ inputs.project }}:"${COMPOSER_REF} as ${LATEST_RELEASE}" - name: Obtain the test target using Git - if: env.HEAD_USER != 'localgovdrupal' && ${{ inputs.project }} != 'localgovdrupal/localgov' + if: env.HEAD_USER != 'localgovdrupal' uses: actions/checkout@v4 with: path: ${{inputs.project_path}} diff --git a/.github/workflows/test-profile-4.x.yml b/.github/workflows/test-profile-4.x.yml new file mode 100644 index 0000000..9fb07ca --- /dev/null +++ b/.github/workflows/test-profile-4.x.yml @@ -0,0 +1,341 @@ +name: Test localgovdrupal drupal-module + +on: + workflow_call: + inputs: + project: + description: 'LocalGov Drupal module name' + required: true + type: string + project_path: + description: 'LocalGov Drupal module path' + required: true + type: string + use_module_phpstan_config: + description: 'Use phpstan.neon from the module under test, instead of the drupal root.' + required: false + default: false + type: boolean + +jobs: + build: + name: Install LocalGov Drupal + runs-on: ubuntu-latest + + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + strategy: + fail-fast: false + matrix: + include: + - localgov-version: '4.x' + drupal-version: '~11.0' + php-version: '8.3' + - localgov-version: '4.x' + drupal-version: '~11.0' + php-version: '8.4' + + steps: + - name: Save git branch and git repo names to env if this is not a pull request + if: github.event_name != 'pull_request' + run: | + echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "HEAD_USER=localgovdrupal" >> $GITHUB_ENV + + - name: Save git branch and git repo names to env if this is a pull request + if: github.event_name == 'pull_request' + run: | + echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV + echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + export HEAD="${{ github.event.pull_request.head.label }}" + echo "HEAD_USER=${HEAD%%:*}" >> $GITHUB_ENV + + - name: Set composer branch reference for version branches + if: endsWith(github.ref, '.x') || endsWith(env.GIT_BRANCH, '.x') + run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV + + - name: Set composer branch reference for non-version branches + if: endsWith(github.ref, '.x') == false && endsWith(env.GIT_BRANCH, '.x') == false + run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV + + - name: Get the latest tagged release for branch version + run: | + LATEST_RELEASE=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GIT_BASE%%.*} | grep -Po '(?<=refs/tags/)[^"]+' | tail -1) + if [ -z $LATEST_RELEASE ]; then LATEST_RELEASE=1; fi + echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV + + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Clone drupal_container + uses: actions/checkout@v4 + with: + repository: localgovdrupal/drupal-container + ref: php${{ matrix.php-version }} + + - name: Create LocalGov Drupal project + run: | + composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}" + composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev + composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }} + composer --working-dir=./html install + + - name: Obtain the test target using Composer + if: env.HEAD_USER == 'localgovdrupal' + run: | + composer --working-dir=./html require --with-all-dependencies ${{ inputs.project }}:"${COMPOSER_REF} as ${LATEST_RELEASE}" + + - name: Obtain the test target using Git + if: env.HEAD_USER != 'localgovdrupal' + uses: actions/checkout@v4 + with: + path: ${{inputs.project_path}} + + # Allow continue on error as breaks D11 installs because suggest doesn't have a version + # so it falls back to stable versions, which do not have D11 releases so fails + - name: Obtain suggested dependencies + continue-on-error: true + run: composer --working-dir=./html/${{inputs.project_path}} suggests --list | xargs composer --working-dir=./html require + + - name: Obtain dev dependencies + if: hashFiles('./html/${{inputs.project_path}}/composer.json') != '' + run: | + composer --working-dir=./html require 'drupal/facets:^2.0' + jq --raw-output '.["require-dev"] | values | to_entries[] | @sh "\(.key):\(.value)"' ./html/${{inputs.project_path}}/composer.json | xargs composer --working-dir=./html require + + eslint_js: + name: ESLint javascript checks + needs: build + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + localgov-version: + - '4.x' + drupal-version: + - '~11.0' + php-version: + - '8.4' + + steps: + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Install packages + if: ${{ hashFiles(format('./html/{0}/**/*.js', inputs.project_path)) != '' }} + run: | + cd html/web/core + npm i + + - name: Run coding standards checks + if: ${{ hashFiles(format('./html/{0}/**/*.js', inputs.project_path)) != '' }} + run: | + cd html/web/core + cp -f .prettierrc.json ../.prettierrc.json + node ./node_modules/eslint/bin/eslint.js --ext .js --resolve-plugins-relative-to=./web/core ../../${{inputs.project_path}} + + eslint_yaml: + name: ESLint yaml checks + needs: build + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + localgov-version: + - '4.x' + drupal-version: + - '~11.0' + php-version: + - '8.4' + + steps: + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Install packages + if: ${{ hashFiles(format('./html/{0}/**/*.yml', inputs.project_path)) != '' }} + run: | + cd html/web/core + npm i + + - name: Run coding standards checks + if: ${{ hashFiles(format('./html/{0}/**/*.yml', inputs.project_path)) != '' }} + run: | + cd html/web/core + cp -f .prettierrc.json ../.prettierrc.json + node ./node_modules/eslint/bin/eslint.js --ext .yml --resolve-plugins-relative-to=./web/core ../../${{inputs.project_path}} + + stylelint: + name: Stylelint checks + needs: build + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + localgov-version: + - '4.x' + drupal-version: + - '~11.0' + php-version: + - '8.4' + + steps: + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Install packages + if: ${{ hashFiles(format('./html/{0}/**/*.css', inputs.project_path)) != '' }} + run: | + cd html/web/core + npm i + + - name: Run coding standards checks + if: ${{ hashFiles(format('./html/{0}/**/*.css', inputs.project_path)) != '' }} + run: | + cd html/web/core + cp -f .prettierrc.json ../.prettierrc.json + node ./node_modules/.bin/stylelint --ignore-path .stylelintignore --config .stylelintrc.json "../../${{inputs.project_path}}/**/*.css" + + phpcs: + name: PHP coding standards checks + needs: build + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + localgov-version: + - '4.x' + drupal-version: + - '~11.0' + php-version: + - '8.4' + + steps: + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Run coding standards checks + run: | + cd html + ./bin/phpcs -p ${{inputs.project_path}} + + phpstan: + name: PHP static analysis checks + needs: build + runs-on: ubuntu-latest + env: + PHPSTAN_NEON_PATH: "./phpstan.neon" + + strategy: + fail-fast: false + matrix: + localgov-version: + - '4.x' + drupal-version: + - '~11.0' + php-version: + - '8.4' + + steps: + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Override phpstan.neon path if requested + if: ${{inputs.use_module_phpstan_config}} + run: echo "PHPSTAN_NEON_PATH=\"${{inputs.project_path}}/phpstan.neon\"" >> $GITHUB_ENV + + - name: Run static analysis checks + if: ${{ hashFiles(format('./html/{0}/**/*.inc', inputs.project_path), format('./html/{0}/**/*.install', inputs.project_path), format('./html/{0}/**/*.module', inputs.project_path), format('./html/{0}/**/*.php', inputs.project_path), format('./html/{0}/**/*.profile', inputs.project_path), format('./html/{0}/**/*.test', inputs.project_path), format('./html/{0}/**/*.theme', inputs.project_path)) != '' }} + run: | + cd html + ./bin/phpstan analyse -c ${{ env.PHPSTAN_NEON_PATH }} ${{inputs.project_path}} + + phpunit: + name: PHPUnit tests + needs: [build,phpcs,phpstan] + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - localgov-version: '4.x' + drupal-version: '~11.0' + php-version: '8.3' + - localgov-version: '4.x' + drupal-version: '~11.0' + php-version: '8.4' + + steps: + - name: Clone Drupal container + uses: actions/checkout@v4 + with: + repository: localgovdrupal/drupal-container + ref: php${{ matrix.php-version }} + + - name: Cached workspace + uses: actions/cache@v4 + with: + path: ./html + key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} + restore-keys: | + localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- + + - name: Start Docker environment + run: docker compose -f docker-compose.yml up -d + + - name: Run PHPUnit tests + run: | + mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest + sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist + docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html' + docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/phpunit -c ./phpunit.d11.xml.dist /var/www/html/${{inputs.project_path}}"