2019-10-17 02:57:45 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-11-12 20:47:40 +00:00
|
|
|
set -eo pipefail
|
2019-10-17 02:57:45 +00:00
|
|
|
|
|
|
|
export HAB_ORIGIN='ci'
|
|
|
|
export PLAN='inspec'
|
2019-10-21 21:46:04 +00:00
|
|
|
export CHEF_LICENSE="accept-no-persist"
|
2019-10-21 23:16:37 +00:00
|
|
|
export HAB_LICENSE="accept-no-persist"
|
2020-02-10 23:45:56 +00:00
|
|
|
export project_root="$(git rev-parse --show-toplevel)"
|
|
|
|
export HAB_NONINTERACTIVE=true
|
|
|
|
export HAB_NOCOLORING=true
|
|
|
|
export HAB_STUDIO_SECRET_HAB_NONINTERACTIVE=true
|
2019-10-17 02:57:45 +00:00
|
|
|
|
|
|
|
echo "--- system details"
|
|
|
|
uname -a
|
|
|
|
|
2019-11-12 20:47:40 +00:00
|
|
|
echo "--- Installing Habitat"
|
|
|
|
id -a
|
|
|
|
curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash
|
|
|
|
|
|
|
|
|
2019-10-17 02:57:45 +00:00
|
|
|
echo "--- Generating fake origin key"
|
2019-10-19 00:56:42 +00:00
|
|
|
hab origin key generate $HAB_ORIGIN
|
2019-11-12 20:47:40 +00:00
|
|
|
HAB_CI_KEY=$(realpath /hab/cache/keys/"$HAB_ORIGIN"*.pub)
|
2019-10-22 06:01:19 +00:00
|
|
|
export HAB_CI_KEY
|
2019-11-12 20:47:40 +00:00
|
|
|
if [ -f "$HAB_CI_KEY" ]; then
|
|
|
|
hab origin key import < "$HAB_CI_KEY"
|
|
|
|
else
|
|
|
|
echo "$HAB_CI_KEY not found"
|
|
|
|
ls "$HOME/.hab/cache/keys"
|
|
|
|
ls "$project_root/hab/cache/keys"
|
|
|
|
ls /hab
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-10-17 02:57:45 +00:00
|
|
|
|
|
|
|
echo "--- Building $PLAN"
|
|
|
|
cd "$project_root"
|
|
|
|
DO_CHECK=true hab pkg build .
|
|
|
|
|
2019-10-21 20:20:48 +00:00
|
|
|
echo "--- Sourcing 'results/last_build.sh'"
|
2019-10-21 20:31:37 +00:00
|
|
|
if [ -f ./results/last_build.env ]; then
|
2019-11-12 20:47:40 +00:00
|
|
|
cat ./results/last_build.env
|
2019-10-21 20:31:37 +00:00
|
|
|
. ./results/last_build.env
|
2019-10-22 09:26:52 +00:00
|
|
|
export pkg_artifact
|
2019-10-19 00:56:42 +00:00
|
|
|
fi
|
2019-10-17 02:57:45 +00:00
|
|
|
|
2019-10-22 03:21:26 +00:00
|
|
|
echo "+++ Installing ${pkg_ident:?is undefined}"
|
2019-11-12 20:47:40 +00:00
|
|
|
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
2019-10-22 03:21:26 +00:00
|
|
|
|
2020-07-17 15:00:26 +00:00
|
|
|
echo "--- Removing world readability from /usr/local/bundle"
|
|
|
|
chmod go-w /usr/local/bundle
|
|
|
|
|
2019-10-22 06:27:53 +00:00
|
|
|
echo "+++ Testing $PLAN"
|
2019-11-06 22:31:47 +00:00
|
|
|
|
2019-11-12 20:47:40 +00:00
|
|
|
PATH="$(hab pkg path ci/inspec)/bin:$PATH"
|
2019-11-06 22:31:47 +00:00
|
|
|
export PATH
|
2019-11-12 20:47:40 +00:00
|
|
|
echo "PATH is $PATH"
|
2019-11-06 22:31:47 +00:00
|
|
|
|
2019-10-22 06:27:53 +00:00
|
|
|
pushd "$project_root/test/artifact"
|
2019-11-12 20:47:40 +00:00
|
|
|
rake
|