Skip to content

Commit

Permalink
refactor: moving cleanup in to test.sh in order not to block github c…
Browse files Browse the repository at this point in the history
…onfig updates on tools.sh
  • Loading branch information
pacostas authored and mhdawson committed Feb 26, 2024
1 parent ad96fe1 commit f91fcbf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
26 changes: 0 additions & 26 deletions scripts/.util/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,3 @@ function util::tools::tests::checkfocus() {
fi
rm "${testout}"
}

function util::tools::setup_local_registry() {

registry_port="${1}"

local registry_container_id
if [[ "$(curl -s -o /dev/null -w "%{http_code}" localhost:$registry_port/v2/)" == "200" ]]; then
registry_container_id=""
else
registry_container_id=$(docker run -d -p "${registry_port}:5000" --restart=always registry:2)
fi

echo $registry_container_id
}

function util::tools::cleanup_local_registry() {
local registry_container_id
registry_container_id="${1}"

util::print::title "inside cleanup $registry_container_id"

if [[ -n "${registry_container_id}" ]]; then
docker stop $registry_container_id
docker rm $registry_container_id
fi
}
33 changes: 32 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function main() {

pack config experimental true

tests::run
tests::run "${registry_container_id}"

util::tools::cleanup_local_registry "${registry_container_id}"
}
Expand Down Expand Up @@ -156,17 +156,48 @@ function tools::install() {
}

function tests::run() {
local registry_container_id
registry_container_id="${1}"

util::print::title "Run Stack Acceptance Tests"

export CGO_ENABLED=0
testout=$(mktemp)
pushd "${STACK_DIR}" > /dev/null
if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./... -v -run Acceptance | tee "${testout}"; then
util::tools::tests::checkfocus "${testout}"
util::tools::cleanup_local_registry "${registry_container_id}"
util::print::success "** GO Test Succeeded **"
else
util::tools::cleanup_local_registry "${registry_container_id}"
util::print::error "** GO Test Failed **"
fi
popd > /dev/null
}


function util::tools::setup_local_registry() {

registry_port="${1}"

local registry_container_id
if [[ "$(curl -s -o /dev/null -w "%{http_code}" localhost:$registry_port/v2/)" == "200" ]]; then
registry_container_id=""
else
registry_container_id=$(docker run -d -p "${registry_port}:5000" --restart=always registry:2)
fi

echo $registry_container_id
}

function util::tools::cleanup_local_registry() {
local registry_container_id
registry_container_id="${1}"

if [[ -n "${registry_container_id}" ]]; then
docker stop $registry_container_id
docker rm $registry_container_id
fi
}

main "${@:-}"

0 comments on commit f91fcbf

Please sign in to comment.