-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·66 lines (55 loc) · 1.64 KB
/
test.sh
File metadata and controls
executable file
·66 lines (55 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# test.sh - Build and test devwork images locally, mirroring CI behaviour
# Usage:
# ./test.sh - Build and test all Node versions (22, 24, lts)
# ./test.sh 24 - Build and test a specific version
# ./test.sh 22 24 - Build and test multiple versions
set -e
VERSIONS="${*:-22 24 lts}"
PASS=0
FAIL=0
# Colours
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() { printf "${GREEN}[✔]${NC} %s\n" "$1"; }
warn() { printf "${YELLOW}[!]${NC} %s\n" "$1"; }
err() { printf "${RED}[✘]${NC} %s\n" "$1"; }
# --- Shellcheck ---
printf "\n${YELLOW}==> Linting shell scripts${NC}\n"
if command -v shellcheck >/dev/null 2>&1; then
shellcheck devwork-versions .profile && log "shellcheck passed" || warn "shellcheck reported issues"
else
warn "shellcheck not installed, skipping lint"
fi
# --- Build & test each version ---
for VERSION in $VERSIONS; do
printf "\n${YELLOW}==> Node.js $VERSION${NC}\n"
TAG="devwork:$VERSION-node"
# Build
printf "Building $TAG...\n"
if docker build --build-arg NODE_VERSION="$VERSION" -t "$TAG" .; then
log "Build succeeded"
else
err "Build failed for Node $VERSION"
FAIL=$((FAIL + 1))
continue
fi
# Test
printf "Testing $TAG...\n"
if docker run --rm "$TAG" devwork-versions; then
log "Tests passed"
PASS=$((PASS + 1))
else
err "Tests failed for Node $VERSION"
FAIL=$((FAIL + 1))
fi
# Size report
SIZE=$(docker images --format "{{.Size}}" "$TAG" | head -1)
log "Image size: $SIZE"
done
# --- Summary ---
printf "\n${YELLOW}==> Summary${NC}\n"
printf "Passed: ${GREEN}$PASS${NC} Failed: ${RED}$FAIL${NC}\n\n"
[ "$FAIL" -eq 0 ]