forked from nodejs/docker-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-build.sh
executable file
·73 lines (53 loc) · 1.89 KB
/
test-build.sh
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
67
68
69
70
71
72
73
#!/usr/bin/env bash
#
# Run a test build for all images.
set -uo pipefail
. functions.sh
cd "$(cd "${0%/*}" && pwd -P)" || exit;
IFS=' ' read -ra versions <<< "$(get_versions . "$@")"
if [ ${#versions[@]} -eq 0 ]; then
fatal "No valid versions found!"
fi
for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue
tag=$(get_tag "$version")
full_version=$(get_full_version "$version")
info "Building $tag..."
if ! docker build -t node:"$tag" "$version"; then
fatal "Build of $tag failed!"
fi
info "Build of $tag succeeded."
OUTPUT=$(docker run --rm -it node:"$tag" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$full_version" ]; then
fatal "Test of $tag for node failed!"
fi
info "Test of $tag for node succeeded."
if ! docker run --rm -i node:"$tag" npm --version; then
fatal "Test of $tag for npm failed!"
fi
info "Test of $tag for npm succeeded."
if ! docker run --rm -i node:"$tag" yarn --version; then
fatal "Test of $tag for yarn failed!"
fi
info "Test of $tag for yarn succeeded."
# Get supported variants according to the target architecture.
# See details in function.sh
variants=$(get_variants "$(dirname "$version")")
for variant in $variants; do
# Skip non-docker directories
[ -f "$version/$variant/Dockerfile" ] || continue
info "Building $tag-$variant variant..."
if ! docker build -t node:"$tag-$variant" "$version/$variant"; then
fatal "Build of $tag-$variant failed!"
fi
info "Build of $tag-$variant succeeded."
OUTPUT=$(docker run --rm -it node:"$tag-$variant" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$full_version" ]; then
fatal "Test of $tag-$variant failed!"
fi
info "Test of $tag-$variant succeeded."
done
done
info "All builds successful!"
exit 0