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

use variables to set container registry and repository in scripts #968

Merged
merged 4 commits into from
Aug 29, 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
3 changes: 2 additions & 1 deletion development/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -xeu

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INTEGRATION_TEST_DIR="$SCRIPT_DIR/../integration-tests/"
CONTAINER_REPOSITORY="aelsabbahy"

LABEL_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ')
LABEL_URL="https://github.com/goss-org/goss"
Expand All @@ -23,5 +24,5 @@ for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
--label "org.opencontainers.image.url=$LABEL_URL" \
--label "org.opencontainers.image.version=manual" \
--label "rocks.goss.dockerfile-md5"=$md5 \
-t "aelsabbahy/goss_${os}:latest" - < "$docker_file"
-t "$CONTAINER_REPOSITORY/goss_${os}:latest" - < "$docker_file"
done
3 changes: 2 additions & 1 deletion development/push_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
set -xeu

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
images=$(docker images | grep '^aelsabbahy/goss_.*latest' | awk '$0=$1')
CONTAINER_REPOSITORY="aelsabbahy"
images=$(docker images | grep "^$CONTAINER_REPOSITORY/goss_.*latest" | awk '$0=$1')

# Use md5sum to determine if CI needs to do a docker build
pushd "$SCRIPT_DIR/../integration-tests";
Expand Down
9 changes: 5 additions & 4 deletions integration-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ os="${1:?"Need OS as 1st arg. e.g. alpine arch centos7 rockylinux9 trusty wheezy
arch="${2:?"Need arch as 2nd arg. e.g. amd64 386"}"

vars_inline="{inline: bar, overwrite: bar}"
container_repository="aelsabbahy"

# setup places us inside repo-root; this preserves current behaviour with least change.
cd integration-tests

cp "../release/goss-linux-$arch" "goss/$os/"
# Run build if Dockerfile has changed but hasn't been pushed to dockerhub
if ! md5sum -c "Dockerfile_${os}.md5"; then
docker build -t "aelsabbahy/goss_${os}:latest" - < "Dockerfile_$os"
docker build -t "$container_repository/goss_${os}:latest" - < "Dockerfile_$os"
# Pull if image doesn't exist locally
elif ! docker images | grep "aelsabbahy/goss_$os";then
docker pull "aelsabbahy/goss_$os"
elif ! docker images | grep "$container_repository/goss_$os";then
docker pull "$container_repository/goss_$os"
fi

container_name="goss_int_test_${os}_${arch}"
Expand All @@ -37,7 +38,7 @@ network=goss-test
docker network create --driver bridge --subnet '172.19.0.0/16' $network
docker run -d --name httpbin --network $network kennethreitz/httpbin
opts=(--env OS=$os --cap-add SYS_ADMIN -v "$PWD/goss:/goss" -d --name "$container_name" --security-opt seccomp:unconfined --security-opt label:disable --privileged)
id=$(docker run "${opts[@]}" --network $network "aelsabbahy/goss_$os" /sbin/init)
id=$(docker run "${opts[@]}" --network $network "$container_repository/goss_$os" /sbin/init)
ip=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$id")
trap "rv=\$?; docker rm -vf $id;docker rm -vf httpbin;docker network rm $network; exit \$rv" INT TERM EXIT
# Give httpd time to start up, adding 1 second to see if it helps with intermittent CI failures
Expand Down