Skip to content

Commit

Permalink
Update smoke.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Naveen-is-here authored Jul 24, 2024
1 parent 36aeee7 commit d24fd54
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion scripts/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -o pipefail

readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly BUILDERDIR="$(cd "${PROGDIR}/.." && pwd)"
readonly OPTIONS_JSON="${BUILDERDIR}/scripts/options.json"

# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${PROGDIR}/.util/tools.sh"
Expand All @@ -14,7 +15,10 @@ source "${PROGDIR}/.util/print.sh"

function main() {
local name token
local registryPort registryPid localRegistry setupLocalRegistry pushBuilderToLocalRegistry
token=""
registryPid=""
setupLocalRegistry=""

while [[ "${#}" != 0 ]]; do
case "${1}" in
Expand Down Expand Up @@ -54,9 +58,39 @@ function main() {

tools::install "${token}"

if [[ -f $OPTIONS_JSON ]]; then
setupLocalRegistry="$(jq -r '.setup_local_registry //false' $OPTIONS_JSON)"
fi

if [[ "${setupLocalRegistry}" == "true" ]]; then
registryPort=$(get::random::port)
registryPid=$(local::registry::start $registryPort)
localRegistry="127.0.0.1:$registryPort"
export REGISTRY_URL="${localRegistry}"
fi

if [ -f $OPTIONS_JSON ]; then
pushBuilderToLocalRegistry="$(jq -r '.push_builder_to_local_registry //false' $OPTIONS_JSON)"
else
pushBuilderToLocalRegistry="false"
fi

builder::create "${name}"
image::pull::lifecycle "${name}"
tests::run "${name}"

if [ "${pushBuilderToLocalRegistry}" == "true" ]; then
docker tag "$name" "$REGISTRY_URL/$name"
docker push "$REGISTRY_URL/$name"
imageName="$REGISTRY_URL/$name"
else
imageName="$name"
fi

tests::run $imageName

if [[ "${setupLocalRegistry}" == "true" ]]; then
kill $registryPid
fi
}

function usage() {
Expand All @@ -76,6 +110,10 @@ function tools::install() {
local token
token="${1}"

util::tools::crane::install \
--directory "${BUILDERDIR}/.bin" \
--token "${token}"

util::tools::pack::install \
--directory "${BUILDERDIR}/.bin" \
--token "${token}"
Expand Down

0 comments on commit d24fd54

Please sign in to comment.