Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Updates github-config #186

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
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
67 changes: 53 additions & 14 deletions scripts/.util/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ function util::tools::path::export() {
}

function util::tools::jam::install() {
local dir
local dir token
token=""

while [[ "${#}" != 0 ]]; do
case "${1}" in
--directory)
dir="${2}"
shift 2
;;

--token)
token="${2}"
shift 2
;;

*)
util::print::error "unknown argument \"${1}\""
esac
Expand All @@ -49,30 +56,49 @@ function util::tools::jam::install() {
util::tools::path::export "${dir}"

if [[ ! -f "${dir}/jam" ]]; then
local version
local version curl_args

version="$(jq -r .jam "$(dirname "${BASH_SOURCE[0]}")/tools.json")"

curl_args=(
"--fail"
"--silent"
"--location"
"--output" "${dir}/jam"
)

if [[ "${token}" != "" ]]; then
curl_args+=("--header" "Authorization: Token ${token}")
fi


util::print::title "Installing jam ${version}"

curl "https://github.com/paketo-buildpacks/jam/releases/download/${version}/jam-${os}" \
--fail \
--silent \
--location \
--output "${dir}/jam"
"${curl_args[@]}"

chmod +x "${dir}/jam"
else
util::print::title "Using $("${dir}"/jam version)"
fi
}

function util::tools::pack::install() {
local dir
local dir token
token=""

while [[ "${#}" != 0 ]]; do
case "${1}" in
--directory)
dir="${2}"
shift 2
;;

--token)
token="${2}"
shift 2
;;

*)
util::print::error "unknown argument \"${1}\""
esac
Expand All @@ -97,18 +123,31 @@ function util::tools::pack::install() {
esac

if [[ ! -f "${dir}/pack" ]]; then
local version
local version curl_args

version="$(jq -r .pack "$(dirname "${BASH_SOURCE[0]}")/tools.json")"

tmp_location="/tmp/pack.tgz"
curl_args=(
"--fail"
"--silent"
"--location"
"--output" "${tmp_location}"
)

if [[ "${token}" != "" ]]; then
curl_args+=("--header" "Authorization: Token ${token}")
fi

util::print::title "Installing pack ${version}"

curl "https://github.com/buildpacks/pack/releases/download/${version}/pack-${version}-${os}.tgz" \
--fail \
--silent \
--location \
--output /tmp/pack.tgz
tar xzf /tmp/pack.tgz -C "${dir}"
"${curl_args[@]}"

tar xzf "${tmp_location}" -C "${dir}"
chmod +x "${dir}/pack"
rm /tmp/pack.tgz

rm "${tmp_location}"
else
util::print::info "Using pack $("${dir}"/pack version)"
fi
Expand Down
18 changes: 15 additions & 3 deletions scripts/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ source "${PROGDIR}/.util/tools.sh"
source "${PROGDIR}/.util/print.sh"

function main() {
local name
local name token
token=""

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

--token|-t)
token="${2}"
shift 2
;;

"")
# skip if the argument is empty
shift 1
Expand All @@ -46,7 +52,8 @@ function main() {
name="testbuilder"
fi

tools::install
tools::install "${token}"

builder::create "${name}"
image::pull::lifecycle "${name}"
tests::run "${name}"
Expand All @@ -61,12 +68,17 @@ Runs the smoke test suite.
OPTIONS
--help -h prints the command usage
--name <name> -n <name> sets the name of the builder that is built for testing
--token <token> Token used to download assets from GitHub (e.g. jam, pack, etc) (optional)
USAGE
}

function tools::install() {
local token
token="${1}"

util::tools::pack::install \
--directory "${BUILDERDIR}/.bin"
--directory "${BUILDERDIR}/.bin" \
--token "${token}"
}

function builder::create() {
Expand Down