forked from paketo-buildpacks/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.sh
More file actions
executable file
·110 lines (86 loc) · 2.52 KB
/
integration.sh
File metadata and controls
executable file
·110 lines (86 loc) · 2.52 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
set -eu
set -o pipefail
readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly BUILDPACKDIR="$(cd "${PROGDIR}/.." && pwd)"
# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${PROGDIR}/.util/tools.sh"
# shellcheck source=SCRIPTDIR/.util/print.sh
source "${PROGDIR}/.util/print.sh"
function main() {
while [[ "${#}" != 0 ]]; do
case "${1}" in
--help|-h)
shift 1
usage
exit 0
;;
"")
# skip if the argument is empty
shift 1
;;
*)
util::print::error "unknown argument \"${1}\""
esac
done
if [[ ! -d "${BUILDPACKDIR}/integration" ]]; then
util::print::warn "** WARNING No Integration tests **"
fi
tools::install
images::pull
tests::run
}
function usage() {
cat <<-USAGE
integration.sh [OPTIONS]
Runs the integration test suite.
OPTIONS
--help -h prints the command usage
USAGE
}
function tools::install() {
util::tools::pack::install \
--directory "${BUILDPACKDIR}/.bin"
util::tools::jam::install \
--directory "${BUILDPACKDIR}/.bin"
}
function images::pull() {
local builder
builder=""
if [[ -f "${BUILDPACKDIR}/integration.json" ]]; then
builder="$(jq -r .builder "${BUILDPACKDIR}/integration.json")"
fi
if [[ "${builder}" == "null" || -z "${builder}" ]]; then
builder="index.docker.io/paketobuildpacks/builder:buildpackless-base"
fi
util::print::title "Pulling builder image..."
docker pull "${builder}"
util::print::title "Setting default pack builder image..."
pack config default-builder "${builder}"
local run_image lifecycle_image
run_image="$(
pack inspect-builder "${builder}" --output json \
| jq -r '.remote_info.run_images[0].name'
)"
lifecycle_image="index.docker.io/buildpacksio/lifecycle:$(
pack inspect-builder "${builder}" --output json \
| jq -r '.remote_info.lifecycle.version'
)"
util::print::title "Pulling run image..."
docker pull "${run_image}"
util::print::title "Pulling lifecycle image..."
docker pull "${lifecycle_image}"
}
function tests::run() {
util::print::title "Run Buildpack Runtime Integration Tests"
testout=$(mktemp)
pushd "${BUILDPACKDIR}" > /dev/null
if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./integration/... -v -run Integration | tee "${testout}"; then
util::tools::tests::checkfocus "${testout}"
util::print::success "** GO Test Succeeded **"
else
util::print::error "** GO Test Failed **"
fi
popd > /dev/null
}
main "${@:-}"