File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # https://github.com/docker-library/official-images/blob/3bc6a70175d4e1da2080b86415e6f3c8eb2c6af3/test/config.sh
4+
5+ imageTests[golang]+='
6+ go-dist-test
7+ '
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -Eeuo pipefail
3+
4+ image=" $1 "
5+
6+ args=(
7+ # respond better to SIGINT/SIGTERM
8+ --init --interactive
9+
10+ # Go has some tests that are very picky about DNS resolution
11+ --dns 8.8.8.8
12+ --dns 8.8.4.4
13+ )
14+
15+ cmd=(
16+ # the "dist" tool doesn't query Go for GOROOT and expects it to be set explicitly
17+ sh -xec ' GOROOT="$(go env GOROOT)" && export GOROOT && exec "$@"' --
18+
19+ go tool dist test
20+ )
21+
22+ case " $image " in
23+ * alpine* )
24+ # Alpine needs a few extra dependencies installed for the tests to run/pass
25+ # gcc/libc-dev: cgo-related tests
26+ # iproute2-minimal: BusyBox's "ip" isn't enough for tests that need to shell out to "ip" for various env setup
27+ cmd=( sh -xec ' apk add --no-cache gcc libc-dev iproute2-minimal && exec "$@"' -- " ${cmd[@]} " )
28+ # for some reason, running the tests on Alpine needs NET_ADMIN (but not on Debian 🤔)
29+ args+=( --cap-add NET_ADMIN )
30+ ;;
31+
32+ * windows* | * nanoserver* )
33+ echo >&2 " note: tests do not run successfully in a Windows container yet (https://github.com/docker-library/golang/issues/552#issuecomment-2658011431)"
34+ exit 0
35+ ;;
36+ esac
37+
38+ if [ -t 0 ] && [ -t 1 ]; then
39+ # let Ctrl+C DTRT if we're at a TTY
40+ args+=( --tty )
41+ fi
42+
43+ docker run --rm " ${args[@]} " " $image " " ${cmd[@]} "
You can’t perform that action at this time.
0 commit comments