Skip to content

Commit b3416b3

Browse files
committed
Updating the check size test logic for universal image
1 parent 06db0f0 commit b3416b3

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.github/actions/smoke-test/build.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ export DOCKER_BUILDKIT=1
77
echo "(*) Installing @devcontainer/cli"
88
npm install -g @devcontainers/cli
99

10-
echo "(*) Building image - ${IMAGE}"
1110
id_label="test-container=${IMAGE}"
12-
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
11+
id_image="universal-test-image"
12+
if [ $IMAGE == "universal" ]; then
13+
echo "(*) Building image - ${IMAGE}"
14+
devcontainer build --image-name ${id_image} --workspace-folder "src/${IMAGE}/"
15+
echo "(*) Starting container - ${IMAGE}"
16+
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
17+
else
18+
echo "(*) Building image - ${IMAGE}"
19+
devcontainer up --id-label ${id_label} --workspace-folder "src/${IMAGE}/"
20+
fi

.github/actions/smoke-test/check-image-size.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ install_bc() {
3232
check_image_size() {
3333
IMAGE="$1"
3434
THRESHOLD_IN_GB="$2"
35-
35+
id_image="$3"
3636
# call install_bc
3737
install_bc
3838

3939
if [ $IMAGE == "universal" ]; then
4040
#Read the image id of the original image, not the modified image with uid and gid
41-
IMAGE_ID=$(docker images | grep -v "uid" | sed '1d' | awk '{print $3}')
41+
IMAGE_ID=$(docker images -q --filter=reference="$id_image")
4242
else
4343
CONTAINER_ID=$(docker ps -q --filter "label=test-container=$IMAGE")
4444
# Find the image ID of the container

.github/actions/smoke-test/test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ set -e
1010
# Run actual test
1111
echo "(*) Running test..."
1212
id_label="test-container=${IMAGE}"
13+
id_image="universal-test-image"
1314
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'
1415

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

1920
if [ $IMAGE == "universal" ]; then
20-
check_image_size $IMAGE $THRESHOLD_IN_GB
21+
check_image_size $IMAGE $THRESHOLD_IN_GB $id_image
2122
fi
2223

2324
# Clean up

0 commit comments

Comments
 (0)