Skip to content

Commit

Permalink
Updating the check size test logic for universal image
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaniska244 committed Feb 21, 2025
1 parent 06db0f0 commit b3416b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions .github/actions/smoke-test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export DOCKER_BUILDKIT=1
echo "(*) Installing @devcontainer/cli"
npm install -g @devcontainers/cli

echo "(*) Building image - ${IMAGE}"
id_label="test-container=${IMAGE}"
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
id_image="universal-test-image"
if [ $IMAGE == "universal" ]; then
echo "(*) Building image - ${IMAGE}"
devcontainer build --image-name ${id_image} --workspace-folder "src/${IMAGE}/"
echo "(*) Starting container - ${IMAGE}"
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
else
echo "(*) Building image - ${IMAGE}"
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
fi
4 changes: 2 additions & 2 deletions .github/actions/smoke-test/check-image-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ install_bc() {
check_image_size() {
IMAGE="$1"
THRESHOLD_IN_GB="$2"

id_image="$3"
# call install_bc
install_bc

if [ $IMAGE == "universal" ]; then
#Read the image id of the original image, not the modified image with uid and gid
IMAGE_ID=$(docker images | grep -v "uid" | sed '1d' | awk '{print $3}')
IMAGE_ID=$(docker images -q --filter=reference="$id_image")
else
CONTAINER_ID=$(docker ps -q --filter "label=test-container=$IMAGE")
# Find the image ID of the container
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/smoke-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ set -e
# Run actual test
echo "(*) Running test..."
id_label="test-container=${IMAGE}"
id_image="universal-test-image"
devcontainer exec --workspace-folder $(pwd)/src/$IMAGE --id-label ${id_label} /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi'

echo "(*) Docker image details..."
docker images
# Checking size of universal image

if [ $IMAGE == "universal" ]; then
check_image_size $IMAGE $THRESHOLD_IN_GB
check_image_size $IMAGE $THRESHOLD_IN_GB $id_image
fi

# Clean up
Expand Down

0 comments on commit b3416b3

Please sign in to comment.