diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 349533ef8765eabea40e7c78b1efad8b0acc14c7..fea217916b2731da84357c62f2e2e99c8d3ab20d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,23 +34,55 @@ create-or-update-multidev: echo "** Checking Multidev $MULTIDEV_NAME. If doesn't exist - creating and locking **" MULTIDEV_INITIALIZED=$(terminus env:info $PATHEON_SITE.$MULTIDEV_NAME --field=initialized || true) if [ -n "$MULTIDEV_INITIALIZED" ]; then - echo "** Environment exists. Rebuilding the code **" - terminus env:code-rebuild $PATHEON_SITE.$MULTIDEV_NAME + echo "** Environment $MULTIDEV_NAME exists.**" + INSTALL_SITE=false else - echo "** Environment doesn't exist. Creating, patching and locking it **" + echo "** Environment doesn't exist. Creating and locking it **" terminus multidev:create $PATHEON_SITE.dev $MULTIDEV_NAME terminus lock:enable $PATHEON_SITE.$MULTIDEV_NAME $ENV_BASIC_USERNAME $ENV_BASIC_PASSWORD - git clone $GIT_URL -b $MULTIDEV_NAME ./site_repo - cd ./site_repo - jq ".require.\"uis-drupal-team/drupal-10-cambridge-profile\" = \"dev-$CI_COMMIT_REF_NAME\"" upstream-configuration/composer.json > upstream-configuration/composer_modified.json \ - && mv upstream-configuration/composer_modified.json upstream-configuration/composer.json - echo "** The following upstream-configuration/composer.json changes will be comitted to $MULTIDEV_NAME branch **" - cat upstream-configuration/composer.json - git config user.email "not-real-address@gitlab.developers.cam.ac.uk" - git config user.name "CI Job" - git add upstream-configuration/composer.json - git commit -m "Update upstream-configuration/composer.json with profile branch $CI_COMMIT_REF_NAME" - git push + INSTALL_SITE=true + fi + + echo "** Updating Multidev $MULTIDEV_NAME's upstream with actual commit hash **" + git clone $GIT_URL -b $MULTIDEV_NAME ./site_repo + cd ./site_repo + jq ".require.\"uis-drupal-team/drupal-10-cambridge-profile\" = \"dev-$CI_COMMIT_REF_NAME#$CI_COMMIT_SHA\"" upstream-configuration/composer.json > upstream-configuration/composer_modified.json \ + && mv upstream-configuration/composer_modified.json upstream-configuration/composer.json + echo "** The following upstream-configuration/composer.json changes will be comitted to $MULTIDEV_NAME branch **" + cat upstream-configuration/composer.json + git config user.email "not-real-address@gitlab.developers.cam.ac.uk" + git config user.name "CI Job" + git add upstream-configuration/composer.json + git commit -m "Update upstream-configuration/composer.json with profile branch $CI_COMMIT_REF_NAME" + git push + sleep 5 + + echo "** Waiting for 'Sync Code' workflow to be done **" + TIMEOUT=300 + START_TIME=$(date +%s) + while true; do + STATUS=$(terminus workflow:list $PATHEON_SITE --format=json | jq -r "to_entries | map(select(.value.workflow | test(\"^Sync code on\")) | select(.value.env == \"$MULTIDEV_NAME\")).[0].value.status") + if [[ "$STATUS" == "succeeded" ]]; then + echo "** 'Sync Code' workflow completed successfully **" + break + fi + # Check if the timeout has been reached + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + if [[ $ELAPSED_TIME -ge $TIMEOUT ]]; then + echo "** Timeout reached. 'Sync Code' workflow did not complete successfully within 5 minutes **" + break + fi + sleep 10 + done + + echo "** Updatig upstream **" + terminus upstream:updates:status -- $PATHEON_SITE.$MULTIDEV_NAME + terminus upstream:updates:apply --updatedb --accept-upstream -- $PATHEON_SITE.$MULTIDEV_NAME + + if [[ "$INSTALL_SITE" == true ]]; then + echo "** This is a first run of CI job for $MULTIDEV_NAME. Running 'drush site-install' **" + terminus drush $PATHEON_SITE.$MULTIDEV_NAME -- site-install cambridge_d10 --site-name=cwp -y fi echo "** Receiving information about the environment **" @@ -79,14 +111,13 @@ clean-up-multidevs: done echo "** Getting information about multidev environments **" - MULTIDEVS=$(terminus multidev:list $PATHEON_SITE --format=json | jq '.[].id' | grep 'ci-mr-.d*') + MULTIDEVS=$(terminus multidev:list $PATHEON_SITE --format=json | jq -r '.[].id' | grep 'ci-mr-.d*' || true) if [ -n "$MULTIDEVS" ]; then echo "** Check multidevs for opened MRs **" for multidev in `echo $MULTIDEVS`; do echo "** Working with $multidev ENV **" - CLEAN_NAME=$(echo $multidev | tr -d '"') - if ! echo "$NAMES_FROM_MRS" | grep -q -w $CLEAN_NAME; then + if ! echo "$NAMES_FROM_MRS" | grep -q -w $multidev; then echo "** Deleting environment $multidev **" yes | terminus env:delete $PATHEON_SITE.$CLEAN_NAME || true else diff --git a/cambridge_d10.info.yml b/cambridge_d10.info.yml index 25b89d433329715696575c1700bd68814a7dc369..6a0215d1aaaa957cdb3b8035ce9ac52864d3bb9e 100755 --- a/cambridge_d10.info.yml +++ b/cambridge_d10.info.yml @@ -96,8 +96,6 @@ install: - drupal:menu_item_fields_ui - drupal:media_migration - drupal:media_migration_tools - - drupal:memcache - - drupal:memcache_admin - drupal:menu_force - drupal:menu_link_content - drupal:menu_ui @@ -185,7 +183,6 @@ install: - drupal:webform_migrate - drupal:webform_node - drupal:webform_ui - - drupal:storybook # Required modules # Note that any dependencies of the modules listed here will be installed automatically. diff --git a/composer.json b/composer.json index 470ea3a0467513509783205b0cbb7ac8944991ca..9ca61271cddf78063b1ab4ba8b2950b3deda34b5 100644 --- a/composer.json +++ b/composer.json @@ -108,7 +108,6 @@ "drupal/libraries": "^4.0", "drupal/linked_field": "^1.5", "drupal/media_migration": "^1.0@alpha", - "drupal/memcache": "^2.5", "drupal/menu_firstchild": "^2.1", "drupal/menu_force": "^2.0", "drupal/menu_position": "^1.1",