From 540d8cbef82aa8b595ce3f02a9c1d7bbb03c4c75 Mon Sep 17 00:00:00 2001 From: Lee Mills <8024370+millnut@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:34:51 +0100 Subject: [PATCH 1/8] fix: use strict types --- localgov.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localgov.install b/localgov.install index 347addf..e74ff19 100644 --- a/localgov.install +++ b/localgov.install @@ -36,7 +36,7 @@ function localgov_install() { // Enable entity_usage for media by default. $entity_usage_config = $config_factory->getEditable('entity_usage.settings'); $local_task_enabled_entity_types = $entity_usage_config->get('local_task_enabled_entity_types'); - if (!in_array('media', $local_task_enabled_entity_types)) { + if (!in_array('media', $local_task_enabled_entity_types, TRUE)) { $local_task_enabled_entity_types[] = 'media'; $entity_usage_config->set('local_task_enabled_entity_types', $local_task_enabled_entity_types); $entity_usage_config->save(TRUE); @@ -94,7 +94,7 @@ function localgov_update_9503() { $config_factory = \Drupal::configFactory(); $entity_usage_config = $config_factory->getEditable('entity_usage.settings'); $local_task_enabled_entity_types = $entity_usage_config->get('local_task_enabled_entity_types'); - if (!in_array('media', $local_task_enabled_entity_types)) { + if (!in_array('media', $local_task_enabled_entity_types, TRUE)) { $local_task_enabled_entity_types[] = 'media'; $entity_usage_config->set('local_task_enabled_entity_types', $local_task_enabled_entity_types); $entity_usage_config->save(TRUE); From bd1b3b9bacc7bc834d47a1292e860d1ceb3219a1 Mon Sep 17 00:00:00 2001 From: Rupert Jabelman Date: Tue, 6 Aug 2024 12:18:06 +0100 Subject: [PATCH 2/8] Adds new install step, which calls a new hook. (#751) * Adds new install step, which calls a new hook (hook_localgov_post_install), so modules can run tasks at the end of a site install. * Code style. --- localgov.api.php | 30 ++++++++++++++++++++++++++++++ localgov.profile | 25 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 localgov.api.php diff --git a/localgov.api.php b/localgov.api.php new file mode 100644 index 0000000..e5bb791 --- /dev/null +++ b/localgov.api.php @@ -0,0 +1,30 @@ + [ + 'display_name' => t('Localgov post install'), + 'display' => TRUE, + ], + ]; +} + +/** + * This is an install step, added by localgov_install_tasks(). + * + * We use this step to call a hook to allow other localgov modules to set things + * up as part of the site installation process that they can't do in their + * install hooks. + */ +function localgov_post_install_task(): void { + \Drupal::moduleHandler()->invokeAllWith('localgov_post_install', function (callable $hook, string $module) { + $hook(); + }); +} From eef35eefbd17f5ee1dab4553f80930d9e9c3280e Mon Sep 17 00:00:00 2001 From: Stephen Cox Date: Thu, 8 Aug 2024 14:32:06 +0100 Subject: [PATCH 3/8] Use shared GitHub workflows to run tests (#753) * Use shared GitHub workflows to run tests * Test fix/install-dev-dependencies branch of shared workflows * Update test.yml --- .github/workflows/test.yml | 209 ++----------------------------------- 1 file changed, 6 insertions(+), 203 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b18e62..72246ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,208 +7,11 @@ on: pull_request: branches: - '3.x' - -env: - LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov - LOCALGOV_DRUPAL_PROJECT_PATH: web/profiles/contrib/localgov + workflow_dispatch: jobs: - - build: - name: Install LocalGov Drupal - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - localgov-version: - - '3.x' - drupal-version: - - '~10.0' - php-version: - - '8.1' - - '8.2' - - 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') - run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV - - - name: Set composer branch reference for non-version branches - if: endsWith(github.ref, '.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%'.x'} | 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@v2 - 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@v2 - 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 config repositories.1 vcs git@github.com:${LOCALGOV_DRUPAL_PROJECT}.git - composer global config github-oauth.github.com ${{ github.token }} - composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}" - - - name: Obtain the test target using Git - if: env.HEAD_USER != 'localgovdrupal' - uses: actions/checkout@v2 - with: - path: ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }} - - - name: Obtain dev dependencies - run: jq --raw-output '.["require-dev"] | values | to_entries[] | @sh "\(.key):\(.value)"' ./html/web/profiles/contrib/localgov/composer.json | xargs composer --working-dir=./html require - - phpcs: - name: Coding standards checks - needs: build - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - localgov-version: - - '3.x' - drupal-version: - - '~10.0' - php-version: - - '8.1' - - '8.2' - - steps: - - - name: Cached workspace - uses: actions/cache@v2 - 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 ${LOCALGOV_DRUPAL_PROJECT_PATH} - - phpstan: - name: Deprecated code checks - needs: build - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - localgov-version: - - '3.x' - drupal-version: - - '~10.0' - php-version: - - '8.1' - - '8.2' - - steps: - - - name: Cached workspace - uses: actions/cache@v2 - 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 deprecated code checks - run: | - cd html - ./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH} - phpunit: - name: PHPUnit tests - needs: build - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - localgov-version: - - '3.x' - drupal-version: - - '~10.0' - php-version: - - '8.1' - - '8.2' - - steps: - - - name: Clone Drupal container - uses: actions/checkout@v2 - with: - repository: localgovdrupal/drupal-container - ref: php${{ matrix.php-version }} - - - name: Cached workspace - uses: actions/cache@v2 - 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/paratest --processes=4 /var/www/html/${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}" + tests: + uses: localgovdrupal/localgov_shared_workflows/.github/workflows/test-module.yml@1.x + with: + project: 'localgovdrupal/localgov' + project_path: 'web/profiles/contrib/localgov' From 11842dbc9027ef78a203f1b65da6ec1df2bc873b Mon Sep 17 00:00:00 2001 From: ekes Date: Sun, 11 Aug 2024 13:54:19 +0200 Subject: [PATCH 4/8] Patches for workspaces. - Core patch for integration with workflows / content moderation. - Pathauto patch to prevent recalculation of aliases when publishing a space (order is not always good, and paths relying on paths, services parent for example, can be incorrect). - Redirect patch to allow it to be spaces aware, and avoid a sql error. --- composer.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2c383d0..55a9447 100644 --- a/composer.json +++ b/composer.json @@ -59,14 +59,19 @@ }, "patches": { "drupal/core": { - "Users can't reference unpublished content even when they have access to it. See https://www.drupal.org/project/drupal/issues/2845144": "https://www.drupal.org/files/issues/2024-02-13/2845144-87.patch" + "Users can't reference unpublished content even when they have access to it. See https://www.drupal.org/project/drupal/issues/2845144": "https://www.drupal.org/files/issues/2024-02-13/2845144-87.patch", + "Content moderation and Workspaces https://www.drupal.org/project/drupal/issues/3179199#comment-15711680": "./patches/drupal_core/3179199-3132022-content-moderation-workspaces-query.patch" }, "drupal/preview_link": { "Automatically populating multiple preview link entities #3439968": "https://www.drupal.org/files/issues/2024-05-22/3439968-4.diff", "Add a 'copy to clipboard' feature for preview_link": "https://www.drupal.org/files/issues/2024-05-28/3449121-9.patch" }, + "drupal/pathauto": { + "Allow path generation inside of a workspace - and importantly don't regenerate when publishing space": "https://www.drupal.org/files/issues/2024-04-08/3283769-10.patch" + }, "drupal/redirect": { - "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2022-09-01/3057250-53.patch" + "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2022-09-01/3057250-53.patch", + "Create redirect from path alias change and workspaces": "https://www.drupal.org/files/issues/2024-03-18/3431260.patch" } } } From 335f0ab58cf16221ebcfe8b7b2ed7b10a0cfa2a7 Mon Sep 17 00:00:00 2001 From: ekes Date: Sun, 11 Aug 2024 14:17:33 +0200 Subject: [PATCH 5/8] Moved to a remote http download patch. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 55a9447..bd32371 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "patches": { "drupal/core": { "Users can't reference unpublished content even when they have access to it. See https://www.drupal.org/project/drupal/issues/2845144": "https://www.drupal.org/files/issues/2024-02-13/2845144-87.patch", - "Content moderation and Workspaces https://www.drupal.org/project/drupal/issues/3179199#comment-15711680": "./patches/drupal_core/3179199-3132022-content-moderation-workspaces-query.patch" + "Content moderation and Workspaces https://www.drupal.org/project/drupal/issues/3179199#comment-15711680": "https://www.drupal.org/files/issues/2024-08-11/3179199-3132022-content-moderation-workspaces-query.patch" }, "drupal/preview_link": { "Automatically populating multiple preview link entities #3439968": "https://www.drupal.org/files/issues/2024-05-22/3439968-4.diff", From ca856ed3389ca0496ab824d1db5cf037e4422bb3 Mon Sep 17 00:00:00 2001 From: ekes Date: Sun, 11 Aug 2024 14:39:16 +0200 Subject: [PATCH 6/8] Add direct links to the issues in the description. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bd32371..56f8488 100644 --- a/composer.json +++ b/composer.json @@ -67,11 +67,11 @@ "Add a 'copy to clipboard' feature for preview_link": "https://www.drupal.org/files/issues/2024-05-28/3449121-9.patch" }, "drupal/pathauto": { - "Allow path generation inside of a workspace - and importantly don't regenerate when publishing space": "https://www.drupal.org/files/issues/2024-04-08/3283769-10.patch" + "Allow path generation inside of a workspace - and importantly don't regenerate when publishing space https://www.drupal.org/project/pathauto/issues/3283769": "https://www.drupal.org/files/issues/2024-04-08/3283769-10.patch" }, "drupal/redirect": { "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2022-09-01/3057250-53.patch", - "Create redirect from path alias change and workspaces": "https://www.drupal.org/files/issues/2024-03-18/3431260.patch" + "Create redirect from path alias change and workspaces https://www.drupal.org/project/redirect/issues/3431260": "https://www.drupal.org/files/issues/2024-03-18/3431260.patch" } } } From 3d2a3d20fde0e4f8cd69b22a5342915b53387596 Mon Sep 17 00:00:00 2001 From: ekes Date: Mon, 12 Aug 2024 11:24:13 +0200 Subject: [PATCH 7/8] Update patch for Redirect 1.10+ --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2c383d0..28922f9 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "drupal/gin_toolbar": "^1.0@beta", "drupal/entity_browser": "^2.9", "drupal/preview_link": "^2.1@alpha", - "drupal/redirect": "^1.6", + "drupal/redirect": "^1.10", "drupal/simple_sitemap": "^4.1", "drupal/search_api": "^1.21", "drush/drush": ">=10", @@ -66,7 +66,7 @@ "Add a 'copy to clipboard' feature for preview_link": "https://www.drupal.org/files/issues/2024-05-28/3449121-9.patch" }, "drupal/redirect": { - "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2022-09-01/3057250-53.patch" + "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2024-08-11/redirect--2024-08-11--3057250-79.patch" } } } From c2c228eba0e6c50857a19bfea0ef5b0c737ef0e2 Mon Sep 17 00:00:00 2001 From: ekes Date: Tue, 13 Aug 2024 09:54:08 +0100 Subject: [PATCH 8/8] Fix JSON: missing ,. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d1e542e..a8444ba 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,7 @@ "Allow path generation inside of a workspace - and importantly don't regenerate when publishing space https://www.drupal.org/project/pathauto/issues/3283769": "https://www.drupal.org/files/issues/2024-04-08/3283769-10.patch" }, "drupal/redirect": { - "Create redirect from path alias change and workspaces https://www.drupal.org/project/redirect/issues/3431260": "https://www.drupal.org/files/issues/2024-03-18/3431260.patch" + "Create redirect from path alias change and workspaces https://www.drupal.org/project/redirect/issues/3431260": "https://www.drupal.org/files/issues/2024-03-18/3431260.patch", "Validation issue on adding url redirect: https://www.drupal.org/project/redirect/issues/3057250": "https://www.drupal.org/files/issues/2024-08-11/redirect--2024-08-11--3057250-79.patch" } }