summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher A. Snapp <csnapp@chef.io>2020-06-30 10:37:19 -0600
committerChristopher A. Snapp <csnapp@chef.io>2020-07-13 13:33:47 -0600
commit1638ab05fe4170d248fd99d3c91ac2a7bbda8e37 (patch)
treeb11a3f29748fdb1879a27be9c4df102ab72cbdaf
parenta555ea251f8f94df7093e87402187d3644aabdbe (diff)
downloadchef-1638ab05fe4170d248fd99d3c91ac2a7bbda8e37.tar.gz
Add windows + linux hab tests to verify pipeline
This removes the verify/habitat pipeline by bringing windows and linux verification tests into the default verify pipeline. Signed-off-by: Christopher A. Snapp <csnapp@chef.io>
-rw-r--r--.expeditor/config.yml8
-rw-r--r--.expeditor/verify.habitat.pipeline.yml20
-rw-r--r--.expeditor/verify.pipeline.yml32
-rwxr-xr-xhabitat/tests/test.sh35
-rwxr-xr-xscripts/ci/install-hab.sh20
-rwxr-xr-xscripts/ci/verify-plan.sh37
6 files changed, 124 insertions, 28 deletions
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index 090a31808a..e9d5970882 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -26,14 +26,6 @@ docker_images:
pipelines:
- verify:
public: true
- - verify/habitat:
- description: >
- A temporary pipeline to verify the habitat plans. Performs a local build,
- tests it, then throws it away. Its steps should eventually move into the
- "verify" pipeline (if fast enough) or this pipeline should be removed in
- favor of learning about packaging problems after merge.
- definition: .expeditor/verify.habitat.pipeline.yml
- trigger: default
- habitat/build
- habitat/test:
definition: .expeditor/habitat-test.pipeline.yml
diff --git a/.expeditor/verify.habitat.pipeline.yml b/.expeditor/verify.habitat.pipeline.yml
deleted file mode 100644
index 9c50312db5..0000000000
--- a/.expeditor/verify.habitat.pipeline.yml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-expeditor:
- defaults:
- buildkite:
- timeout_in_minutes: 60
- retry:
- automatic:
- limit: 1
-
-steps:
-
-- label: "Windows plan"
- commands:
- - scripts/ci/verify-plan.ps1
- expeditor:
- executor:
- windows:
- privileged: true
- single-use: true
- shell: ["powershell", "-Command"]
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index 987980aa3a..34a2dee47d 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -579,3 +579,35 @@ steps:
expeditor:
executor:
docker:
+
+- label: ":habicat: Linux plan"
+ commands:
+ - sudo ./scripts/ci/install-hab.sh 'x86_64-linux'
+ - sudo ./scripts/ci/verify-plan.sh
+ timeout_in_minutes: 60
+ expeditor:
+ executor:
+ linux:
+ privileged: true
+ single-use: true
+
+- label: ":habicat: Linux plan (kernel2)"
+ commands:
+ - sudo ./scripts/ci/install-hab.sh 'x86_64-linux-kernel2'
+ - sudo ./scripts/ci/verify-plan.sh
+ timeout_in_minutes: 60
+ expeditor:
+ executor:
+ linux:
+ privileged: true
+ single-use: true
+
+- label: ":habicat: Windows plan"
+ commands:
+ - ./scripts/ci/verify-plan.ps1
+ expeditor:
+ executor:
+ windows:
+ privileged: true
+ single-use: true
+ shell: ["powershell", "-Command"]
diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh
new file mode 100755
index 0000000000..0882313c8e
--- /dev/null
+++ b/habitat/tests/test.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+export CHEF_LICENSE="accept-no-persist"
+export HAB_LICENSE="accept-no-persist"
+
+project_root="$(git rev-parse --show-toplevel)"
+pkg_ident="$1"
+
+# print error message followed by usage and exit
+error () {
+ local message="$1"
+
+ echo -e "\nERROR: ${message}\n" >&2
+
+ exit 1
+}
+
+[[ -n "$pkg_ident" ]] || error 'no hab package identity provided'
+
+package_version=$(awk -F / '{print $3}' <<<"$pkg_ident")
+
+cd "${project_root}"
+
+echo "--- :mag_right: Testing ${pkg_ident} executables"
+[[ "$package_version" = "$(hab pkg exec "${pkg_ident}" chef-client --version | sed 's/.*: //')" ]] || error "chef-client is not the expected version"
+
+for executable in 'chef-client' 'ohai' 'chef-shell' 'chef-apply' 'knife' 'chef-solo'; do
+ echo -en "\t$executable = "
+ hab pkg exec "${pkg_ident}" "${executable}" --version || error "${executable} failed to execute properly"
+done
+
+echo "--- :mag_right: Testing ${pkg_ident} functionality"
+hab pkg exec "${pkg_ident}" rspec -f documentation --tag ~executables spec/functional || error 'failures during rspec tests'
diff --git a/scripts/ci/install-hab.sh b/scripts/ci/install-hab.sh
new file mode 100755
index 0000000000..a59b9ce0f0
--- /dev/null
+++ b/scripts/ci/install-hab.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+hab_target="$1"
+
+# print error message followed by usage and exit
+error () {
+ local message="$1"
+
+ echo -e "\nERROR: ${message}\n" >&2
+
+ exit 1
+}
+
+[[ -n "$hab_target" ]] || error 'no hab target provided'
+
+echo "--- :habicat: Installing latest version of Habitat"
+rm -rf /hab
+curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash -s -- -t "$hab_target"
diff --git a/scripts/ci/verify-plan.sh b/scripts/ci/verify-plan.sh
new file mode 100755
index 0000000000..71aac8d767
--- /dev/null
+++ b/scripts/ci/verify-plan.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+export HAB_ORIGIN='ci'
+export PLAN='chef-infra-client'
+export CHEF_LICENSE="accept-no-persist"
+export HAB_LICENSE="accept-no-persist"
+
+# print error message followed by usage and exit
+error () {
+ local message="$1"
+
+ echo -e "\nERROR: ${message}\n" >&2
+
+ exit 1
+}
+
+echo "--- :8ball: :linux: Verifying $PLAN"
+project_root="$(git rev-parse --show-toplevel)"
+
+echo "--- :key: Generating fake origin key"
+hab origin key generate "$HAB_ORIGIN"
+
+echo "--- :construction: Building $PLAN (solely for verification testing)"
+(
+ cd "$project_root" || error 'cannot change directory to project root'
+ DO_CHECK=true hab pkg build . || error 'unable to build'
+)
+
+source "${project_root}/results/last_build.env" || error 'unable to determine details about this build'
+
+echo "--- :hammer_and_wrench: Installing $pkg_ident"
+hab pkg install "${project_root}/results/$pkg_artifact" || error 'unable to install this build'
+
+echo "--- :mag_right: Testing $PLAN"
+${project_root}/habitat/tests/test.sh "$pkg_ident" || error 'failures during test of executables'