Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1279] Remove DB copy from ahoy provision. #1283

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading