Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ function usage() {
integration.sh --github-token <token> [OPTIONS]
Runs the integration tests.
OPTIONS
--help -h prints the command usage
--github-token <token> GitHub token to use when making API requests
--platform <cf|docker> Switchblade platform to execute the tests against
--keep-failed-containers Preserve failed test containers for debugging (default: false)
--help -h prints the command usage
--github-token <token> GitHub token to use when making API requests
--platform <cf|docker> Switchblade platform to execute the tests against
USAGE
}

function main() {
local src stack platform token cached parallel keep_failed
local src stack platform token cached parallel
src="$(find "${ROOTDIR}/src" -mindepth 1 -maxdepth 1 -type d )"
stack="${CF_STACK:-$(jq -r -S .stack "${ROOTDIR}/config.json")}"
platform="cf"
keep_failed="false"

while [[ "${#}" != 0 ]]; do
case "${1}" in
Expand All @@ -54,11 +52,6 @@ function main() {
shift 2
;;

--keep-failed-containers)
keep_failed="true"
shift 1
;;

--help|-h)
shift 1
usage
Expand Down Expand Up @@ -101,37 +94,31 @@ function main() {

echo "Running integration suite (cached: ${cached}, parallel: ${parallel})"

specs::run "${cached}" "${parallel}" "${stack}" "${platform}" "${token:-}" "${keep_failed}"
specs::run "${cached}" "${parallel}" "${stack}" "${platform}" "${token:-}"
done
}

function specs::run() {
local cached parallel stack platform token keep_failed
local cached parallel stack platform token
cached="${1}"
parallel="${2}"
stack="${3}"
platform="${4}"
token="${5}"
keep_failed="${6}"

local nodes cached_flag serial_flag platform_flag stack_flag token_flag keep_failed_flag
local nodes cached_flag serial_flag platform_flag stack_flag token_flag
cached_flag="--cached=${cached}"
serial_flag="--serial=true"
platform_flag="--platform=${platform}"
stack_flag="--stack=${stack}"
token_flag="--github-token=${token}"
keep_failed_flag=""
nodes=1

if [[ "${parallel}" == "true" ]]; then
nodes=3
serial_flag=""
fi

if [[ "${keep_failed}" == "true" ]]; then
keep_failed_flag="--keep-failed-containers"
fi

local buildpack_file
buildpack_file="$(buildpack::package "1.2.3" "${cached}" "${stack}")"

Expand All @@ -144,12 +131,11 @@ function specs::run() {
-mod vendor \
-v \
"${src}/integration" \
${cached_flag} \
${platform_flag} \
${token_flag} \
${stack_flag} \
${serial_flag} \
${keep_failed_flag}
"${cached_flag}" \
"${platform_flag}" \
"${token_flag}" \
"${stack_flag}" \
"${serial_flag}"
}

function buildpack::package() {
Expand Down
Loading