Unverified Commit 72d8ef56 authored by Nick Santamaria's avatar Nick Santamaria Committed by GitHub
Browse files

[#3290308] Automated Drupal 10 compatibility fixes (#41)



* Issue #3290308 by Project Update Bot, joestewart, Kristen Pol: Automated Drupal 10 compatibility fixes

* Replaced circle build with one from Drevops.

* Lint fixes.

Co-authored-by: default avatarKristen Pol <22321-kepol@users.noreply.drupalcode.org>
parent a27951fc
Loading
Loading
Loading
Loading
+164 −43
Original line number Diff line number Diff line
#!/usr/bin/env bash
##
# Build.
# Build Drupal site using SQLite database, install current module and serve
# using in-built PHP server.
#
# shellcheck disable=SC2015,SC2094
# Allows to use the latest Drupal core as well as specified versions (for
# testing backward compatibility).
#
# - Retrieves the scaffold from drupal-composer/drupal-project or custom scaffold.
# - Builds Drupal site codebase with current module and it's dependencies.
# - Installs Drupal using SQLite database.
# - Starts in-built PHP-server
# - Enables module
# - Serves site and generates one-time login link
#
# This script will re-build everything from scratch every time it runs.

# shellcheck disable=SC2015,SC2094,SC2002

set -e

echo "==> Validate composer"
#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
#-------------------------------------------------------------------------------

# Directory where Drupal site will be built.
BUILD_DIR="${BUILD_DIR:-build}"

# Webserver hostname.
WEBSERVER_HOST="${WEBSERVER_HOST:-localhost}"

# Webserver port.
WEBSERVER_PORT="${WEBSERVER_PORT:-8000}"

# Drupal core version to use. If not provided - the latest stable version will be used.
# Must be coupled with DRUPAL_PROJECT_SHA below.
DRUPAL_VERSION="${DRUPAL_VERSION:-}"

# Commit SHA of the drupal-project to install custom core version. If not
# provided - the latest version will be used.
# Must be coupled with DRUPAL_VERSION above.
DRUPAL_PROJECT_SHA="${DRUPAL_PROJECT_SHA:-}"

# Repository for "drupal-composer/drupal-project" project.
# May be overwritten to use forked repos that may have not been accepted
# yet (i.e., when major Drupal version is about to be released).
DRUPAL_PROJECT_REPO="${DRUPAL_PROJECT_REPO:-https://github.com/drupal-composer/drupal-project.git}"

# Drupal profile to use when installing the site.
DRUPAL_PROFILE="${DRUPAL_PROFILE:-standard}"

# Module name, taken from the .info file.
MODULE="$(basename -s .info.yml -- ./*.info.yml)"

# Database file path.
DB_FILE="${DB_FILE:-/tmp/site_${MODULE}.sqlite}"

#-------------------------------------------------------------------------------

echo
echo "==> Started build in \"${BUILD_DIR}\" directory."
echo

echo "-------------------------------"
echo " Validating requirements       "
echo "-------------------------------"

echo "  > Validating tools."
! command -v git > /dev/null && echo "ERROR: Git is required for this script to run." && exit 1
! command -v php > /dev/null && echo "ERROR: PHP is required for this script to run." && exit 1
! command -v composer > /dev/null && echo "ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1
! command -v jq > /dev/null && echo "ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1

echo "  > Validating Composer configuration."
composer validate --ansi --strict

[ -d build ] && echo "==> Remove existing build directory" && chmod -Rf 777 build && rm -rf build
# Reset the environment.
[ -d "${BUILD_DIR}" ] && echo "  > Removing existing ${BUILD_DIR} directory." && chmod -Rf 777 "${BUILD_DIR}" && rm -rf "${BUILD_DIR}"

# Allow installing custom version of Drupal core, but only coupled with
# drupal-project SHA (required to get correct dependencies).
if [ -n "${DRUPAL_PROJECT_SHA}" ] && [ -n "${DRUPAL_VERSION}" ] ; then
  echo "==> Initialise Drupal site from the scaffold commit $DRUPAL_PROJECT_SHA"
echo "-------------------------------"
echo " Installing Composer packages  "
echo "-------------------------------"

  git clone -n https://github.com/drupal-composer/drupal-project.git build
  git --git-dir=build/.git --work-tree=build checkout "${DRUPAL_PROJECT_SHA}"
  rm -rf build/.git > /dev/null
# Allow installing custom version of Drupal core from drupal-composer/drupal-project,
# but only coupled with drupal-project SHA (required to get correct dependencies).
if [ -n "${DRUPAL_VERSION}" ] && [ -n "${DRUPAL_PROJECT_SHA}" ]; then
  echo "  > Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} commit ${DRUPAL_PROJECT_SHA}."

  echo "==> Pin Drupal to a specific version"
  sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
  sed "${sed_opts[@]}" 's|\(.*"drupal\/core"\): "\(.*\)",.*|\1: '"\"$DRUPAL_VERSION\",|" build/composer.json
  cat build/composer.json
  # Clone Drupal core at the specific commit SHA.
  git clone -n "${DRUPAL_PROJECT_REPO}" "${BUILD_DIR}"
  git --git-dir="${BUILD_DIR}/.git" --work-tree="${BUILD_DIR}" checkout "${DRUPAL_PROJECT_SHA}"
  rm -rf "${BUILD_DIR}/.git" > /dev/null

  echo "==> Install dependencies"
  php -d memory_limit=-1 "$(command -v composer)" --working-dir=build install
  echo "  > Pinning Drupal to a specific version ${DRUPAL_VERSION}."
  sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
  sed "${sed_opts[@]}" 's|\(.*"drupal\/core"\): "\(.*\)",.*|\1: '"\"$DRUPAL_VERSION\",|" "${BUILD_DIR}/composer.json"
  cat "${BUILD_DIR}/composer.json"
else
  echo "==> Initialise Drupal site from the latest scaffold"
  php -d memory_limit=-1 "$(command -v composer)" create-project drupal-composer/drupal-project:8.x-dev build --no-interaction
  echo "  > Initialising Drupal site from the latest scaffold."
  # There are no releases in "drupal-composer/drupal-project", so have to use "@dev".
  php -d memory_limit=-1 "$(command -v composer)" create-project drupal-composer/drupal-project:@dev "${BUILD_DIR}" --no-interaction --no-install
fi

echo "==> Install additional dev dependencies from module's composer.json"
cat <<< "$(jq --indent 4 -M -s '.[0] * .[1]' composer.json build/composer.json)" > build/composer.json
php -d memory_limit=-1 "$(command -v composer)" --working-dir=build update --lock
echo "  > Updating scaffold."
cat <<< "$(jq --indent 4 '.extra["enable-patching"] = true' "${BUILD_DIR}/composer.json")" > "${BUILD_DIR}/composer.json"
cat <<< "$(jq --indent 4 '.extra["phpcodesniffer-search-depth"] = 10' "${BUILD_DIR}/composer.json")" > "${BUILD_DIR}/composer.json"

echo "  > Merging configuration from module's composer.json."
php -r "echo json_encode(array_replace_recursive(json_decode(file_get_contents('composer.json'), true),json_decode(file_get_contents('${BUILD_DIR}/composer.json'), true)),JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);" > "${BUILD_DIR}/composer2.json" && mv -f "${BUILD_DIR}/composer2.json" "${BUILD_DIR}/composer.json"

echo "  > Creating GitHub authentication token if provided."
[ -n "$GITHUB_TOKEN" ] && composer config --global github-oauth.github.com "$GITHUB_TOKEN" && echo "Token: " && composer config --global github-oauth.github.com

echo "  > Installing dependencies."
php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" install

echo "==> Install other dev dependencies"
cat <<< "$(jq --indent 4 '.extra["phpcodesniffer-search-depth"] = 10' build/composer.json)" > build/composer.json
php -d memory_limit=-1 "$(command -v composer)" --working-dir=build require --dev dealerdirect/phpcodesniffer-composer-installer
# Suggested dependencies allow to install them for testing without requiring
# them in module's composer.json.
echo "  > Installing suggested dependencies from module's composer.json."
composer_suggests=$(cat composer.json | jq -r 'select(.suggest != null) | .suggest | keys[]')
for composer_suggest in $composer_suggests; do
  php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" require "${composer_suggest}"
done

echo "==> Start inbuilt PHP server in $(pwd)/build/web"
echo "  > Installing other dev dependencies."
php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" require --dev \
  dealerdirect/phpcodesniffer-composer-installer \
  phpspec/prophecy-phpunit:^2 \
  mglaman/drupal-check \
  palantirnet/drupal-rector
cp "${BUILD_DIR}/vendor/palantirnet/drupal-rector/rector.php" "${BUILD_DIR}/."

echo "-------------------------------"
echo " Starting builtin PHP server   "
echo "-------------------------------"

# Stop previously started services.
killall -9 php > /dev/null 2>&1 || true
nohup php -S localhost:8000 -t "$(pwd)/build/web" "$(pwd)/build/web/.ht.router.php" > /tmp/php.log 2>&1 &
# Start the PHP webserver.
nohup php -S "${WEBSERVER_HOST}:${WEBSERVER_PORT}" -t "$(pwd)/${BUILD_DIR}/web" "$(pwd)/${BUILD_DIR}/web/.ht.router.php" > /tmp/php.log 2>&1 &
sleep 4 # Waiting for the server to be ready.
netstat_opts='-tulpn'; [ "$(uname)" == "Darwin" ] && netstat_opts='-anv' || true;
netstat "${netstat_opts[@]}" | grep -q 8000 || (echo "ERROR: Unable to start inbuilt PHP server" && cat /tmp/php.log && exit 1)
curl -s -o /dev/null -w "%{http_code}" -L -I http://localhost:8000 | grep -q 200 || (echo "ERROR: Server is started, but site cannot be served" && exit 1)
# Check that the server was started.
netstat "${netstat_opts[@]}" | grep -q "${WEBSERVER_PORT}" || (echo "ERROR: Unable to start inbuilt PHP server" && cat /tmp/php.log && exit 1)
# Check that the server can serve content.
curl -s -o /dev/null -w "%{http_code}" -L -I "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" | grep -q 200 || (echo "ERROR: Server is started, but site cannot be served" && exit 1)
echo "  > Started builtin PHP server at http://${WEBSERVER_HOST}:${WEBSERVER_PORT} in $(pwd)/${BUILD_DIR}/web."

MODULE=$(basename -s .info.yml -- ./*.info.yml)
DB_FILE="${DB_FILE:-/tmp/site_${MODULE}.sqlite}"
echo "-------------------------------"
echo " Installing Drupal and modules "
echo "-------------------------------"

echo "  > Installing Drupal into SQLite database ${DB_FILE}."
"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" si "${DRUPAL_PROFILE}" -y --db-url "sqlite://${DB_FILE}" --account-name=admin install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL
"${BUILD_DIR}/vendor/bin/drush" -r "$(pwd)/${BUILD_DIR}/web" status

echo "  > Symlinking module code."
rm -rf "${BUILD_DIR}/web/modules/${MODULE}"/* > /dev/null
mkdir -p "${BUILD_DIR}/web/modules/${MODULE}"
ln -s "$(pwd)"/* "${BUILD_DIR}/web/modules/${MODULE}" && rm "${BUILD_DIR}/web/modules/${MODULE}/${BUILD_DIR}"

echo "  > Enabling module ${MODULE}."
"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" pm:enable "${MODULE}" -y
"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" cr

echo "  > Enabling suggested modules, if any."
drupal_suggests=$(cat composer.json | jq -r 'select(.suggest != null) | .suggest | keys[]' | sed "s/drupal\///" | cut -f1 -d":")
for drupal_suggest in $drupal_suggests; do
  "${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" pm:enable "${drupal_suggest}" -y
done

echo "==> Install Drupal into SQLite database ${DB_FILE}"
build/vendor/bin/drush -r build/web si "${DRUPAL_PROFILE:-standard}" -y --db-url "sqlite://${DB_FILE}" --account-name=admin install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL
build/vendor/bin/drush -r "$(pwd)/build/web" status
# Visit site to pre-warm caches.
curl -s "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" > /dev/null

echo "==> Symlink module code"
rm -rf build/web/modules/"${MODULE}"/* > /dev/null
mkdir -p "build/web/modules/${MODULE}"
ln -s "$(pwd)"/* build/web/modules/"${MODULE}" && rm build/web/modules/"${MODULE}"/build
echo "-------------------------------"
echo " Build finished 🚀🚀🚀"
echo "-------------------------------"

echo "==> Enable module ${MODULE}"
build/vendor/bin/drush -r build/web pm:enable "${MODULE}" -y
build/vendor/bin/drush -r build/web cr
build/vendor/bin/drush -r build/web -l http://localhost:8000 uli --no-browser
echo
echo "  > Site URL:            http://${WEBSERVER_HOST}:${WEBSERVER_PORT}"
echo -n "  > One-time login link: "
"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" -l "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" uli --no-browser
echo "  > Available commands:"
echo "    ahoy build  # rebuild"
echo "    ahoy lint   # check coding standards"
echo "    ahoy test   # run tests"
echo
+33 −60
Original line number Diff line number Diff line
# @see https://github.com/integratedexperts/drupal_circleci
# @see https://github.com/drevops/drupal_circleci
version: 2
aliases:
  # SSH deployment key fingerprint from CircleCI App -> Project -> Settings -> SSH Permissions.
  # Replace the value for your project.
  - &deploy_ssh_fingerprint "31:e8:10:d4:d6:e9:b3:0f:d6:f6:10:c5:94:66:87:6d"
  - &deploy_ssh_fingerprint "2d:71:4d:aa:4d:34:38:b5:8f:af:ca:3b:d4:82:6a:21"
  - &container_config
    working_directory: ~/project
    docker:
      - image: circleci/php:7.4-cli-browsers
      - image: cimg/php:8.1-browsers

job-build: &job-build
  steps:
    - checkout
    - run: |
        sudo -E apt-get update && sudo -E apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev jq \
        && sudo -E docker-php-ext-install -j$(nproc) iconv \
        && if [ "$(php -r "echo PHP_MAJOR_VERSION;")" -gt 5 ] && [ "$(php -r "echo PHP_MINOR_VERSION;")" -gt 3 ] ; then sudo -E docker-php-ext-configure gd --with-freetype --with-jpeg; else sudo -E docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/; fi \
        && sudo -E docker-php-ext-install -j$(nproc) gd
    - run: .circleci/build.sh
    - run: .circleci/lint.sh
    - run: .circleci/test.sh
@@ -25,62 +20,47 @@ job-build: &job-build
        when: always
    - store_test_results:
        path: /tmp/test_results
        when: always
    - store_artifacts:
        path: /tmp/artifacts
        when: always

jobs:
  build-php-7.4:
  build-php-8.0:
    <<: *container_config
    docker:
      - image: cimg/php:8.0-browsers
    <<: *job-build

  build-php-7.3:
  build-php-8.1:
    <<: *container_config
    docker:
      - image: circleci/php:7.3-cli-browsers
      - image: cimg/php:8.1-browsers
    <<: *job-build

  build-php-7.2:
  build-php-8.0-legacy:
    <<: *container_config
    docker:
      - image: circleci/php:7.2-cli-browsers
      - image: cimg/php:8.0-browsers
    environment:
      DRUPAL_VERSION: 9.3.22
      DRUPAL_PROJECT_SHA: 9.x
    <<: *job-build

  # @todo: Enable after Drupal core > 8.8.0 release, so that DRUPAL_VERSION
  # would become 8.8.0. This is due to a core version < 8.8 does not support
  # php 7.4. But we still want to provide the template for testing code with
  # legacy cores.
  # Also, enable in workflows below.
  # build-php-7.4-legacy:
  #   <<: *container_config
  #   environment:
  #     DRUPAL_VERSION: 8.7.6
  #     # Drupal project commit before moving 8.8.0.
  #     # https://github.com/drupal-composer/drupal-project/commit/53f6910c35db73d0b367d5b6f22be4af94dd1af3
  #     DRUPAL_PROJECT_SHA: 53f6910c35db73d0b367d5b6f22be4af94dd1af3
  #   <<: *job-build

  build-php-7.3-legacy:
  build-php-8.1-legacy:
    <<: *container_config
    docker:
      - image: circleci/php:7.3-cli-browsers
      - image: cimg/php:8.1-browsers
    environment:
      DRUPAL_VERSION: 8.7.6
      # Drupal project commit before moving 8.8.0.
      # https://github.com/drupal-composer/drupal-project/commit/53f6910c35db73d0b367d5b6f22be4af94dd1af3
      DRUPAL_PROJECT_SHA: 53f6910c35db73d0b367d5b6f22be4af94dd1af3
      DRUPAL_VERSION: 9.3.22
      DRUPAL_PROJECT_SHA: 9.x
    <<: *job-build

  build-php-7.2-legacy:
  build-php-8.1-next:
    <<: *container_config
    docker:
      - image: circleci/php:7.2-cli-browsers
      - image: cimg/php:8.1-browsers
    environment:
      DRUPAL_VERSION: 8.7.6
      # Drupal project commit before moving 8.8.0.
      # https://github.com/drupal-composer/drupal-project/commit/53f6910c35db73d0b367d5b6f22be4af94dd1af3
      DRUPAL_PROJECT_SHA: 53f6910c35db73d0b367d5b6f22be4af94dd1af3
      DRUPAL_VERSION: 10@beta2
      DRUPAL_PROJECT_SHA: 10.x
    <<: *job-build

  deploy:
@@ -98,43 +78,36 @@ workflows:
  version: 2
  main:
    jobs:
      - build-php-7.4:
      - build-php-8.0:
          filters:
            tags:
              only: /.*/
      - build-php-7.3:
      - build-php-8.1:
          filters:
            tags:
              only: /.*/
      - build-php-7.2:
      - build-php-8.0-legacy:
          filters:
            tags:
              only: /.*/
      # @todo: Enable after Drupal core version > 8.8.0 released.
      # - build-php-7.4-legacy:
      #     filters:
      #       tags:
      #         only: /.*/
      - build-php-7.3-legacy:
      - build-php-8.1-legacy:
          filters:
            tags:
              only: /.*/
      - build-php-7.2-legacy:
      - build-php-8.1-next:
          filters:
            tags:
              only: /.*/
      - deploy:
          requires:
            - build-php-7.4
            - build-php-7.3
            - build-php-7.2
            # @todo: Enable after Drupal core version > 8.8.0 released.
            # - build-php-7.4-legacy
            - build-php-7.3-legacy
            - build-php-7.2-legacy
            - build-php-8.0
            - build-php-8.1
            - build-php-8.0-legacy
            - build-php-8.1-legacy
            - build-php-8.1-next
          filters:
            tags:
              only: /.*/
            branches:
              # 7.x, 8.x, 7.x-1.x, 8.x-1.x, 7.x-2.x, 8.x-2.x, ci
              only: /^(?:7|8)\.x(?:\-[0-9]+\.x)?|ci$/
              # 8.x, 9.x, 10.x, 8.x-1.x, 8.x-1.x, 8.x-2.x, 9.x-2.x, ci
              only: /^[0-9]+.x(?:\-[0-9]+\.x)?|ci$/
+34 −13
Original line number Diff line number Diff line
@@ -10,24 +10,39 @@
# every project.
#
# Add the following variables through CircleCI UI.
# DEPLOY_USER_NAME - name of the user who will be committing to a remote repository.
# DEPLOY_USER_EMAIL - email address of the user who will be committing to a remote repository.
# DEPLOY_REMOTE - remote repository to push code to.
# DEPLOY_PROCEED - set to 1 if the deployment should proceed. Useful for testing CI configuration before an actual code push.
#
# Other variables:
# DEPLOY_BRANCH - git branch to deploy.
# DEPLOY_SSH_FINGERPRINT - the fingerprint of the SSH key of the user on behalf of which the deployment is performed.
# - DEPLOY_USER_NAME - name of the user who will be committing to a remote repository.
# - DEPLOY_USER_EMAIL - email address of the user who will be committing to a remote repository.
# - DEPLOY_REMOTE - remote repository to push code to.
# - DEPLOY_PROCEED - set to 1 if the deployment should proceed. Useful for testing CI configuration before an actual code push.

set -e

#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
#-------------------------------------------------------------------------------

# Name of the user who will be committing to a remote repository.
DEPLOY_USER_NAME="${DEPLOY_USER_NAME}"

# Email address of the user who will be committing to a remote repository.
DEPLOY_USER_EMAIL="${DEPLOY_USER_EMAIL}"

# Remote repository to push code to.
DEPLOY_REMOTE="${DEPLOY_REMOTE:-}"

# Git branch to deploy. If not provided - current branch will be used.
DEPLOY_BRANCH="${DEPLOY_BRANCH:-}"

# The fingerprint of the SSH key of the user on behalf of which the deployment
# is performed.
DEPLOY_SSH_FINGERPRINT="${DEPLOY_SSH_FINGERPRINT:-}"

# Set to 1 if the deployment should proceed. Useful for testing CI configuration
# before an actual code push.
DEPLOY_PROCEED="${DEPLOY_PROCEED:-0}"

#-------------------------------------------------------------------------------

[ -z "${DEPLOY_USER_NAME}" ] && echo "ERROR: Missing required value for DEPLOY_USER_NAME" && exit 1
[ -z "${DEPLOY_USER_EMAIL}" ] && echo "ERROR: Missing required value for DEPLOY_USER_EMAIL" && exit 1
[ -z "${DEPLOY_REMOTE}" ] && echo "ERROR: Missing required value for DEPLOY_REMOTE" && exit 1
@@ -40,19 +55,25 @@ mkdir -p "${HOME}/.ssh/"
echo -e "Host *\n\tStrictHostKeyChecking no\n" > "${HOME}/.ssh/config"
DEPLOY_SSH_FILE="${DEPLOY_SSH_FINGERPRINT//:}"
DEPLOY_SSH_FILE="${HOME}/.ssh/id_rsa_${DEPLOY_SSH_FILE//\"}"
[ ! -f "${DEPLOY_SSH_FILE}" ] && echo "ERROR: Unable to find Deploy SSH key file ${DEPLOY_SSH_FILE}" && exit 1
[ ! -f "${DEPLOY_SSH_FILE}" ] && echo "ERROR: Unable to find Deploy SSH key file ${DEPLOY_SSH_FILE}." && exit 1
if [ -z "${SSH_AGENT_PID}" ]; then eval "$(ssh-agent)"; fi
ssh-add -D > /dev/null
ssh-add "${DEPLOY_SSH_FILE}"

[ "$(git config --global user.name)" == "" ] && echo "==> Configuring global git user name" && git config --global user.name "${DEPLOY_USER_NAME}"
[ "$(git config --global user.email)" == "" ] && echo "==> Configuring global git user email" && git config --global user.email "${DEPLOY_USER_EMAIL}"
# Configure git user name and email, but only if not already set.
[ "$(git config --global user.name)" == "" ] && echo "==> Configuring global git user name ${DEPLOY_USER_NAME}." && git config --global user.name "${DEPLOY_USER_NAME}"
[ "$(git config --global user.email)" == "" ] && echo "==> Configuring global git user email ${DEPLOY_USER_EMAIL}." && git config --global user.email "${DEPLOY_USER_EMAIL}"

# Set git to push to a matching remote branch.
git config --global push.default matching

echo "==> Adding remote ${DEPLOY_REMOTE}"
echo "==> Adding remote ${DEPLOY_REMOTE}."
git remote add deployremote "${DEPLOY_REMOTE}"

echo "==> Deploying to remote ${DEPLOY_REMOTE}"
echo "==> Deploying to remote ${DEPLOY_REMOTE}."
# shellcheck disable=SC2086
git push --force --tags deployremote ${DEPLOY_BRANCH}

echo
echo "==> Deployment finished."
echo
+31 −3
Original line number Diff line number Diff line
@@ -5,7 +5,35 @@

set -e

MODULE=$(basename -s .info.yml -- ./*.info.yml)
#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
#-------------------------------------------------------------------------------

echo "==> Lint code"
build/vendor/bin/phpcs -s --standard=Drupal,DrupalPractice --extensions=module,php,install,inc,test,info.yml,js "build/web/modules/${MODULE}"
# Directory where Drupal site will be built.
BUILD_DIR="${BUILD_DIR:-build}"

# Module name, taken from .info file.
MODULE="$(basename -s .info.yml -- ./*.info.yml)"

#-------------------------------------------------------------------------------

echo "==> Lint code for module $MODULE."
echo "  > Running PHPCS."
build/vendor/bin/phpcs \
  -s \
  -p \
  --standard=Drupal,DrupalPractice \
  --extensions=module,php,install,inc,test,info.yml,js \
  "build/web/modules/${MODULE}"

echo "  > Running drupal-check."
build/vendor/bin/drupal-check \
  --drupal-root=build/web \
  "build/web/modules/${MODULE}" || echo "  > .. ignoring drupal-check failures"

echo "  > Running Drupal Rector."
pushd "build" >/dev/null || exit 1
vendor/bin/rector process \
  "web/modules/${MODULE}" \
  --dry-run
popd >/dev/null || exit 1
+13 −2
Original line number Diff line number Diff line
@@ -2,10 +2,21 @@
##
# Process test artifacts.
#
# This runs only in CircleCI.
#
set -e

if [ -d "$(pwd)/build/web/sites/simpletest/browser_output" ]; then
#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
#-------------------------------------------------------------------------------

# Directory where Drupal site will be built.
BUILD_DIR="${BUILD_DIR:-build}"

#-------------------------------------------------------------------------------

if [ -d "$(pwd)/${BUILD_DIR}/web/sites/simpletest/browser_output" ]; then
  echo "==> Copying Simpletest test artifacts"
  mkdir -p /tmp/artifacts/simpletest
  cp -Rf "$(pwd)/build/web/sites/simpletest/browser_output/." /tmp/artifacts/simpletest
  cp -Rf "$(pwd)/${BUILD_DIR}/web/sites/simpletest/browser_output/." /tmp/artifacts/simpletest
fi
Loading