Skip to content

Commit

Permalink
Added more strict checking for unbound variables in scripts and DEBUG…
Browse files Browse the repository at this point in the history
… variable.

Signed-off-by: Alex Skrypnyk <[email protected]>
  • Loading branch information
AlexSkrypnyk committed Jul 15, 2023
1 parent 531012a commit 8d5ee67
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
7 changes: 4 additions & 3 deletions .circleci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

# shellcheck disable=SC2015,SC2094,SC2002

set -e
set -eu
[ -n "${DEBUG:-}" ] && set -x

#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
Expand Down Expand Up @@ -83,7 +84,7 @@ echo "-------------------------------"

# 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
if [ -n "${DRUPAL_VERSION:-}" ] && [ -n "${DRUPAL_PROJECT_SHA:-}" ]; then
echo " > Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} commit ${DRUPAL_PROJECT_SHA}."

# Clone Drupal core at the specific commit SHA.
Expand All @@ -109,7 +110,7 @@ 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
[ -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
Expand Down
7 changes: 4 additions & 3 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
# - 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
set -eu
[ -n "${DEBUG:-}" ] && set -x

#-------------------------------------------------------------------------------
# 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}"
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}"
DEPLOY_USER_EMAIL="${DEPLOY_USER_EMAIL:-}"

# Remote repository to push code to.
DEPLOY_REMOTE="${DEPLOY_REMOTE:-}"
Expand Down
9 changes: 5 additions & 4 deletions .circleci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Run lint checks.
#

set -e
set -eu
[ -n "${DEBUG:-}" ] && set -x

#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
Expand All @@ -24,15 +25,15 @@ build/vendor/bin/phpcs \
-p \
--standard=Drupal,DrupalPractice \
--extensions=module,php,install,inc,test,info.yml,js \
"build/web/modules/${MODULE}"
"${BUILD_DIR}/web/modules/${MODULE}"

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

echo " > Running Drupal Rector."
pushd "build" >/dev/null || exit 1
pushd "${BUILD_DIR}" >/dev/null || exit 1
vendor/bin/rector process \
"web/modules/${MODULE}" \
--dry-run
Expand Down
4 changes: 3 additions & 1 deletion .circleci/process-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#
# This runs only in CircleCI.
#
set -e

set -eu
[ -n "${DEBUG:-}" ] && set -x

#-------------------------------------------------------------------------------
# Variables (passed from environment; provided for reference only).
Expand Down
3 changes: 2 additions & 1 deletion .circleci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Run tests.
#

set -e
set -eu
[ -n "${DEBUG:-}" ] && set -x

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

0 comments on commit 8d5ee67

Please sign in to comment.