Skip to content

Commit

Permalink
Updating github-config
Browse files Browse the repository at this point in the history
  • Loading branch information
cf-buildpacks-eng authored and ryanmoran committed Jul 13, 2021
1 parent 20e81e0 commit 25e34df
Showing 1 changed file with 59 additions and 28 deletions.
87 changes: 59 additions & 28 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,89 @@ readonly ROOTDIR
source "${ROOTDIR}/scripts/.util/tools.sh"

function main() {
local src
local src stack harness
src="$(find "${ROOTDIR}/src" -mindepth 1 -maxdepth 1 -type d )"
stack="$(jq -r -S .stack "${ROOTDIR}/config.json")"
harness="$(jq -r -S .integration.harness "${ROOTDIR}/config.json")"

IFS=$'\n' read -r -d '' -a matrix < <(
jq -r -S -c .integration.matrix[] "${ROOTDIR}/config.json" \
&& printf "\0"
)

util::tools::ginkgo::install --directory "${ROOTDIR}/.bin"
util::tools::buildpack-packager::install --directory "${ROOTDIR}/.bin"
util::tools::cf::install --directory "${ROOTDIR}/.bin"

local stack
stack="$(jq -r -S .stack "${ROOTDIR}/config.json")"
for row in "${matrix[@]}"; do
local cached parallel
cached="$(jq -r -S .cached <<<"${row}")"
parallel="$(jq -r -S .parallel <<<"${row}")"

cached=true
serial=true
if [[ "${src}" == *python ]]; then
run_specs "uncached" "parallel"
run_specs "uncached" "serial"
echo "Running integration suite (cached: ${cached}, parallel: ${parallel})"

run_specs "cached" "parallel"
run_specs "cached" "serial"
else
run_specs "uncached" "parallel"
run_specs "cached" "parallel"
fi
specs::run "${harness}" "${cached}" "${parallel}"
done
}

function run_specs(){
local cached serial nodes

cached="false"
serial=""
nodes="${GINKGO_NODES:-3}"
function specs::run() {
local harness cached parallel
harness="${1}"
cached="${2}"
parallel="${3}"

echo "Run ${1} Buildpack"
local nodes cached_flag serial_flag
cached_flag="--cached=${cached}"
serial_flag="-serial=true"
nodes=1

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

if [[ "${2}" == "serial" ]]; then
nodes=1
serial="-serial=true"
if [[ "${harness}" == "gotest" ]]; then
specs::gotest::run "${nodes}" "${cached_flag}" "${serial_flag}"
else
specs::ginkgo::run "${nodes}" "${cached_flag}" "${serial_flag}"
fi
}

function specs::gotest::run() {
local nodes cached_flag serial_flag
nodes="${1}"
cached_flag="${2}"
serial_flag="${3}"

CF_STACK="${CF_STACK:-"${stack}"}" \
BUILDPACK_FILE="${UNCACHED_BUILDPACK_FILE:-}" \
GOMAXPROCS="${GOMAXPROCS:-"${nodes}"}" \
go test \
-count=1 \
-timeout=0 \
-mod vendor \
-v \
"${src}/integration" \
"${cached_flag}" \
"${serial_flag}"
}

function specs::ginkgo::run(){
local nodes cached_flag serial_flag
nodes="${1}"
cached_flag="${2}"
serial_flag="${3}"

CF_STACK="${CF_STACK:-"${stack}"}" \
BUILDPACK_FILE="${UNCACHED_BUILDPACK_FILE:-}" \
ginkgo \
-r \
-mod vendor \
--flakeAttempts "${GINKGO_ATTEMPTS:-2}" \
-nodes ${nodes} \
-nodes "${nodes}" \
--slowSpecThreshold 60 \
"${src}/integration" \
-- --cached="${cached}" ${serial}
-- "${cached_flag}" "${serial_flag}"
}

main "${@:-}"

0 comments on commit 25e34df

Please sign in to comment.