Skip to content

Commit 27a9a39

Browse files
authored
Adding back the habitat packaging and license changes and releasing to major version (#272)
* Revert "Reverting back the hab and licensing changes" * updating version and changelog Signed-off-by: nikhil2611 <[email protected]> * empty commit to fix DCO Signed-off-by: nikhil2611 <[email protected]> --------- Signed-off-by: nikhil2611 <[email protected]>
1 parent 2b908c7 commit 27a9a39

33 files changed

+1269
-32
lines changed

.expeditor/build.habitat.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
origin: chef
3+
4+
expeditor:
5+
defaults:
6+
buildkite:
7+
retry:
8+
automatic:
9+
limit: 1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env powershell
2+
3+
#Requires -Version 5
4+
# https://stackoverflow.com/questions/9948517
5+
# TODO: Set-StrictMode -Version Latest
6+
$PSDefaultParameterValues['*:ErrorAction']='Stop'
7+
$ErrorActionPreference = 'Stop'
8+
$env:HAB_BLDR_CHANNEL = "LTS-2024"
9+
$env:HAB_REFRESH_CHANNEL = "LTS-2024"
10+
$env:HAB_ORIGIN = 'ci'
11+
$env:CHEF_LICENSE = 'accept-no-persist'
12+
$env:HAB_LICENSE = 'accept-no-persist'
13+
$Plan = 'chef-cli'
14+
15+
Write-Host "--- system details"
16+
$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'
17+
Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize
18+
19+
Write-Host "--- Installing the version of Habitat required"
20+
21+
function Stop-HabProcess {
22+
$habProcess = Get-Process hab -ErrorAction SilentlyContinue
23+
if ($habProcess) {
24+
Write-Host "Stopping hab process..."
25+
Stop-Process -Name hab -Force
26+
}
27+
}
28+
29+
# Installing Habitat
30+
function Install-Habitat {
31+
Write-Host "Downloading and installing Habitat..."
32+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1'))
33+
}
34+
35+
try {
36+
hab --version
37+
}
38+
catch {
39+
Set-ExecutionPolicy Bypass -Scope Process -Force
40+
41+
Stop-HabProcess
42+
43+
# Remove the existing hab.exe if it exists and if you have permissions
44+
$habPath = "C:\ProgramData\Habitat\hab.exe"
45+
if (Test-Path $habPath) {
46+
Write-Host "Attempting to remove existing hab.exe..."
47+
Remove-Item $habPath -Force -ErrorAction SilentlyContinue
48+
if (Test-Path $habPath) {
49+
Write-Host "Failed to remove hab.exe, re-running script with elevated permissions."
50+
Start-Process powershell -Verb runAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
51+
exit
52+
}
53+
}
54+
55+
Install-Habitat
56+
}
57+
finally {
58+
Write-Host ":habicat: I think I have the version I need to build."
59+
}
60+
61+
62+
Write-Host "--- Generating fake origin key"
63+
hab origin key generate $env:HAB_ORIGIN
64+
65+
Write-Host "--- Building $Plan"
66+
$project_root = "$(git rev-parse --show-toplevel)"
67+
Set-Location $project_root
68+
69+
$env:DO_CHECK=$true; hab pkg build .
70+
71+
. $project_root/results/last_build.ps1
72+
73+
Write-Host "--- Installing $pkg_ident/$pkg_artifact"
74+
hab pkg install -b $project_root/results/$pkg_artifact
75+
76+
Write-Host "+++ Testing $Plan"
77+
78+
Push-Location $project_root
79+
80+
try {
81+
Write-Host "Running unit tests..."
82+
habitat/tests/test.ps1 $pkg_ident
83+
}
84+
finally {
85+
# Ensure we always return to the original directory
86+
Pop-Location
87+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
export HAB_ORIGIN='ci'
6+
export PLAN='chef-cli'
7+
export CHEF_LICENSE="accept-no-persist"
8+
export HAB_LICENSE="accept-no-persist"
9+
export HAB_BLDR_CHANNEL="LTS-2024"
10+
export HAB_REFRESH_CHANNEL="LTS-2024"
11+
12+
echo "--- checking if git is installed"
13+
if ! command -v git &> /dev/null; then
14+
echo "Git is not installed. Installing Git..."
15+
sudo yum install -y git
16+
else
17+
echo "Git is already installed."
18+
git --version
19+
fi
20+
21+
echo "--- add an exception for this directory since detected dubious ownership in repository at /workdir"
22+
git config --global --add safe.directory /workdir
23+
24+
echo "--- git status for this workdir"
25+
git status
26+
27+
echo "--- ruby version"
28+
ruby -v
29+
30+
export project_root="$(git rev-parse --show-toplevel)"
31+
echo "The value for project_root is: $project_root"
32+
33+
export HAB_NONINTERACTIVE=true
34+
export HAB_NOCOLORING=true
35+
export HAB_STUDIO_SECRET_HAB_NONINTERACTIVE=true
36+
37+
echo "--- system details"
38+
uname -a
39+
40+
echo "--- Installing Habitat"
41+
id -a
42+
curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | bash
43+
44+
echo "--- :key: Generating fake origin key"
45+
hab origin key generate "$HAB_ORIGIN"
46+
47+
48+
echo "--- Building $PLAN"
49+
cd "$project_root"
50+
DO_CHECK=true hab pkg build .
51+
52+
echo "--- Sourcing 'results/last_build.sh'"
53+
if [ -f ./results/last_build.env ]; then
54+
cat ./results/last_build.env
55+
. ./results/last_build.env
56+
export pkg_artifact
57+
fi
58+
echo "+++ Installing ${pkg_ident:?is undefined}"
59+
echo "++++"
60+
echo $project_root
61+
echo "+++"
62+
hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}"
63+
64+
echo "+++ Testing $PLAN"
65+
66+
PATH="$(hab pkg path ci/chef-cli)/bin:$PATH"
67+
export PATH
68+
echo "PATH is $PATH"
69+
70+
echo "--- :mag_right: Testing $PLAN"
71+
${project_root}/habitat/tests/test.sh "$pkg_ident" || error 'failures during test of executables'

.expeditor/config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,27 @@ github:
3030
changelog:
3131
rollup_header: Changes not yet released to rubygems.org
3232

33+
artifact_channels:
34+
- unstable
35+
- chef-dke-lts2024
36+
3337
pipelines:
3438
- verify:
3539
description: Pull Request validation tests
3640
public: true
41+
- habitat/build:
42+
env:
43+
- HAB_NONINTERACTIVE: "true"
44+
- HAB_NOCOLORING: "true"
45+
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
46+
- habitat/test:
47+
description: Execute tests against the habitat artifact
48+
definition: .expeditor/habitat-test.pipeline.yml
49+
env:
50+
- HAB_NONINTERACTIVE: "true"
51+
- HAB_NOCOLORING: "true"
52+
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
53+
trigger: pull_request
3754

3855
subscriptions:
3956
# These actions are taken, in order they are specified, anytime a Pull Request is merged.
@@ -51,7 +68,15 @@ subscriptions:
5168
- "Expeditor: Skip All"
5269
- built_in:build_gem:
5370
only_if: built_in:bump_version
71+
- trigger_pipeline:habitat/build:
72+
only_if: built_in:bump_version
73+
ignore_labels:
74+
- "Expeditor: Skip Habitat"
75+
- "Expeditor: Skip All"
76+
77+
# this works for symantec version promote
5478
- workload: project_promoted:{{agent_id}}:*
5579
actions:
5680
- built_in:rollover_changelog
81+
- built_in:promote_habitat_packages
5782
- built_in:publish_rubygems
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
expeditor:
3+
defaults:
4+
buildkite:
5+
timeout_in_minutes: 30
6+
retry:
7+
automatic:
8+
limit: 1
9+
10+
11+
steps:
12+
13+
- label: ":linux: Validate Habitat Builds of Chef-cli"
14+
commands:
15+
- .expeditor/buildkite/artifact.habitat.test.sh
16+
expeditor:
17+
executor:
18+
docker:
19+
image: ruby:3.1
20+
privileged: true
21+
22+
- label: ":windows: Validate Habitat Builds of Test Kitchen"
23+
commands:
24+
- .expeditor/buildkite/artifact.habitat.test.ps1
25+
expeditor:
26+
executor:
27+
docker:
28+
host_os: windows
29+
shell: ["powershell", "-Command"]
30+
image: rubydistros/windows-2019:3.1
31+
user: 'NT AUTHORITY\SYSTEM'
32+
environment:
33+
- FORCE_FFI_YAJL=ext
34+
- EXPIRE_CACHE=true
35+
- CHEF_LICENSE=accept-no-persist
36+
- CHEF_LICENSE_SERVER=http://hosted-license-service-lb-8000-606952349.us-west-2.elb.amazonaws.com:8000/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ Vagrantfile
4141
my-cookbook
4242
results/
4343
Gemfile.lock
44+
45+
46+
.idea/

Gemfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,30 @@ source "https://rubygems.org"
33
gemspec
44

55
gem "logger", "< 1.6" # 1.6 causes errors with mixlib-log < 3.1.1
6-
6+
gem "chefspec"
77
group :test do
88
gem "rake"
9-
gem "rspec", "~> 3.8"
9+
gem "rspec", "=3.12.0"
1010
gem "rspec-expectations", "~> 3.8"
1111
gem "rspec-mocks", "~> 3.8"
1212
gem "cookstyle"
1313
gem "chefstyle"
14-
gem "test-kitchen"
14+
gem "faraday_middleware"
15+
gem "chef-test-kitchen-enterprise", git: "https://github.com/chef/chef-test-kitchen-enterprise", branch: "main"
1516
gem "simplecov", require: false
1617
end
1718

1819
group :development do
1920
gem "pry"
2021
gem "pry-byebug"
2122
gem "rb-readline"
23+
gem "appbundler"
2224
end
2325

2426
group :profile do
25-
gem "stackprof"
26-
gem "stackprof-webnav"
27-
gem "memory_profiler"
28-
end
27+
unless RUBY_PLATFORM.match?(/mswin|mingw|windows/)
28+
gem "stackprof"
29+
gem "stackprof-webnav"
30+
gem "memory_profiler"
31+
end
32+
end

Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17+
#
18+
require "bundler/gem_tasks"
1719

1820
namespace :style do
1921
begin
@@ -52,3 +54,4 @@ namespace :style do
5254
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
5355
end
5456
end
57+

chef-cli.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ Gem::Specification.new do |gem|
5050
gem.add_dependency "diff-lcs", ">= 1.0", "< 1.4" # 1.4 changes the output
5151
gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
5252
gem.add_dependency "license-acceptance", ">= 1.0.11", "< 3"
53+
gem.add_dependency "chef-licensing", "~> 1.0"
5354
end

0 commit comments

Comments
 (0)