From 13a1c30ba68ab7335743087c5755a91b302765e9 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 6 Nov 2019 14:31:47 -0800 Subject: [PATCH] Corret build scripts correct path to hab artifact Rather than throwing, lets try to install the version Make sure hab is in the path we use -b on windows. lets be consistent export project_root too picardface fix regex execute rake _through_ habitat make test vrooom test presence of inspec strip out clixml bs ... no which on bk. full path to which export PATH test exist on linux/windows Signed-off-by: Miah Johnson --- .../buildkite/artifact.habitat.install.sh | 2 +- .expeditor/buildkite/artifact.habitat.test.ps1 | 6 +++--- .expeditor/buildkite/artifact.habitat.test.sh | 7 ++++++- test/artifact/inspec_detect_test.rb | 18 +++++++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.expeditor/buildkite/artifact.habitat.install.sh b/.expeditor/buildkite/artifact.habitat.install.sh index 104d16ecc..92ca5ce46 100755 --- a/.expeditor/buildkite/artifact.habitat.install.sh +++ b/.expeditor/buildkite/artifact.habitat.install.sh @@ -3,4 +3,4 @@ set -ueo pipefail hab origin key import < "$HAB_CI_KEY" -hab pkg install --binlink "./results/${pkg_artifact:?is undefined}" +hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}" diff --git a/.expeditor/buildkite/artifact.habitat.test.ps1 b/.expeditor/buildkite/artifact.habitat.test.ps1 index b2f3aa7c4..47e4fc7f2 100644 --- a/.expeditor/buildkite/artifact.habitat.test.ps1 +++ b/.expeditor/buildkite/artifact.habitat.test.ps1 @@ -15,13 +15,11 @@ Write-Host "--- Installing the version of Habitat required" $hab_version = (hab --version) $hab_minor_version = $hab_version.split('.')[1] if ( -not $? -Or $hab_minor_version -lt 85 ) { - Write-Host "I'm being built with $hab_version. I need at least Hab 0.85.0, because I use the -IsPath option for setting/pushing paths in SetupEnvironment." -throw "unable to build: required minimum version of Habitat not installed" + Install-Habitat --version 0.85.0.20190916 } else { Write-Host ":habicat: I think I have the version I need to build." } -Install-Habitat --version 0.85.0.20190916 Write-Host "--- Generating fake origin key" hab origin key generate $env:HAB_ORIGIN @@ -41,6 +39,8 @@ hab pkg install -b $project_root/results/$pkg_artifact if (-not $?) { throw "unable to install this build" } Write-Host "+++ Testing $Plan" + +$env:PATH = "C:\hab\bin;$env:PATH" Push-Location $project_root/test/artifact rake if (-not $?) { throw "rake failed" } diff --git a/.expeditor/buildkite/artifact.habitat.test.sh b/.expeditor/buildkite/artifact.habitat.test.sh index 8138f2d44..c4b9eff0a 100755 --- a/.expeditor/buildkite/artifact.habitat.test.sh +++ b/.expeditor/buildkite/artifact.habitat.test.sh @@ -25,6 +25,7 @@ echo "--- Sourcing 'results/last_build.sh'" if [ -f ./results/last_build.env ]; then . ./results/last_build.env export pkg_artifact + export project_root fi echo "+++ Installing ${pkg_ident:?is undefined}" @@ -35,6 +36,10 @@ HSI="$project_root"/.expeditor/buildkite/artifact.habitat.install.sh sudo -E "$HSI" echo "+++ Testing $PLAN" + +PATH="/hab/bin:$PATH" +export PATH + pushd "$project_root/test/artifact" -rake +hab pkg exec core/ruby rake popd diff --git a/test/artifact/inspec_detect_test.rb b/test/artifact/inspec_detect_test.rb index 61f066b25..820ccff61 100644 --- a/test/artifact/inspec_detect_test.rb +++ b/test/artifact/inspec_detect_test.rb @@ -1,12 +1,24 @@ require "minitest/autorun" class TestArtifactDetect < Minitest::Test + def test_inspec_exists_linux + skip if windows? + refute_match(/no inspec/, `/usr/bin/which inspec`) + end + + def test_inspec_exists_windows + skip unless windows? + assert_match(/inspec.bat/, `Get-Command inspec`) + end + def test_detect + exit = nil out, err = capture_subprocess_io do - assert system("inspec detect --no-color") + exit = system("inspec detect --no-color") end - assert_match %r{/Platform Details/}, out - assert_empty err + assert_empty err.sub(/#< CLIXML\n/, "") + assert_match(/Platform Details/, out) + assert exit end end