-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove scripts submodule and hard code for now [#163825783]
Co-authored-by: Guillermo Kardolus <[email protected]>
- Loading branch information
Showing
7 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "scripts"] | ||
path = scripts | ||
url = [email protected]:cloudfoundry/cnb-scripts | ||
Submodule scripts
deleted from
0d5d3c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
./scripts/unit.sh && ./scripts/integration.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
PACK_VERSION=latest | ||
|
||
usage() { | ||
echo "Usage: install_tools.sh <version: optional>" | ||
echo "Example: install_tools.sh 0.0.9" | ||
exit 0 | ||
} | ||
|
||
if [ "$#" -gt 1 ]; then | ||
usage | ||
fi | ||
|
||
if [[ "$#" -eq 1 && $1 == "-h" ]]; then | ||
usage | ||
fi | ||
|
||
if [ "$#" -eq 1 ]; then | ||
PACK_VERSION="$1" | ||
fi | ||
|
||
install_pack() { | ||
OS=$(uname -s) | ||
|
||
if [[ $OS == "Darwin" ]]; then | ||
OS="macos" | ||
elif [[ $OS == "Linux" ]]; then | ||
OS="linux" | ||
else | ||
echo "Unsupported operating system" | ||
exit 1 | ||
fi | ||
|
||
if [ "$PACK_VERSION" != "latest" ]; then | ||
echo "Installing pack $PACK_VERSION" | ||
|
||
PACK_ARTIFACT=pack-$PACK_VERSION-$OS.tar.gz | ||
ARTIFACT_URL="https://github.com/buildpack/pack/releases/download/v$PACK_VERSION/$PACK_ARTIFACT" | ||
expand $ARTIFACT_URL | ||
return 0 | ||
fi | ||
|
||
if [[ $OS == "macos" ]]; then | ||
ARTIFACT_URL=$(curl -s https://api.github.com/repos/buildpack/pack/releases/latest | jq --raw-output '.assets[1] | .browser_download_url') | ||
else | ||
ARTIFACT_URL=$(curl -s https://api.github.com/repos/buildpack/pack/releases/latest | jq --raw-output '.assets[0] | .browser_download_url') | ||
fi | ||
|
||
expand $ARTIFACT_URL | ||
} | ||
|
||
expand() { | ||
PACK_ARTIFACT=$(echo $1 | sed "s/.*\///") | ||
PACK_VERSION=v$(echo $PACK_ARTIFACT | sed 's/pack-//' | sed 's/-.*//') | ||
|
||
if [[ ! -f .bin/pack ]]; then | ||
echo "Installing Pack" | ||
elif [[ "$(.bin/pack version | sed 's/VERSION: //' | cut -d ' ' -f 1)" != *$PACK_VERSION* ]]; then | ||
rm .bin/pack | ||
echo "Updating Pack" | ||
else | ||
echo "Version $PACK_VERSION of pack is already installed" | ||
return 0 | ||
fi | ||
wget $ARTIFACT_URL | ||
tar xzvf $PACK_ARTIFACT -C .bin | ||
rm $PACK_ARTIFACT | ||
} | ||
|
||
configure_pack() { | ||
pack add-stack org.cloudfoundry.stacks.cflinuxfs3 \ | ||
--build-image cfbuildpacks/cflinuxfs3-cnb-experimental:build \ | ||
--run-image cfbuildpacks/cflinuxfs3-cnb-experimental:run || echo "Ignoring add stack error" | ||
} | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
mkdir -p .bin | ||
export PATH=$(pwd)/.bin:$PATH | ||
|
||
install_pack | ||
configure_pack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
if [[ ! -d integration ]]; then | ||
echo "No integration tests" | ||
exit 1 | ||
fi | ||
|
||
PACK_VERSION=${PACK_VERSION:-""} | ||
source ./scripts/install_tools.sh $PACK_VERSION | ||
|
||
export CNB_BUILD_IMAGE=${CNB_BUILD_IMAGE:-cfbuildpacks/cflinuxfs3-cnb-experimental:build} | ||
export CNB_RUN_IMAGE=${CNB_RUN_IMAGE:-cfbuildpacks/cflinuxfs3-cnb-experimental:run} | ||
|
||
# Always pull latest images | ||
# Most helpful for local testing consistency with CI (which would already pull the latest) | ||
docker pull $CNB_BUILD_IMAGE | ||
docker pull $CNB_RUN_IMAGE | ||
|
||
set +e | ||
echo "Run Buildpack Runtime Integration Tests" | ||
go test ./integration/... -v -run Integration | ||
exit_code=$? | ||
|
||
if [ "$exit_code" != "0" ]; then | ||
echo -e "\n\033[0;31m** GO Test Failed **\033[0m" | ||
else | ||
echo -e "\n\033[0;32m** GO Test Succeeded **\033[0m" | ||
fi | ||
|
||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
TARGET_OS=${1:-linux} | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
echo "Target OS is $TARGET_OS" | ||
echo -n "Creating buildpack directory..." | ||
bp_dir=/tmp/"${PWD##*/}"_$(openssl rand -hex 12) | ||
mkdir $bp_dir | ||
echo "done" | ||
|
||
echo -n "Copying buildpack.toml..." | ||
cp buildpack.toml $bp_dir/buildpack.toml | ||
echo "done" | ||
|
||
if [ "${BP_REWRITE_HOST:-}" != "" ]; then | ||
sed -i -e "s|^uri = \"https:\/\/buildpacks\.cloudfoundry\.org\(.*\)\"$|uri = \"http://$BP_REWRITE_HOST\1\"|g" "$bp_dir/buildpack.toml" | ||
fi | ||
|
||
for b in $(ls cmd); do | ||
echo -n "Building $b..." | ||
GOOS=$TARGET_OS go build -o $bp_dir/bin/$b ./cmd/$b | ||
echo "done" | ||
done | ||
echo "Buildpack packaged into: $bp_dir" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
echo "Run Buildpack Unit Tests" | ||
|
||
set +e | ||
go test ./... -v -run Unit | ||
exit_code=$? | ||
|
||
if [ "$exit_code" != "0" ]; then | ||
echo -e "\n\033[0;31m** GO Test Failed **\033[0m" | ||
else | ||
echo -e "\n\033[0;32m** GO Test Succeeded **\033[0m" | ||
fi | ||
|
||
exit $exit_code |