Skip to content

Commit

Permalink
Removed build.sh in favour of Ahoy and CI config.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Feb 18, 2024
1 parent cd81d9f commit d1f0881
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 515 deletions.
41 changes: 23 additions & 18 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ commands:
build:
usage: Build or rebuild the project.
cmd: |
ahoy confirm "Running this command will remove your current database and files. Are you sure?" &&
./scripts/drevops/build.sh &&
ahoy info
ahoy reset && \
ahoy up --build --force-recreate && \
ahoy composer install --prefer-dist && \
(docker compose exec cli mkdir -p .data && docker compose cp -L .data/db.sql cli:/app/.data/db.sql || true) && \
ahoy provision && \
DREVOPS_SHOW_LOGIN_LINK=1 ahoy info
info:
usage: Show information about this project.
Expand All @@ -34,7 +37,6 @@ commands:
DREVOPS_HOST_DB_PORT=$(docker compose port mariadb 3306 2>/dev/null | cut -d : -f 2) \
DREVOPS_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2) \
DREVOPS_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true) \
DREVOPS_DRUPAL_SHOW_LOGIN_LINK=${DREVOPS_DRUPAL_SHOW_LOGIN_LINK} \
ahoy cli ./scripts/drevops/info.sh "$@"
db:
Expand Down Expand Up @@ -82,18 +84,21 @@ commands:

cli:
usage: Start a shell or run a command inside the CLI service container.
# This will drop into shell if no arguments are supplied to this command.
# If arguments supplied, a new shell with TERM, COMPOSE_*, GITHUB_*,
# DOCKER_*, DRUPAL_* and DREVOPS_* environment variables will be started.
# This allows passing of the environment variables to Ahoy commands which
# will then be forwarded to the container.
# Drop into shell if no arguments were supplied.
# If arguments were supplied - a new shell will be started with environment
# variables passed from the host environment and filtered by prefix.
# This allows passing the host environment variables to a container without
# the need to restart it.
# Escape double quotes with \" (slash double-quote) when passing arguments
# with spaces.
# containing spaces.
cmd: if \[ "${#}" -ne 0 \]; then docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\DRUPAL_\|DREVOPS_" | sed 's/^/-e /') -T cli bash -c "$*"; else docker compose exec cli bash; fi

composer:
usage: Run Composer commands in the CLI service container.
cmd: ahoy cli composer "$@"
cmd: |
docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\DRUPAL_\|DREVOPS_" | sed 's/^/-e /') -T cli bash -c " \
if [ -n \"${GITHUB_TOKEN:-}\" ]; then export COMPOSER_AUTH='{\"github-oauth\": {\"github.com\": \"${GITHUB_TOKEN-}\"}}'; fi && \
COMPOSER_MEMORY_LIMIT=-1 composer --ansi $@"
drush:
usage: Run Drush commands in the CLI service container.
Expand Down Expand Up @@ -149,7 +154,7 @@ commands:
usage: "Remove containers, all build files. Use with `hard` to reset repository to the last commit."
cmd: |
ahoy confirm "All containers and build files will be removed. Proceed?" &&
AHOY_CONFIRM_RESPONSE=y ahoy down && ./scripts/drevops/reset.sh "$@"
AHOY_CONFIRM=y ahoy down && ./scripts/drevops/reset.sh "$@"
fei:
usage: Install front-end assets.
Expand Down Expand Up @@ -178,7 +183,7 @@ commands:
cmd: |
ahoy cli vendor/bin/phpcs
ahoy cli vendor/bin/phpstan
ahoy cli vendor/bin/rector --dry-run
ahoy cli vendor/bin/rector --clear-cache --dry-run
ahoy cli vendor/bin/phpmd . text phpmd.xml
lint-fe:
Expand All @@ -190,7 +195,7 @@ commands:
lint-fix:
usage: Fix lint issues of back-end and front-end code.
cmd: |
ahoy cli vendor/bin/rector process
ahoy cli vendor/bin/rector --clear-cache
ahoy cli vendor/bin/phpcbf
test:
Expand Down Expand Up @@ -252,11 +257,11 @@ commands:
# ----------------------------------------------------------------------------
confirm:
cmd: |
if [ -z "$AHOY_CONFIRM_RESPONSE" ]; then
read -r -p ">> $1 [y/N] " AHOY_CONFIRM_RESPONSE
[ "$AHOY_CONFIRM_RESPONSE" = "y" ] || [ "$AHOY_CONFIRM_RESPONSE" = true ] || ( echo "The operation was canceled." && exit 1 )
if [ -z "$AHOY_CONFIRM" ]; then
read -r -p ">> $1 [y/N] " AHOY_CONFIRM
[ "$AHOY_CONFIRM" = "y" ] || [ "$AHOY_CONFIRM" = true ] || ( echo "The operation was canceled." && exit 1 )
else
echo ">> $1 [y/N] $AHOY_CONFIRM_RESPONSE" \
echo ">> $1 [y/N] $AHOY_CONFIRM" \
&& if [ "${AHOY_CONFIRM_WAIT_SKIP}" != "1" ]; then echo "Waiting for 3 seconds... Press Ctrl+C to cancel."; sleep 3; fi
fi
hide: true
Expand Down
Loading

0 comments on commit d1f0881

Please sign in to comment.