Skip to content

Commit

Permalink
[#1279] Remove DB copy from ahoy provision. (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Apr 25, 2024
1 parent 305b385 commit 90643b4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
7 changes: 1 addition & 6 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,7 @@ commands:
provision:
usage: Provision a site from the database dump or profile.
cmd: |
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
fi
ahoy cli ./scripts/drevops/provision.sh
cmd: ahoy cli ./scripts/drevops/provision.sh

export-db:
usage: Export database dump or database image (if DREVOPS_DB_DOCKER_IMAGE variable is set).
Expand Down
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ jobs:
- run:
name: Process test logs and artifacts
command: |
mkdir -p "${DREVOPS_CI_TEST_RESULTS}"
mkdir -p "${DREVOPS_CI_ARTIFACTS}"
mkdir -p "${DREVOPS_CI_TEST_RESULTS}" "${DREVOPS_CI_ARTIFACTS}"
if docker compose ps --services --filter "status=running" | grep -q cli && docker compose exec cli test -d /app/.logs; then
docker compose cp cli:/app/.logs/. "${DREVOPS_CI_ARTIFACTS}/"
if docker compose exec -T cli sh -c '[ -d /app/.logs/test_results/ ]'; then
Expand Down
12 changes: 12 additions & 0 deletions .scaffold/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1334,3 +1334,15 @@ download_installer() {

popd >/dev/null || exit 1
}

process_ahoyyml() {
[ "${SCAFFOLD_DEV_VOLUMES_MOUNTED}" = "1" ] && return

# Override the provision command in .ahoy.yml to copy the database file to
# the container for when the volumes are not mounted.
# We are doing this only to replicate developer's workflow and experience
# when they run `ahoy build` locally.
local sed_opts
sed_opts=(-i) && [ "$(uname)" = "Darwin" ] && sed_opts=(-i '')
sed "${sed_opts[@]}" 's|cmd: ahoy cli ./scripts/drevops/provision.sh|cmd: if [ -f .data/db.sql ]; then docker compose exec cli mkdir -p .data; docker compose cp -L .data/db.sql cli:/app/.data/db.sql; fi; ahoy cli \.\/scripts\/drevops\/provision\.sh|g' .ahoy.yml
}
1 change: 1 addition & 0 deletions .scaffold/tests/bats/_helper.deployment.bash
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ install_and_build_site() {

export DREVOPS_PROVISION_POST_OPERATIONS_SKIP=1

process_ahoyyml
ahoy build
sync_to_host
fi
Expand Down
1 change: 1 addition & 0 deletions .scaffold/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ assert_ahoy_build() {
export DOCKER_USER="${TEST_DOCKER_USER?Test Docker user is not set}"
export DOCKER_PASS="${TEST_DOCKER_PASS?Test Docker pass is not set}"

process_ahoyyml
run ahoy build
run sync_to_host

Expand Down
14 changes: 11 additions & 3 deletions .scaffold/tests/bats/workflow.smoke.bats
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ load _helper.workflow.bash

step "Build without a GITHUB_TOKEN token"
unset GITHUB_TOKEN
process_ahoyyml
run ahoy build
assert_failure

step "Build with a GITHUB_TOKEN token"
export GITHUB_TOKEN="${TEST_GITHUB_TOKEN}"
process_ahoyyml
run ahoy build
assert_success
}
Expand All @@ -66,10 +68,16 @@ load _helper.workflow.bash
docker compose exec -T cli composer install --prefer-dist >&3

substep "Provisioning"
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql

# Copy DB into container for the cases when the volumes are not mounted.
# This will not be a case locally.
if [ "${SCAFFOLD_DEV_VOLUMES_MOUNTED}" != "1" ]; then
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
fi
fi

docker compose exec -T cli ./scripts/drevops/provision.sh >&3

sync_to_host
Expand Down

1 comment on commit 90643b4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.