Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2265 from ec-europa/ISAICP-6229
Browse files Browse the repository at this point in the history
ISAICP-6229: Use Toolkit dist
  • Loading branch information
idimopoulos authored Oct 2, 2020
2 parents 78ee1d9 + b55df13 commit a43f767
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 73 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
/tests export-ignore
/drush/Commands/ export-ignore
/drush/sites/ export-ignore
/resources/fixtures/ export-ignore
/resources/mac/ export-ignore
/resources/uat/ export-ignore
/web/sites/simpletest/ export-ignore
Expand Down
1 change: 0 additions & 1 deletion .opts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ upgrade_commands:
default:
- ./vendor/bin/drush state:set system.maintenance_mode 1 --input-format=integer --yes
- touch disable-config-readonly
- ./vendor/bin/run redis:flush-all
- ./vendor/bin/drush updatedb --no-post-updates --yes
- ./vendor/bin/drush config:import --yes
- ./vendor/bin/drush updatedb --yes
Expand Down
1 change: 0 additions & 1 deletion resources/drupal-scaffold/.gitattributes.append
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/tests export-ignore
/drush/Commands/ export-ignore
/drush/sites/ export-ignore
/resources/fixtures/ export-ignore
/resources/mac/ export-ignore
/resources/uat/ export-ignore
/web/sites/simpletest/ export-ignore
Expand Down
4 changes: 3 additions & 1 deletion resources/rpmbuild/SPECS/joinup.spec
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ fi

%files
%{_prefix}/%{name}-%{version}/*

%{_prefix}/%{name}-%{version}/.dockerignore
%{_prefix}/%{name}-%{version}/.env.dist
%{_prefix}/%{name}-%{version}/.opts.yml
3 changes: 2 additions & 1 deletion resources/runner/toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ toolkit:
- ${toolkit.build.dist.root}/.editorconfig
- ${toolkit.build.dist.root}/.gitattributes
- ${toolkit.build.dist.root}/.gitignore
- ${toolkit.build.dist.root}/composer.json
# Drupal Finder, and consequently Drush, are still needing
# composer.json to locate the root dir. Remove only composer.lock.
- ${toolkit.build.dist.root}/composer.lock

commands:
Expand Down
15 changes: 7 additions & 8 deletions scripts/rpmbuild/make_joinup_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,24 @@ cp -r ${PROJECT_ROOT}/resources/rpmbuild/* ${BUILD_ROOT} || exit 1
SOURCES_DIR=${BUILD_ROOT}/SOURCES
JOINUP_DIR=${SOURCES_DIR}/Joinup-${BUILD_VERSION}

mkdir -p ${JOINUP_DIR} || exit 1

# Download composer dependencies.
${COMPOSER_PATH} install --no-dev || exit 1
${COMPOSER_PATH} install || exit 1

# Build the site.
./vendor/bin/run joinup:compile-scss || exit 1
./vendor/bin/run toolkit:build-dist || exit 1

# Collect the source files for the package.
cp -r composer.* VERSION config/ drush/ resources/ scripts/ src/ vendor/ web/ ${JOINUP_DIR} || exit 1
# Move the distribution on its location.
mv dist ${JOINUP_DIR} || exit 1

# Replace files and folders with production symlinks.
rm -rf ${JOINUP_DIR}/web/sites/default/settings.php
rm -rf ${JOINUP_DIR}/web/sites/default/files
cp -r ${SOURCES_DIR}/template/* ${JOINUP_DIR}/web || exit 1
rm -r ${SOURCES_DIR}/template || exit 1

# Remove unneeded files.
rm -rf ${JOINUP_DIR}/web/themes/joinup/scss
# Fix Drush settings.
echo 'options:' > ${JOINUP_DIR}/drush/drush.yml
echo " uri: ${DRUPAL_BASE_URL}" >> ${JOINUP_DIR}/drush/drush.yml

# Output the version number in a file that will be appended to the HTTP headers.
echo X-build-id: $BUILD_VERSION > ${SOURCES_DIR}/buildinfo.ini
Expand Down
13 changes: 6 additions & 7 deletions scripts/rpmbuild/make_joinup_build_acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,24 @@ cp -r ${PROJECT_ROOT}/resources/rpmbuild/* ${BUILD_ROOT} || exit 1
SOURCES_DIR=${BUILD_ROOT}/SOURCES
JOINUP_DIR=${SOURCES_DIR}/Joinup-${BUILD_VERSION}

mkdir -p ${JOINUP_DIR} || exit 1

# Download composer dependencies.
${COMPOSER_PATH} install --no-dev || exit 1
${COMPOSER_PATH} install || exit 1

# Build the site.
./vendor/bin/run joinup:compile-scss || exit 1
./vendor/bin/run toolkit:build-dist || exit 1

# Collect the source files for the package.
cp -r composer.* VERSION config/ drush/ resources/ scripts/ src/ vendor/ web/ ${JOINUP_DIR} || exit 1
mv dist ${JOINUP_DIR} || exit 1

# Replace files and folders with production symlinks.
rm -rf ${JOINUP_DIR}/web/sites/default/settings.php
rm -rf ${JOINUP_DIR}/web/sites/default/files
cp -r ${SOURCES_DIR}/template/* ${JOINUP_DIR}/web || exit 1
rm -r ${SOURCES_DIR}/template || exit 1

# Remove unneeded files.
rm -rf ${JOINUP_DIR}/web/themes/joinup/scss
# Fix Drush settings.
echo 'options:' > ${JOINUP_DIR}/drush/drush.yml
echo " uri: ${DRUPAL_BASE_URL}" >> ${JOINUP_DIR}/drush/drush.yml

# Output the version number in a file that will be appended to the HTTP headers.
echo X-build-id: $BUILD_VERSION > ${SOURCES_DIR}/buildinfo.ini
Expand Down
66 changes: 14 additions & 52 deletions scripts/update_production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,31 @@
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT=$(realpath ${SCRIPT_PATH}/..)

# Keep track of any errors that occur during the update.
STATUS=0
trap 'STATUS=$?' ERR

# Virtuoso has a checkpoint interval of 60 minutes. That means that every 60 minutes,
# the server will be un responsive for a small amount of time (a few seconds).
# Since our updates take too long, this can lead to "random" valid query failures.
# Set the interval to 0 to disable automatic checkpoints. At the end of the update
# The interval will be restored, and a manual checkpoint will be fired in order to
# write all the transactions of the updates into the disk.
echo "Disabling automatic checkpoints."
./vendor/bin/run virtuoso:checkpoint-set -- -1

# Perform the necessary steps for the update
cd ${PROJECT_ROOT}

# Make sure config is writable when performing updates. This depends on the
# following code being present in web/sites/default/settings.php:
# $settings['config_readonly'] = !file_exists(getcwd() . '/../disable-config-readonly');
grep -Fqx '$settings['\''config_readonly'\''] = !file_exists(getcwd() . '\''/../disable-config-readonly'\'');' web/sites/default/settings.php

if [ ${STATUS} -ne 0 ]; then
echo "The following line is missing from web/sites/default/settings.php:"
echo '$settings['\''config_readonly'\''] = !file_exists(getcwd() . '\''/../disable-config-readonly'\'');'
exit ${STATUS}
fi
grep -Fqx '$settings['\''config_readonly'\''] = !file_exists(getcwd() . '\''/../disable-config-readonly'\'');' web/sites/default/settings.php || exit 1

echo "Disabling config_readonly."
touch disable-config-readonly
touch disable-config-readonly || exit 1

./vendor/bin/run redis:flush-all &&
./vendor/bin/drush updatedb --yes --no-post-updates &&
./vendor/bin/drush config:import --yes &&
./vendor/bin/drush updatedb --yes &&
./vendor/bin/drush search-api:reset-tracker --yes &&
./vendor/bin/drush updatedb --yes --no-post-updates || exit 1
./vendor/bin/drush config:import --yes || exit 1
./vendor/bin/drush updatedb --yes || exit 1
./vendor/bin/drush search-api:reset-tracker --yes || exit 1

echo "Rebuilding node access records." &&
./vendor/bin/drush php:eval "if(node_access_needs_rebuild()) { node_access_rebuild(); }"

echo "Creating a manual checkpoint."
./vendor/bin/run virtuoso:checkpoint-execute

echo "Restoring the virtuoso checkpoint interval."
./vendor/bin/run virtuoso:checkpoint-set
echo "Rebuilding node access records."
./vendor/bin/drush php:eval "if(node_access_needs_rebuild()) { node_access_rebuild(); }" || exit 1

echo "Enabling config_readonly."
rm disable-config-readonly

# Check if any of the steps returned an error.
if [ ${STATUS} -ne 0 ]; then
echo "An error occurred during the update."
exit ${STATUS}
fi
rm disable-config-readonly || exit 1

# Check if there are any errors or warnings reported.
# Ignore the warning about the update notifications module not being enabled,
# the updates are monitored by the development team.
ERROR_COUNT=$(./vendor/bin/drush status-report --severity=1 --field=title | grep -v "Update notifications" | wc -l)
if [ ${ERROR_COUNT} -ne 0 ]; then
echo "Errors or warnings are reported after the update:"
./vendor/bin/drush status-report --severity=1 | grep -v "Update notifications"
exit 1
fi
# Check if there are any errors or warnings reported. Ignore the warning about
# the update notifications module not being enabled, the updates are monitored
# by the development team.
test $(./vendor/bin/drush status-report --severity=1 --field=title | grep -v "Update notifications" | wc -l) = "0" || (./vendor/bin/drush status-report --severity=1 | grep -v "Update notifications" && exit 1)

echo "Update successfully completed. No errors or warnings reported."
exit 0
exit 0;
2 changes: 1 addition & 1 deletion src/TaskRunner/Commands/BuildCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function getGitTag(): string {
* Current Git hash.
*/
protected function getGitCommitHash(): string {
return Robo::getContainer()->get('repository')->getHead()->getCommitHash();
return Robo::getContainer()->get('repository')->getHeadCommit()->getHash();
}

}

0 comments on commit a43f767

Please sign in to comment.