Skip to content

Commit 6701f78

Browse files
committed
use the same scripts layout as the other buildpacks are using.
1 parent fd40ea5 commit 6701f78

4 files changed

Lines changed: 77 additions & 98 deletions

File tree

config.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
2-
"language": "java",
2+
"stack": "cflinuxfs4",
33
"oses": [
44
"linux"
55
],
6-
"scripts": {
7-
"build": "./scripts/build.sh",
8-
"unit": "./scripts/unit.sh",
9-
"integration": "./scripts/integration.sh",
10-
"brats": "./scripts/brats.sh",
11-
"package": "./scripts/package.sh"
6+
"integration": {
7+
"harness": "switchblade",
8+
"matrix": [
9+
{
10+
"cached": false,
11+
"parallel": true
12+
},
13+
{
14+
"cached": true,
15+
"parallel": true
16+
}
17+
]
1218
}
13-
}
19+
}

scripts/build.sh

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
#!/usr/bin/env bash
2-
set -euo pipefail
32

4-
# Add GOPATH bin to PATH
5-
export PATH="${PATH}:${HOME}/go/bin"
3+
set -e
4+
set -u
5+
set -o pipefail
66

7-
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
8-
source ./scripts/install_tools.sh
7+
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8+
readonly ROOTDIR
99

10-
ROOTDIR="$(pwd)"
10+
# shellcheck source=SCRIPTDIR/.util/tools.sh
11+
source "${ROOTDIR}/scripts/.util/tools.sh"
1112

12-
# Find all CLI packages
13-
IFS=" " read -r -a binaries <<< "$(find "${ROOTDIR}/src/java" -name cli -type d -print0 | xargs -0)"
13+
function main() {
14+
util::tools::jq::install --directory "${ROOTDIR}/.bin"
1415

15-
# Read supported OSes from config.json
16-
if [[ -f "${ROOTDIR}/config.json" ]]; then
17-
IFS=" " read -r -a oses <<< "$(jq -r -S '.oses[]' "${ROOTDIR}/config.json" | xargs)"
18-
else
19-
# Default to linux if config.json doesn't exist yet
20-
oses=("linux")
21-
fi
16+
IFS=" " read -r -a oses <<< "$(jq -r -S '.oses[]' "${ROOTDIR}/config.json" | xargs)"
17+
18+
mapfile -t binaries < <(find "${ROOTDIR}/src" -mindepth 2 -name cli -type d)
2219

23-
# Build for each OS
24-
for os in "${oses[@]}"; do
20+
for os in "${oses[@]}"; do
2521
for path in "${binaries[@]}"; do
26-
name="$(basename "$(dirname "${path}")")"
27-
output="${ROOTDIR}/bin/${name}"
28-
29-
if [[ "${os}" == "windows" ]]; then
30-
output="${output}.exe"
31-
fi
32-
33-
# Remove existing file (could be bash wrapper or old binary)
34-
rm -f "${output}"
35-
36-
echo "-----> Building ${name} for ${os}"
37-
CGO_ENABLED=0 GOOS="${os}" go build \
38-
-mod vendor \
39-
-ldflags="-s -w" \
40-
-o "${output}" \
22+
local name output
23+
name="$(basename "$(dirname "${path}")")"
24+
output="${ROOTDIR}/bin/${name}"
25+
26+
if [[ "${os}" == "windows" ]]; then
27+
output="${output}.exe"
28+
fi
29+
30+
CGO_ENABLED=0 \
31+
GOOS="${os}" \
32+
go build \
33+
-mod vendor \
34+
-ldflags="-s -w" \
35+
-o "${output}" \
4136
"${path}"
4237
done
43-
done
38+
done
39+
}
4440

45-
echo "-----> Build complete"
41+
main "${@:-}"

scripts/install_tools.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

scripts/integration.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set -euo pipefail
55
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
66
readonly ROOTDIR
77

8+
# shellcheck source=SCRIPTDIR/.util/print.sh
9+
source "${ROOTDIR}/scripts/.util/print.sh"
10+
11+
# shellcheck source=SCRIPTDIR/.util/tools.sh
12+
source "${ROOTDIR}/scripts/.util/tools.sh"
13+
814
function usage() {
915
cat <<-USAGE
1016
integration.sh --github-token <token> [OPTIONS]
@@ -34,7 +40,7 @@ USAGE
3440

3541
function main() {
3642
local src stack platform token cached parallel keep_failed
37-
src="${ROOTDIR}/src/integration"
43+
src="${ROOTDIR}/src/java/integration"
3844
stack="${CF_STACK:-cflinuxfs4}"
3945
platform="cf"
4046
cached="false"
@@ -99,7 +105,6 @@ function main() {
99105
echo "Cached: ${cached}"
100106
echo "Parallel: ${parallel}"
101107
echo "Keep Failed: ${keep_failed}"
102-
echo "Buildpack: ${BUILDPACK_FILE}"
103108
echo ""
104109

105110
specs::run "${cached}" "${parallel}" "${stack}" "${platform}" "${token}" "${keep_failed}"
@@ -151,4 +156,30 @@ function specs::run() {
151156
${keep_failed_flag}
152157
}
153158

159+
function buildpack::package() {
160+
local version cached stack
161+
version="${1}"
162+
cached="${2}"
163+
stack="${3}"
164+
165+
local name cached_flag
166+
name="buildpack-${stack}-v${version}-uncached.zip"
167+
cached_flag=""
168+
if [[ "${cached}" == "true" ]]; then
169+
cached_flag="--cached"
170+
name="buildpack-${stack}-v${version}-cached.zip"
171+
fi
172+
173+
local output
174+
output="$(mktemp -d)/${name}"
175+
176+
CF_STACK="${stack}" bash "${ROOTDIR}/scripts/package.sh" \
177+
--version "${version}" \
178+
--output "${output}" \
179+
--stack "${stack}" \
180+
${cached_flag} > /dev/null
181+
182+
printf "%s" "${output}"
183+
}
184+
154185
main "${@:-}"

0 commit comments

Comments
 (0)