inspec/habitat/plan.ps1
Nikita Mathur fa1d9354e7
Use Ruby 3.1 for InSpec 4; Drop EOL 2.7 (#6713)
* Verify pipeline tests upgraded to ruby 3.1

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Removed unused test fixtures of older ruby version

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Updates test fixtures from ruby 2.7 to ruby 3.0 & 3.1

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Habitat package upgrade to ruby 31

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Upgraded omnibus ruby version to ruby 3.1

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Update ruby gem version in expeditor verify

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Update ruby gem version to ruby 3.3.3 in expeditor verify

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* add ruby test 3.1 in verify pipeline (#5892)

* add ruby test 3.1 in verify pipeline

Signed-off-by: jayashri garud <jgarud@msystechnologies.com>

* updating rubygem to 3.3.3

Signed-off-by: jayashri garud <jgarud@msystechnologies.com>

* Test fixture plugin files for ABI 3.1.0

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Use kwargs to match new calling style for ERB in ruby 2.7 and 3.0

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Allow Date and Time data types, needed for waivers, since safe load is now the default for YAML

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Use Time.parse, not Time.new since the rules tightened for what you can pass the constructor for waiver dates

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Add ruby platform debug message to test parallel output

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* Conditionalize permitted_classes in inputs yaml_load for <= 3.1.x only

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>

* In ruby 3.1.0 net/pop3 is no more a default gem and that will require us to add it in Gemfile so trying with the byebug gem which we are bundling already

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>

* CFINSPEC-166 Updated url fetcher to handle Net::OpenTimeout Exception on Windows

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>

Co-authored-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Co-authored-by: Vasu1105 <vasundhara.jagdale@chef.io>

* Inputs test fix as fixed in vasundhara/ruby-3-support

Signed-off-by: Nik08 <nikita.mathur@progress.com>

---------

Signed-off-by: Nik08 <nikita.mathur@progress.com>
Co-authored-by: jayashrig158 <61735743+jayashrig158@users.noreply.github.com>
Co-authored-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Co-authored-by: Vasu1105 <vasundhara.jagdale@chef.io>
2023-09-29 19:14:27 -04:00

89 lines
3.6 KiB
PowerShell

# https://stackoverflow.com/questions/9948517
# TODO: Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'
$pkg_name="inspec"
$pkg_origin="chef"
$pkg_version=$(Get-Content "$PLAN_CONTEXT/../VERSION")
$pkg_revision="1"
$pkg_description="InSpec is an open-source testing framework for infrastructure
with a human- and machine-readable language for specifying compliance,
security and policy requirements."
$pkg_upstream_url="https://www.inspec.io/"
$pkg_maintainer="The Chef Maintainers <humans@chef.io>"
$pkg_license=('Apache-2.0')
$pkg_deps=@(
"chef/ruby31-plus-devkit"
)
$pkg_bin_dirs=@("bin"
"vendor/bin")
$project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path
function Invoke-SetupEnvironment {
Push-RuntimeEnv -IsPath GEM_PATH "$pkg_prefix/vendor"
Set-RuntimeEnv APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH
Set-RuntimeEnv FORCE_FFI_YAJL "ext"
Set-RuntimeEnv LANG "en_US.UTF-8"
Set-RuntimeEnv LC_CTYPE "en_US.UTF-8"
}
function Invoke-Build {
try {
Push-Location $project_root
$env:GEM_HOME = "$HAB_CACHE_SRC_PATH/$pkg_dirname/vendor"
Write-BuildLine " ** Configuring bundler for this build environment"
bundle config --local without integration deploy maintenance
bundle config --local jobs 4
bundle config --local retry 5
bundle config --local silence_root_warning 1
Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies"
bundle install
If ($lastexitcode -ne 0) { Exit $lastexitcode }
Write-BuildLine " ** Running the inspec project's 'rake install' to install the path-based gems so they look like any other installed gem."
bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
If ($lastexitcode -ne 0) { Exit $lastexitcode }
} finally {
Pop-Location
}
}
function Invoke-Install {
Write-BuildLine "** Copy built & cached gems to install directory"
Copy-Item -Path "$HAB_CACHE_SRC_PATH/$pkg_dirname/*" -Destination $pkg_prefix -Recurse -Force -Exclude @("gem_make.out", "mkmf.log", "Makefile",
"*/latest", "latest",
"*/JSON-Schema-Test-Suite", "JSON-Schema-Test-Suite")
try {
Push-Location $pkg_prefix
bundle config --local gemfile $project_root/Gemfile
foreach($gem in ("inspec-core", "inspec", "inspec-bin")) {
Write-BuildLine "** generating binstubs for $gem with precise version pins"
Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin $gem"
If ($lastexitcode -ne 0) { Exit $lastexitcode }
}
} finally {
Pop-Location
# forget about the build bundle config
Remove-Item $pkg_prefix/.bundle -Recurse -Force
}
}
function Invoke-After {
# We don't need the cache of downloaded .gem files ...
Remove-Item $pkg_prefix/vendor/cache -Recurse -Force
# We don't need the gem docs.
Remove-Item $pkg_prefix/vendor/doc -Recurse -Force
# We don't need to ship the test suites for every gem dependency,
# only inspec's for package verification.
Get-ChildItem $pkg_prefix/vendor/gems -Filter "spec" -Directory -Recurse -Depth 1 `
| Where-Object -FilterScript { $_.FullName -notlike "*inspec*" } `
| Remove-Item -Recurse -Force
# Remove the byproducts of compiling gems with extensions
Get-ChildItem $pkg_prefix/vendor/gems -Include @("gem_make.out", "mkmf.log", "Makefile") -File -Recurse `
| Remove-Item -Force
}