Skip to content

Commit 6689451

Browse files
nikhil2611Sachinsanjain-progresssanghinitinchef-ci
authored
Habitat package for Fauxhai (#59)
* Pick version from Version file instead of Hardcoded Signed-off-by: Sachin <sachin.jain@chef.io> * add pipleline for build, publish Signed-off-by: Sachin <sachin.jain@chef.io> * fix habitat build for linux Signed-off-by: Sachin <sachin.jain@chef.io> * Change pipeline to expeditor Signed-off-by: nitin sanghi <nsanghi@progress.com> * Fix pipeline name Signed-off-by: nitin sanghi <nsanghi@progress.com> * Change pipeline to expeditor Signed-off-by: nitin sanghi <nsanghi@progress.com> * remove pipeline create config Signed-off-by: nitin sanghi <nsanghi@progress.com> * pkg indent fix Signed-off-by: nitin sanghi <nsanghi@progress.com> * Experditor trigger for promoting pkg Signed-off-by: nitin sanghi <nsanghi@progress.com> * adding echo to check bash file is running or not Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * testing release branch Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * testing agents creating Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * adding artifact channel Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * added the channel variable Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 9.3.19 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * Bump version to 9.3.20 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * re-working expeditor config you will need to manually create the habitat packages: workstation-build, stable, workstation-LTS for this workflow to work properlly for now i will create them via the build, just once, then undo the commit Signed-off-by: Sean Simmons <sean.simmons@progress.com> * updating do_before just to add the channels once Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * fixing expeditor error config Signed-off-by: Sean Simmons <sean.simmons@progress.com> * updtaing workflow for expeditor config also updating script to promote from STABLE to workstation-LTS Signed-off-by: Sean Simmons <sean.simmons@progress.com> * updating comments Signed-off-by: Sean Simmons <sean.simmons@progress.com> * removing for a test Signed-off-by: Sean Simmons <sean.simmons@progress.com> * moving this value back as requested Signed-off-by: Sean Simmons <sean.simmons@progress.com> * moving this value back as requested Signed-off-by: Sean Simmons <sean.simmons@progress.com> * updated the channel from workstation-LTS to LTS-2024 Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 9.3.21 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * updated the version to 0.1 Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * removed the rollover changes Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 0.1.0 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * Update CHANGELOG.md to reflect the promotion of 9.3.21 Obvious fix; these changes are the result of automation not creative thinking. * Updating the promote-hab script to grab the correct values out of running env vars updated expeditor config to auto promote to the first channel, workstation-build updated expeditor script with a better name for the staging area Signed-off-by: Sean Simmons <sean.simmons@progress.com> * Bump version to 0.1.1 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * Bump version to 0.1.2 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * testing env vars Signed-off-by: Sean Simmons <sean.simmons@progress.com> * removing pipelines to rebuild the agent and pipelines Signed-off-by: Sean Simmons <sean.simmons@progress.com> * re-adding pipelines Signed-off-by: Sean Simmons <sean.simmons@progress.com> * empty commit Signed-off-by: Sean Simmons <sean.simmons@progress.com> * Bump version to 0.1.3 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * updating script Signed-off-by: Sean Simmons <sean.simmons@progress.com> * had the wrong name in the expeditor config, an extra s Signed-off-by: Sean Simmons <sean.simmons@progress.com> * pathing. Signed-off-by: Sean Simmons <sean.simmons@progress.com> * removed the sh file instead promote from wrokload Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * test commit Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * test commit by removing space Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * fixing config Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * add back trigger config Signed-off-by: muthuja <muthujabavaji.vempalli@progress.com> * test the pipeline trigger Signed-off-by: muthuja <muthujabavaji.vempalli@progress.com> * add back trigger config Signed-off-by: muthuja <muthujabavaji.vempalli@progress.com> * revert readme file changes Signed-off-by: muthuja <muthujabavaji.vempalli@progress.com> * empty commit Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * empty commit Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * empty commit Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 0.1.4 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * remove the building of gem from hab config Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 0.1.5 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * testing the pipelines are working fine or not Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Bump version to 0.1.6 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * Chef-18535 Removed the release branch changes and fixed pipeline (#58) * updating version to major version and few plan file fixes Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * reverting versions and fixing pipeline Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> --------- Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * downgrading version back to 9.3.18 Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * Update CHANGELOG.md to fix conflicts * fixing changelog.md Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> * removed the extra Invoke-Before func Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> --------- Signed-off-by: Sachin <sachin.jain@chef.io> Signed-off-by: nitin sanghi <nsanghi@progress.com> Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com> Signed-off-by: Sean Simmons <sean.simmons@progress.com> Signed-off-by: muthuja <muthujabavaji.vempalli@progress.com> Co-authored-by: Sachin <sachin.jain@chef.io> Co-authored-by: Sachin Jain <90894396+sanjain-progress@users.noreply.github.com> Co-authored-by: nitin sanghi <nsanghi@progress.com> Co-authored-by: Chef Expeditor <chef-ci@chef.io> Co-authored-by: Sean Simmons <sean.simmons@progress.com> Co-authored-by: ns <sanghinitin@users.noreply.github.com> Co-authored-by: sean-simmons-progress <111799713+sean-simmons-progress@users.noreply.github.com> Co-authored-by: muthuja <muthujabavaji.vempalli@progress.com>
1 parent ea63537 commit 6689451

10 files changed

+336
-68
lines changed

.expeditor/build.habitat.yml

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

.expeditor/config.yml

+34-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,31 @@ slack:
88
# This publish is triggered by the `built_in:publish_rubygems` artifact_action.
99
rubygems:
1010
- fauxhai-chef
11+
12+
artifact_channels:
13+
- unstable
14+
- chef-dke-lts2024
15+
16+
pipelines:
17+
- verify:
18+
description: Pull Request validation tests
19+
public: true
20+
- habitat/build:
21+
description: Build the Habitat packages for faixhai
22+
env:
23+
- HAB_NONINTERACTIVE: "true"
24+
- HAB_NOCOLORING: "true"
25+
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
26+
- habitat/test:
27+
description: Execute tests against the habitat artifact
28+
definition: .expeditor/habitat-test.pipeline.yml
29+
trigger: pull_request
30+
env:
31+
- HAB_NONINTERACTIVE: "true"
32+
- HAB_NOCOLORING: "true"
33+
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
1134

1235
release_branches:
13-
- workstation-LTS:
14-
version_constraint: 9.*
1536
- main:
1637
version_constraint: 9.*
1738

@@ -46,12 +67,18 @@ subscriptions:
4667
- "Expeditor: Skip All"
4768
- built_in:build_gem:
4869
only_if: built_in:bump_version
70+
- trigger_pipeline:habitat/build:
71+
ignore_labels:
72+
- "Expeditor: Skip Habitat"
73+
- "Expeditor: Skip All"
74+
only_if: built_in:bump_version
75+
4976
- workload: project_promoted:{{agent_id}}:*
5077
actions:
5178
- built_in:rollover_changelog
52-
- built_in:publish_rubygems
5379

54-
pipelines:
55-
- verify:
56-
description: Pull Request validation tests
57-
public: true
80+
# Subscribe to the promotion of the unstable channel to stable(chef-dke-lts2024)
81+
- workload: project_promoted:{{agent_id}}:unstable:*
82+
actions:
83+
- built_in:promote_habitat_packages
84+
- built_in:publish_rubygems

.expeditor/habitat-test.pipeline.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
expeditor:
3+
defaults:
4+
buildkite:
5+
timeout_in_minutes: 30
6+
env:
7+
HAB_REFRESH_CHANNEL: "LTS-2024"
8+
retry:
9+
automatic:
10+
limit: 1
11+
12+
13+
steps:
14+
15+
- label: ":linux: Validate Habitat Builds of fauxhai"
16+
commands:
17+
- .expeditor/buildkite/artifact.habitat.test.sh
18+
expeditor:
19+
executor:
20+
docker:
21+
image: ruby:3.1
22+
privileged: true
23+
24+
- label: ":windows: Validate Habitat Builds of fauxhai"
25+
commands:
26+
- .expeditor/buildkite/artifact.habitat.test.ps1
27+
expeditor:
28+
executor:
29+
docker:
30+
host_os: windows
31+
shell: ["powershell", "-Command"]
32+
image: rubydistros/windows-2019:3.1
33+
user: 'NT AUTHORITY\SYSTEM'
34+
environment:
35+
- FORCE_FFI_YAJL=ext
36+
- EXPIRE_CACHE=true
37+
- CHEF_LICENSE=accept-no-persist
38+
- CHEF_LICENSE_SERVER=http://hosted-license-service-lb-8000-606952349.us-west-2.elb.amazonaws.com:8000/

CHANGELOG.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<!-- latest_release 9.3.19 -->
2-
## [v9.3.19](https://github.com/chef/fauxhai/tree/v9.3.19) (2024-12-19)
3-
4-
#### Merged Pull Requests
5-
- Added the release branch [#40](https://github.com/chef/fauxhai/pull/40) ([nikhil2611](https://github.com/nikhil2611))
1+
<!-- latest_release -->
62
<!-- latest_release -->
73

84
<!-- release_rollup since=9.3.16 -->
@@ -12,6 +8,7 @@
128
- Added the release branch [#40](https://github.com/chef/fauxhai/pull/40) ([nikhil2611](https://github.com/nikhil2611)) <!-- 9.3.19 -->
139
- Package fauxhai as a hab package [#31](https://github.com/chef/fauxhai/pull/31) ([sanjain-progress](https://github.com/sanjain-progress)) <!-- 9.3.18 -->
1410
- [CI] Drop EOL rubies [#33](https://github.com/chef/fauxhai/pull/33) ([dafyddcrosby](https://github.com/dafyddcrosby)) <!-- 9.3.17 -->
11+
1512
<!-- release_rollup -->
1613

1714
<!-- latest_stable_release -->
@@ -1020,4 +1017,4 @@ Released: 2013-05-09
10201017
[@mapleoin]: https://github.com/mapleoin
10211018
[@pschultz]: https://github.com/pschultz
10221019
[@sax]: https://github.com/sax
1023-
[@tmatilai]: https://github.com/tmatilai
1020+
[@tmatilai]: https://github.com/tmatilai

habitat/plan.ps1

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ $PSDefaultParameterValues['*:ErrorAction']='Stop'
33

44
$pkg_name="fauxhai"
55
$pkg_origin="core"
6-
$pkg_version="9.3.16"
7-
$pkg_revision="1"
6+
$pkg_version=$(Get-Content "$PLAN_CONTEXT/../VERSION")
87
$pkg_maintainer="The Chef Maintainers <humans@chef.io>"
98

109
$pkg_deps=@(
@@ -15,6 +14,14 @@ $pkg_bin_dirs=@("bin"
1514
"vendor/bin")
1615
$project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path
1716

17+
function pkg_version {
18+
Get-Content "$SRC_PATH/VERSION"
19+
}
20+
21+
function Invoke-Before {
22+
Set-PkgVersion
23+
}
24+
1825
function Invoke-SetupEnvironment {
1926
Push-RuntimeEnv -IsPath GEM_PATH "$pkg_prefix/vendor"
2027

0 commit comments

Comments
 (0)