mirror of
https://github.com/inspec/inspec
synced 2024-11-22 12:43:07 +00:00
Fixup tests
Signed-off-by: Miah Johnson <miah@chia-pet.org>
This commit is contained in:
parent
6510679e6a
commit
45070c15c0
17 changed files with 80 additions and 63 deletions
|
@ -1,4 +1,9 @@
|
|||
---
|
||||
expeditor:
|
||||
defaults:
|
||||
buildkite:
|
||||
timeout_in_minutes: 30
|
||||
|
||||
steps:
|
||||
|
||||
- label: ":linux: Validate Habitat Builds of Chef InSpec"
|
||||
|
@ -6,7 +11,8 @@ steps:
|
|||
- .expeditor/buildkite/artifact.habitat.test.sh
|
||||
expeditor:
|
||||
executor:
|
||||
linux:
|
||||
docker:
|
||||
image: ruby:2.6
|
||||
privileged: true
|
||||
|
||||
- label: ":windows: Validate Habitat Builds of Chef InSpec"
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ueo pipefail
|
||||
|
||||
hab origin key import < "$HAB_CI_KEY"
|
||||
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env powershell
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$env:HAB_ORIGIN = 'ci'
|
||||
$env:CHEF_LICENSE = 'accept-no-persist'
|
||||
$env:HAB_LICENSE = 'accept-no-persist'
|
||||
|
@ -29,19 +29,25 @@ $project_root = "$(git rev-parse --show-toplevel)"
|
|||
Set-Location $project_root
|
||||
|
||||
$env:DO_CHECK=$true; hab pkg build .
|
||||
if (-not $?) { throw "unable to build" }
|
||||
|
||||
. $project_root/results/last_build.ps1
|
||||
if (-not $?) { throw "unable to determine details about this build" }
|
||||
|
||||
Write-Host "--- Installing $pkg_ident/$pkg_artifact"
|
||||
hab pkg install -b $project_root/results/$pkg_artifact
|
||||
if (-not $?) { throw "unable to install this build" }
|
||||
|
||||
Write-Host "--- Downloading Ruby + DevKit"
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
(New-Object System.Net.WebClient).DownloadFile('https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-devkit-2.6.5-1-x64.exe', 'c:\\rubyinstaller-devkit-2.6.5-1-x64.exe')
|
||||
|
||||
Write-Host "--- Installing Ruby + DevKit"
|
||||
Start-Process c:\rubyinstaller-devkit-2.6.5-1-x64.exe -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait
|
||||
|
||||
Write-Host "--- Cleaning up installation"
|
||||
Remove-Item c:\rubyinstaller-devkit-2.6.5-1-x64.exe -Force
|
||||
|
||||
$Env:Path += ";C:\ruby26\bin;C:\hab\bin"
|
||||
|
||||
Write-Host "+++ Testing $Plan"
|
||||
|
||||
$env:PATH = "C:\hab\bin;$env:PATH"
|
||||
Push-Location $project_root/test/artifact
|
||||
rake
|
||||
if (-not $?) { throw "rake failed" }
|
||||
Pop-Location
|
||||
|
|
|
@ -1,45 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ueo pipefail
|
||||
set -eo pipefail
|
||||
|
||||
export HAB_ORIGIN='ci'
|
||||
export PLAN='inspec'
|
||||
export CHEF_LICENSE="accept-no-persist"
|
||||
export HAB_LICENSE="accept-no-persist"
|
||||
project_root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
echo "--- system details"
|
||||
uname -a
|
||||
|
||||
echo "--- Installing Habitat"
|
||||
id -a
|
||||
curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | bash
|
||||
|
||||
|
||||
echo "--- Generating fake origin key"
|
||||
hab origin key generate $HAB_ORIGIN
|
||||
HAB_CI_KEY=$(realpath "$HOME"/.hab/cache/keys/"$HAB_ORIGIN"*.pub)
|
||||
HAB_CI_KEY=$(realpath /hab/cache/keys/"$HAB_ORIGIN"*.pub)
|
||||
export HAB_CI_KEY
|
||||
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
|
||||
|
||||
|
||||
echo "--- Building $PLAN"
|
||||
project_root="$(git rev-parse --show-toplevel)"
|
||||
cd "$project_root"
|
||||
|
||||
DO_CHECK=true hab pkg build .
|
||||
|
||||
echo "--- Sourcing 'results/last_build.sh'"
|
||||
if [ -f ./results/last_build.env ]; then
|
||||
cat ./results/last_build.env
|
||||
. ./results/last_build.env
|
||||
export pkg_artifact
|
||||
export project_root
|
||||
fi
|
||||
|
||||
echo "+++ Installing ${pkg_ident:?is undefined}"
|
||||
|
||||
# habitat sudo install
|
||||
HSI="$project_root"/.expeditor/buildkite/artifact.habitat.install.sh
|
||||
|
||||
sudo -E "$HSI"
|
||||
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
|
||||
|
||||
echo "+++ Testing $PLAN"
|
||||
|
||||
PATH="/hab/bin:$PATH"
|
||||
PATH="$(hab pkg path ci/inspec)/bin:$PATH"
|
||||
export PATH
|
||||
echo "PATH is $PATH"
|
||||
|
||||
pushd "$project_root/test/artifact"
|
||||
hab pkg exec core/ruby rake
|
||||
popd
|
||||
rake
|
||||
|
|
|
@ -21,16 +21,18 @@ Write-Output "--- Running verification for $channel $product $version"
|
|||
# reload Env:PATH to ensure it gets any changes that the install made (e.g. C:\opscode\inspec\bin\ )
|
||||
$Env:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
# Set GEM_HOME and GEM_PATH to verify our appbundle inspec shim is correctly
|
||||
# removing them from the environment while launching from our embedded ruby.
|
||||
$Env:GEM_HOME = "C:\SHOULD_NOT_EXIST"
|
||||
$Env:GEM_PATH = "C:\SHOULD_NOT_EXIST"
|
||||
Write-Host "--- Downloading Ruby + DevKit"
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
(New-Object System.Net.WebClient).DownloadFile('https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-devkit-2.6.5-1-x64.exe', 'c:\\rubyinstaller-devkit-2.6.5-1-x64.exe')
|
||||
|
||||
inspec version
|
||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
||||
Write-Host "--- Installing Ruby + DevKit"
|
||||
Start-Process c:\rubyinstaller-devkit-2.6.5-1-x64.exe -ArgumentList '/verysilent /dir=C:\\ruby26' -Wait
|
||||
|
||||
inspec shell -c platform.family
|
||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
||||
Write-Host "--- Cleaning up installation"
|
||||
Remove-Item c:\rubyinstaller-devkit-2.6.5-1-x64.exe -Force
|
||||
|
||||
inspec plugin list
|
||||
If ($lastexitcode -ne 0) { Exit $lastexitcode }
|
||||
$Env:Path += ";C:\ruby26\bin"
|
||||
Write-Host "+++ Testing $Plan"
|
||||
|
||||
cd test/artifact
|
||||
rake
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -ueo pipefail
|
||||
set -eo pipefail
|
||||
|
||||
channel="${CHANNEL:-unstable}"
|
||||
product="${PRODUCT:-inspec}"
|
||||
|
@ -27,14 +27,13 @@ fi
|
|||
|
||||
echo "--- Running verification for $channel $product $version"
|
||||
|
||||
# Set GEM_HOME and GEM_PATH to verify our appbundle inspec shim is correctly
|
||||
# removing them from the environment while launching from our embedded ruby.
|
||||
export GEM_HOME=/SHOULD_NOT_EXIST
|
||||
export GEM_PATH=/SHOULD_NOT_EXIST
|
||||
export CHEF_LICENSE="accept-no-persist"
|
||||
project_root="$(pwd)"
|
||||
export project_root
|
||||
|
||||
inspec version
|
||||
cd test/artifact
|
||||
|
||||
inspec shell -c platform.family
|
||||
PATH=/opt/inspec/bin:/opt/inspec/embedded/bin:$PATH
|
||||
export PATH
|
||||
|
||||
inspec plugin list
|
||||
rake
|
||||
|
|
|
@ -9,7 +9,8 @@ class ArtifactTest < Minitest::Test
|
|||
def assert_artifact(inspec_command)
|
||||
command = "inspec #{inspec_command} #{TEST_CLI_OPTS}"
|
||||
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
||||
command)
|
||||
command,
|
||||
{ :chdir => ENV["project_root"]})
|
||||
|
||||
assert_empty stderr.sub(/#< CLIXML\n/, "")
|
||||
assert stdout
|
||||
|
|
|
@ -11,6 +11,7 @@ class TestArtifactInstallation < Minitest::Test
|
|||
stdout, stderr, status = Open3.capture3({ "PATH" => ENV["PATH"] },
|
||||
"/usr/bin/which inspec")
|
||||
refute_match(/no inspec/, stdout)
|
||||
assert_includes(ENV["PATH"], "/bin")
|
||||
end
|
||||
|
||||
assert_empty stderr
|
||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecArchive < ArtifactTest
|
||||
def test_archive
|
||||
skip
|
||||
assert_artifact(:archive)
|
||||
assert_artifact("archive examples/profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecCheck < ArtifactTest
|
||||
def test_check
|
||||
skip
|
||||
assert_artifact(:check)
|
||||
assert_artifact("check examples/profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecCompliance < ArtifactTest
|
||||
def test_compliance_version
|
||||
assert_artifact("compliance help")
|
||||
assert_artifact("compliance logout")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecEnv < ArtifactTest
|
||||
def test_env
|
||||
assert_artifact(:env)
|
||||
skip if windows?
|
||||
assert_artifact("env bash")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecExec < ArtifactTest
|
||||
def test_exec
|
||||
skip
|
||||
assert_artifact(:exec)
|
||||
assert_artifact("exec examples/meta-profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecHabitat < ArtifactTest
|
||||
def test_habitat
|
||||
skip
|
||||
assert_artifact(:habitat)
|
||||
assert_artifact("habitat profile create examples/profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
require_relative "artifact_helper"
|
||||
|
||||
class TestInspecInit < ArtifactTest
|
||||
def test_init
|
||||
skip
|
||||
assert_artifact(:init)
|
||||
def test_init_profile
|
||||
assert_artifact("init profile inspec-profile")
|
||||
end
|
||||
|
||||
def test_init_plugin
|
||||
assert_artifact("init plugin inspec-plugin --no-prompt")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,8 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecJson < ArtifactTest
|
||||
def test_json
|
||||
skip
|
||||
# Need a tempdir
|
||||
assert_artifact(:json)
|
||||
assert_artifact("json examples/profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ require_relative "artifact_helper"
|
|||
|
||||
class TestInspecVendor < ArtifactTest
|
||||
def test_vendor
|
||||
skip
|
||||
assert_artifact(:vendor)
|
||||
assert_artifact("vendor examples/profile --overwrite")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue