Skip to content

Commit

Permalink
[SITE-1855] Drupal 11 support (#58)
Browse files Browse the repository at this point in the history
* Declare Drupal 11 compatibility

* Use https url rather than git@ to avoid auth issues

* Try testing on Drupal 11. What could possibly go wrong?

* Don't uninstall the pantheon_advanced_page_cache_test at the beginning of the behat tests, since no one has installed it yet.

* Updated test to visit the page.

* Cache headers innacurate under behat with Drupal 11, disabling Drupal 11 tests for now.

* Avoid using so many Github API requests, and instead just copy the SUT into the test site without using Composer.

* Typo in variable assignment

* Make sure that we do not create test site inside project directory

* Skip copying dot files as a cleaner way to avoid creating a submodule.

* Fix quoting of *

* Use rsync to copy so that we can keep the drupal site where it was, inside the project directory.

* Go back to requiring via Composer, but do so via path repository

* Give path repository project an arbitrary specific version.

* Ah, right, path repositories are symlinked, so they need to be included in the site repository.

* Sync code can be very slow; wait longer

* Speculative fix for BUGS-8929; guard against situations where Drupal\image\Entity\ImageStyle might not exist.

---------

Co-authored-by: Sumit Madan <[email protected]>
  • Loading branch information
greg-1-anderson and iamsumit authored Sep 27, 2024
1 parent a8993fa commit 8db7247
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- run:
name: site install
command: |
terminus build:workflow:wait ${TERMINUS_SITE}.${CIRCLE_BUILD_NUM}
terminus build:workflow:wait ${TERMINUS_SITE}.${CIRCLE_BUILD_NUM} --max=300
terminus connection:set ${TERMINUS_SITE}.${CIRCLE_BUILD_NUM} sftp
terminus env:wake ${TERMINUS_SITE}.${CIRCLE_BUILD_NUM}
terminus drush ${TERMINUS_SITE}.${CIRCLE_BUILD_NUM} -- site-install -y
Expand Down
23 changes: 13 additions & 10 deletions .circleci/scripts/setup-drupal-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
set -e
export TERMINUS_ENV=$CIRCLE_BUILD_NUM

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CIRCLE_DIR="$(dirname -- "${SCRIPT_DIR}")"
PROJECT_DIR="$(dirname -- "${CIRCLE_DIR}")"

if [ "$TERMINUS_BASE_ENV" = "dev" ]; then
export TERMINUS_BASE_ENV=master
fi
Expand All @@ -18,18 +22,17 @@ git checkout -b $TERMINUS_ENV
# git clone command above.
composer update "pantheon-upstreams/upstream-configuration"

composer -- config repositories.papc vcs [email protected]:pantheon-systems/pantheon_advanced_page_cache.git
# Add views_custom_cache_tag
composer -- require "drupal/views_custom_cache_tag:1.x-dev"

# dev-2.x does not match anything, should be 2.x-dev as per https://getcomposer.org/doc/articles/aliases.md#branch-alias.
export BRANCH_PART="dev-${CIRCLE_BRANCH}"
if [ $CIRCLE_BRANCH = "2.x" ]; then
export BRANCH_PART="2.x-dev"
fi
# Composer require the given commit of this module
composer -- require "drupal/views_custom_cache_tag:1.x-dev" "drupal/pantheon_advanced_page_cache:${BRANCH_PART}#${CIRCLE_SHA1}"
# Make a copy of this project and rename it to use in a path repository
mkdir -p path-repositories/pantheon_advanced_page_cache
rsync -av --exclude='vendor' --exclude='drupal-site' "$PROJECT_DIR/"* path-repositories/pantheon_advanced_page_cache
sed -e 's#"name": "drupal/pantheon_advanced_page_cache"#"version": "dev-circle", "name": "local-path/pantheon_advanced_page_cache"#' "$PROJECT_DIR/composer.json" > path-repositories/pantheon_advanced_page_cache/composer.json

# Don't commit a submodule
rm -rf web/modules/contrib/pantheon_advanced_page_cache/.git/
# Require via Composer, in case we need to require any dependencies in the future & etc.
composer -- config repositories.papc path path-repositories/pantheon_advanced_page_cache
composer -- require "local-path/pantheon_advanced_page_cache: dev-circle"

# Make a git commit
git add .
Expand Down
3 changes: 2 additions & 1 deletion pantheon_advanced_page_cache.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ name: Pantheon Advanced Page Cache
description: 'Advanced page cache capabilities for Pantheon.'
package: Performance and scalability
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11

2 changes: 1 addition & 1 deletion pantheon_advanced_page_cache.module
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function pantheon_advanced_page_cache_file_update(EntityInterface $file) {

// If this is an image, we need to clear the edge cache paths for every
// image style, or those won't work.
if (strpos($file->getMimeType(), 'image', 0) === 0) {
if ((class_exists(ImageStyle)) && (strpos($file->getMimeType(), 'image', 0) === 0)) {
$styles = ImageStyle::loadMultiple();
foreach ($styles as $style) {
$file_uri = $file->getFileUri();
Expand Down
1 change: 0 additions & 1 deletion tests/behat/features/huge_header_warning.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ I need a notification when my header is truncated.

@api
Scenario: Warning message.
Given I run drush "pm-uninstall -y pantheon_advanced_page_cache_test"
Given I run drush "en -y pantheon_advanced_page_cache"
And I am logged in as a user with the "administrator" role

Expand Down
9 changes: 5 additions & 4 deletions tests/behat/features/override_list_tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ I want to toggle the setting for overriding cache tags
@api
Scenario: Core behavior
Given there are some "article" nodes
And "/" is caching
When I visit "/"
Then "/" is caching
When a generate a "article" node
Then "/" has been purged
And "/" is caching
Expand All @@ -15,7 +16,7 @@ I want to toggle the setting for overriding cache tags
Scenario: Old override
Given there are some "article" nodes
When I run drush "config:set pantheon_advanced_page_cache.settings --input-format=yaml override_list_tags true"
And "/" is caching
And I visit "/"
Then "/" is caching
When a generate a "article" node
And "/" has not been purged

Then "/" has not been purged
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Pantheon Advanced Page Cache Test
description: 'Used during automated test of Pantheon Advanced Page Cache'
package: Testing
type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11

0 comments on commit 8db7247

Please sign in to comment.