Skip to content

Commit c163312

Browse files
committed
Update docker smoketest to reflect new build patterns
Signed-off-by: lelia <lelia@socket.dev>
1 parent 440b44d commit c163312

1 file changed

Lines changed: 51 additions & 24 deletions

File tree

scripts/smoke-test-docker.sh

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
66
IMAGE_TAG="${IMAGE_TAG:-socket-basics:smoke-test}"
77
APP_TESTS_IMAGE_TAG="${APP_TESTS_IMAGE_TAG:-socket-basics-app-tests:smoke-test}"
88
RUN_APP_TESTS=false
9+
SKIP_BUILD=false
10+
CHECK_SET="main"
911
BUILD_PROGRESS="${SMOKE_TEST_BUILD_PROGRESS:-}"
1012

1113
MAIN_TOOLS=(
@@ -24,7 +26,9 @@ APP_TESTS_TOOLS=(
2426
)
2527

2628
usage() {
27-
echo "Usage: $0 [--image-tag TAG] [--app-tests] [--build-progress MODE]"
29+
echo "Usage: $0 [--image-tag TAG] [--app-tests] [--skip-build] [--check-set main|app-tests] [--build-progress MODE]"
30+
echo " --skip-build: skip docker build; verify tools in a pre-built image"
31+
echo " --check-set: which tool set to verify: main (default) or app-tests"
2832
echo " --build-progress: auto|plain|tty (default: auto locally, plain in CI)"
2933
}
3034

@@ -36,6 +40,11 @@ while [[ $# -gt 0 ]]; do
3640
IMAGE_TAG="$2"; shift 2
3741
;;
3842
--app-tests) RUN_APP_TESTS=true; shift ;;
43+
--skip-build) SKIP_BUILD=true; shift ;;
44+
--check-set)
45+
[[ $# -lt 2 ]] && { echo "Error: --check-set requires a value"; exit 1; }
46+
CHECK_SET="$2"; shift 2
47+
;;
3948
--build-progress)
4049
[[ $# -lt 2 ]] && { echo "Error: --build-progress requires a value"; exit 1; }
4150
BUILD_PROGRESS="$2"; shift 2
@@ -44,6 +53,11 @@ while [[ $# -gt 0 ]]; do
4453
esac
4554
done
4655

56+
case "$CHECK_SET" in
57+
main|app-tests) ;;
58+
*) echo "Error: invalid --check-set '$CHECK_SET' (must be 'main' or 'app-tests')"; exit 1 ;;
59+
esac
60+
4761
if [[ -z "$BUILD_PROGRESS" ]]; then
4862
if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then
4963
BUILD_PROGRESS="plain"
@@ -92,29 +106,42 @@ run_checks() {
92106

93107
cd "$REPO_ROOT"
94108

95-
echo "==> Build main image"
96-
echo "Image: $IMAGE_TAG"
97-
echo "Docker build progress mode: $BUILD_PROGRESS"
98-
build_args_for_tag "$IMAGE_TAG"
99-
main_build_start="$(date +%s)"
100-
docker build "${BUILD_ARGS[@]}" .
101-
main_build_end="$(date +%s)"
102-
echo "Main image build completed in $((main_build_end - main_build_start))s"
103-
104-
echo "==> Verify tools in main image"
105-
run_checks "$IMAGE_TAG" "${MAIN_TOOLS[@]}"
106-
107-
if $RUN_APP_TESTS; then
108-
echo "==> Build app_tests image"
109-
echo "Image: $APP_TESTS_IMAGE_TAG"
110-
build_args_for_tag "$APP_TESTS_IMAGE_TAG"
111-
app_build_start="$(date +%s)"
112-
docker build -f app_tests/Dockerfile "${BUILD_ARGS[@]}" .
113-
app_build_end="$(date +%s)"
114-
echo "app_tests image build completed in $((app_build_end - app_build_start))s"
115-
116-
echo "==> Verify tools in app_tests image"
117-
run_checks "$APP_TESTS_IMAGE_TAG" "${APP_TESTS_TOOLS[@]}"
109+
if $SKIP_BUILD; then
110+
# ── Skip build: verify tools in a pre-built image ────────────────────────
111+
echo "==> Verify tools (skip-build mode)"
112+
echo "Image: $IMAGE_TAG"
113+
echo "Check set: $CHECK_SET"
114+
if [[ "$CHECK_SET" == "app-tests" ]]; then
115+
run_checks "$IMAGE_TAG" "${APP_TESTS_TOOLS[@]}"
116+
else
117+
run_checks "$IMAGE_TAG" "${MAIN_TOOLS[@]}"
118+
fi
119+
else
120+
# ── Normal mode: build then verify ────────────────────────────────────────
121+
echo "==> Build main image"
122+
echo "Image: $IMAGE_TAG"
123+
echo "Docker build progress mode: $BUILD_PROGRESS"
124+
build_args_for_tag "$IMAGE_TAG"
125+
main_build_start="$(date +%s)"
126+
docker build "${BUILD_ARGS[@]}" .
127+
main_build_end="$(date +%s)"
128+
echo "Main image build completed in $((main_build_end - main_build_start))s"
129+
130+
echo "==> Verify tools in main image"
131+
run_checks "$IMAGE_TAG" "${MAIN_TOOLS[@]}"
132+
133+
if $RUN_APP_TESTS; then
134+
echo "==> Build app_tests image"
135+
echo "Image: $APP_TESTS_IMAGE_TAG"
136+
build_args_for_tag "$APP_TESTS_IMAGE_TAG"
137+
app_build_start="$(date +%s)"
138+
docker build -f app_tests/Dockerfile "${BUILD_ARGS[@]}" .
139+
app_build_end="$(date +%s)"
140+
echo "app_tests image build completed in $((app_build_end - app_build_start))s"
141+
142+
echo "==> Verify tools in app_tests image"
143+
run_checks "$APP_TESTS_IMAGE_TAG" "${APP_TESTS_TOOLS[@]}"
144+
fi
118145
fi
119146

120147
echo "==> Smoke test passed"

0 commit comments

Comments
 (0)