From 1c66f14ce5bec461112364943356c69e0b01bda1 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Tue, 17 Sep 2024 10:32:47 +0530 Subject: [PATCH 01/18] Hab plan file for windows and linux to build hab pkg Signed-off-by: nitin sanghi --- Gemfile | 2 +- habitat/plan.ps1 | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ habitat/plan.sh | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 habitat/plan.ps1 create mode 100644 habitat/plan.sh diff --git a/Gemfile b/Gemfile index 31584eccb..7ab9c3de4 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gemspec # pull these gems from main of chef/chef so that we're testing against what we will release gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec" gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec" - +gem "appbundler" # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local group :development do gem "cookstyle", ">= 7.32.8" diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 new file mode 100644 index 000000000..a93c74a47 --- /dev/null +++ b/habitat/plan.ps1 @@ -0,0 +1,92 @@ +$ErrorActionPreference = "Stop" +$PSDefaultParameterValues['*:ErrorAction']='Stop' + +$pkg_name="ohai" +$pkg_origin="chef" +$pkg_version=$(Get-Content "$PLAN_CONTEXT/../VERSION") +$pkg_maintainer="The Chef Maintainers " + +$pkg_deps=@( + "chef/ruby31-plus-devkit" + "core/git" +) +$pkg_bin_dirs=@("bin" + "vendor/bin") +$project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path + +function pkg_version { + Get-Content "$SRC_PATH/VERSION" +} + +function Invoke-Before { + Set-PkgVersion +} +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 { + $env:Path += ";c:\\Program Files\\Git\\bin" + 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 + + gem build ohai.gemspec + Write-BuildLine " ** Using gem to install" + gem install ohai-*.gem --no-document + + + 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 + Write-BuildLine "** generating binstubs for ohai with precise version pins" + Write-BuildLine "** generating binstubs for ohai with precise version pins $project_root $pkg_prefix/bin " + Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin ohai" + If ($lastexitcode -ne 0) { Exit $lastexitcode } + Write-BuildLine " ** Running the ohai project's 'rake install' to install the path-based gems so they look like any other installed gem." + + If ($lastexitcode -ne 0) { Exit $lastexitcode } + } finally { + Pop-Location + } +} + +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 "*ohai*" } ` + | 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 +} \ No newline at end of file diff --git a/habitat/plan.sh b/habitat/plan.sh new file mode 100644 index 000000000..eb96a8730 --- /dev/null +++ b/habitat/plan.sh @@ -0,0 +1,63 @@ +pkg_name=ohai +pkg_origin=chef +ruby_pkg="core/ruby31" +pkg_deps=(${ruby_pkg} core/coreutils) +pkg_build_deps=( + core/make + core/sed + core/gcc + ) +pkg_bin_dirs=(bin) +do_setup_environment() { + build_line 'Setting GEM_HOME="$pkg_prefix/lib"' + export GEM_HOME="$pkg_prefix/lib" + + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" +} + +pkg_version() { + cat "$SRC_PATH/VERSION" +} +do_before() { + update_pkg_version +} +do_unpack() { + mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname" + cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" +} +do_build() { + pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem build ohai.gemspec + popd +} +do_install() { + pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem install ohai-*.gem --no-document + popd + wrap_ruby_bin +} +wrap_ruby_bin() { + local bin="$pkg_prefix/bin/$pkg_name" + local real_bin="$GEM_HOME/gems/ohai-${pkg_version}/bin/ohai" + build_line "Adding wrapper $bin to $real_bin" + cat < "$bin" +#!$(pkg_path_for core/bash)/bin/bash +set -e + +# Set binary path that allows ohai to use non-Hab pkg binaries +export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH" + +# Set Ruby paths defined from 'do_setup_environment()' +export GEM_HOME="$GEM_HOME" +export GEM_PATH="$GEM_PATH" + +exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin \$@ +EOF + chmod -v 755 "$bin" +} + + +do_strip() { + return 0 +} \ No newline at end of file From dbbdd5ba4dbd948e3dc7631c9079ea89a995c281 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Wed, 18 Sep 2024 11:25:51 +0530 Subject: [PATCH 02/18] Linux plan change based on appbundler Signed-off-by: nitin sanghi --- .byebug_history | 1 + Gemfile | 35 +++++----- habitat/plan.ps1 | 4 +- habitat/plan.sh | 145 +++++++++++++++++++++++++++++------------ post-bundle-install.rb | 32 +++++++++ 5 files changed, 155 insertions(+), 62 deletions(-) create mode 100644 .byebug_history create mode 100644 post-bundle-install.rb diff --git a/.byebug_history b/.byebug_history new file mode 100644 index 000000000..5b6985884 --- /dev/null +++ b/.byebug_history @@ -0,0 +1 @@ +next diff --git a/Gemfile b/Gemfile index 7ab9c3de4..39c75defd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,28 +1,29 @@ # frozen_string_literal: true -source "https://rubygems.org" + +source 'https://rubygems.org' gemspec # pull these gems from main of chef/chef so that we're testing against what we will release -gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec" -gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec" -gem "appbundler" +gem 'appbundler' +gem 'chef-config', git: 'https://github.com/chef/chef', branch: 'main', glob: 'chef-config/chef-config.gemspec' +gem 'chef-utils', git: 'https://github.com/chef/chef', branch: 'main', glob: 'chef-utils/chef-utils.gemspec' # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local group :development do - gem "cookstyle", ">= 7.32.8" - gem "ipaddr_extensions" - gem "rake", ">= 10.1.0" - gem "rspec-collection_matchers", "~> 1.0" - gem "rspec-core", "~> 3.0" - gem "rspec-expectations", "~> 3.0" - gem "rspec-mocks", "~> 3.0" - gem "rubocop-performance", "1.18.0" - gem "rubocop-rspec" + gem 'cookstyle', '>= 7.32.8' + gem 'ipaddr_extensions' + gem 'rake', '>= 10.1.0' + gem 'rspec-collection_matchers', '~> 1.0' + gem 'rspec-core', '~> 3.0' + gem 'rspec-expectations', '~> 3.0' + gem 'rspec-mocks', '~> 3.0' + gem 'rubocop-performance', '1.18.0' + gem 'rubocop-rspec' end group :debug do - gem "pry" - gem "pry-byebug" - gem "pry-stack_explorer" - gem "rb-readline" + gem 'pry' + gem 'pry-byebug' + gem 'pry-stack_explorer' + gem 'rb-readline' end diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index a93c74a47..d2d415129 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -45,8 +45,8 @@ function Invoke-Build { bundle install gem build ohai.gemspec - Write-BuildLine " ** Using gem to install" - gem install ohai-*.gem --no-document + Write-BuildLine " ** Using gem to install" + gem install ohai-*.gem --no-document If ($lastexitcode -ne 0) { Exit $lastexitcode } diff --git a/habitat/plan.sh b/habitat/plan.sh index eb96a8730..e01a51fbb 100644 --- a/habitat/plan.sh +++ b/habitat/plan.sh @@ -1,62 +1,121 @@ -pkg_name=ohai -pkg_origin=chef -ruby_pkg="core/ruby31" -pkg_deps=(${ruby_pkg} core/coreutils) +_chef_client_ruby="core/ruby31" +pkg_name="ohai" +pkg_origin="chef" +pkg_maintainer="The Chef Maintainers " +pkg_description="The Chef Ohai" +pkg_license=('Apache-2.0') +pkg_bin_dirs=( + bin + vendor/bin +) pkg_build_deps=( - core/make - core/sed - core/gcc - ) -pkg_bin_dirs=(bin) -do_setup_environment() { - build_line 'Setting GEM_HOME="$pkg_prefix/lib"' - export GEM_HOME="$pkg_prefix/lib" - - build_line "Setting GEM_PATH=$GEM_HOME" - export GEM_PATH="$GEM_HOME" -} + core/make + core/gcc + core/git +) +pkg_deps=( + $_chef_client_ruby + core/coreutils +) +pkg_svc_user=root pkg_version() { - cat "$SRC_PATH/VERSION" + cat "${SRC_PATH}/VERSION" } + do_before() { + do_default_before update_pkg_version + # We must wait until we update the pkg_version to use the pkg_version + pkg_filename="${pkg_name}-${pkg_version}.tar.gz" +} + +do_download() { + build_line "Locally creating archive of latest repository commit at ${HAB_CACHE_SRC_PATH}/${pkg_filename}" + # source is in this repo, so we're going to create an archive from the + # appropriate path within the repo and place the generated tarball in the + # location expected by do_unpack + ( cd "${SRC_PATH}" || exit_with "unable to enter hab-src directory" 1 + git archive --prefix="${pkg_name}-${pkg_version}/" --output="${HAB_CACHE_SRC_PATH}/${pkg_filename}" HEAD + ) } -do_unpack() { - mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname" - cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + +do_verify() { + build_line "Skipping checksum verification on the archive we just created." + return 0 } + +do_setup_environment() { + push_runtime_env GEM_PATH "${pkg_prefix}/vendor" + + set_runtime_env APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH + set_runtime_env LANG "en_US.UTF-8" + set_runtime_env LC_CTYPE "en_US.UTF-8" +} + +do_prepare() { + export GEM_HOME="${pkg_prefix}/vendor" + export CPPFLAGS="${CPPFLAGS} ${CFLAGS}" + + ( cd "$CACHE_PATH" + bundle config --local jobs "$(nproc)" + bundle config --local without server docgen maintenance pry travis integration ci + bundle config --local shebang "$(pkg_path_for "$_chef_client_ruby")/bin/ruby" + bundle config --local retry 5 + bundle config --local silence_root_warning 1 + ) + + build_line "Setting link for /usr/bin/env to 'coreutils'" + if [ ! -f /usr/bin/env ]; then + ln -s "$(pkg_interpreter_for core/coreutils bin/env)" /usr/bin/env + fi +} + do_build() { - pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" - gem build ohai.gemspec - popd + ( cd "$CACHE_PATH" || exit_with "unable to enter hab-cache directory" 1 + build_line "Installing gem dependencies ..." + bundle install --jobs=3 --retry=3 + build_line "Installing gems from git repos properly ..." + ruby ./post-bundle-install.rb + build_line "Installing this project's gems ..." + bundle exec rake install:local + ) } + do_install() { - pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" - gem install ohai-*.gem --no-document - popd - wrap_ruby_bin + ( cd "$pkg_prefix" || exit_with "unable to enter pkg prefix directory" 1 + export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" + build_line "** fixing binstub shebangs" + fix_interpreter "${pkg_prefix}/vendor/bin/*" "$_chef_client_ruby" bin/ruby + export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" + for gem in ohai; do + build_line "** generating binstubs for $gem with precise version pins" + appbundler $CACHE_PATH $pkg_prefix/bin $gem + done + ) } -wrap_ruby_bin() { - local bin="$pkg_prefix/bin/$pkg_name" - local real_bin="$GEM_HOME/gems/ohai-${pkg_version}/bin/ohai" - build_line "Adding wrapper $bin to $real_bin" - cat < "$bin" -#!$(pkg_path_for core/bash)/bin/bash -set -e -# Set binary path that allows ohai to use non-Hab pkg binaries -export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH" +do_after() { + build_line "Trimming the fat ..." -# Set Ruby paths defined from 'do_setup_environment()' -export GEM_HOME="$GEM_HOME" -export GEM_PATH="$GEM_PATH" - -exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin \$@ -EOF - chmod -v 755 "$bin" + # We don't need the cache of downloaded .gem files ... + rm -r "$pkg_prefix/vendor/cache" + # ... or bundler's cache of git-ref'd gems + rm -r "$pkg_prefix/vendor/bundler" + # We don't need the gem docs. + rm -r "$pkg_prefix/vendor/doc" + # We don't need to ship the test suites for every gem dependency, + # only Chef's for package verification. + find "$pkg_prefix/vendor/gems" -name spec -type d | grep -v "ohai-${pkg_version}" \ + | while read spec_dir; do rm -r "$spec_dir"; done } +do_end() { + if [ "$(readlink /usr/bin/env)" = "$(pkg_interpreter_for core/coreutils bin/env)" ]; then + build_line "Removing the symlink we created for '/usr/bin/env'" + rm /usr/bin/env + fi +} do_strip() { return 0 diff --git a/post-bundle-install.rb b/post-bundle-install.rb new file mode 100644 index 000000000..85451e912 --- /dev/null +++ b/post-bundle-install.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +gem_home = Gem.paths.home + +puts "fixing bundle installed gems in #{gem_home}" + +# Install gems from git repos. This makes the assumption that there is a .gemspec and +# you can simply gem build + gem install the resulting gem, so nothing fancy. This does not use +# rake install since we need --conservative --minimal-deps in order to not install duplicate gems. +# +# +puts "gem path #{gem_home}" + +Dir["#{gem_home}/bundler/gems/*"].each do |gempath| + matches = File.basename(gempath).match(/.*-[A-Fa-f0-9]{12}/) + next unless matches + + %w[chef-utils chef-config].each do |gem_need_install| + dir_path = "#{gempath}/#{gem_need_install}" + gem_name = File.basename(Dir["#{dir_path}/*.gemspec"].first, '.gemspec') + # FIXME: should strip any valid ruby platform off of the gem_name if it matches + + next unless gem_name + + puts "re-installing #{gem_name}..." + + Dir.chdir(dir_path) do + system("gem build #{gem_name}.gemspec") or raise 'gem build failed' + system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise 'gem install failed' + end + end +end From 192df7f418354c297669325d5a2409d731f5a17c Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Wed, 25 Sep 2024 13:32:35 +0530 Subject: [PATCH 03/18] Gemfile change on lint issue Signed-off-by: nitin sanghi --- Gemfile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 39c75defd..84d289a15 100644 --- a/Gemfile +++ b/Gemfile @@ -1,29 +1,29 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" gemspec -# pull these gems from main of chef/chef so that we're testing against what we will release -gem 'appbundler' -gem 'chef-config', git: 'https://github.com/chef/chef', branch: 'main', glob: 'chef-config/chef-config.gemspec' -gem 'chef-utils', git: 'https://github.com/chef/chef', branch: 'main', glob: 'chef-utils/chef-utils.gemspec' +# pull these gems from main of chef/chef so that we"re testing against what we will release +gem "appbundler" +gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec" +gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec" # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local group :development do - gem 'cookstyle', '>= 7.32.8' - gem 'ipaddr_extensions' - gem 'rake', '>= 10.1.0' - gem 'rspec-collection_matchers', '~> 1.0' - gem 'rspec-core', '~> 3.0' - gem 'rspec-expectations', '~> 3.0' - gem 'rspec-mocks', '~> 3.0' - gem 'rubocop-performance', '1.18.0' - gem 'rubocop-rspec' + gem "cookstyle", ">= 7.32.8" + gem "ipaddr_extensions" + gem "rake", ">= 10.1.0" + gem "rspec-collection_matchers", "~> 1.0" + gem "rspec-core", "~> 3.0" + gem "rspec-expectations", "~> 3.0" + gem "rspec-mocks", "~> 3.0" + gem "rubocop-performance", "1.18.0" + gem "rubocop-rspec" end group :debug do - gem 'pry' - gem 'pry-byebug' - gem 'pry-stack_explorer' - gem 'rb-readline' + gem "pry" + gem "pry-byebug" + gem "pry-stack_explorer" + gem "rb-readline" end From 788b0d58819645634edc05af25e1fe43656142a9 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Thu, 26 Sep 2024 17:31:41 +0530 Subject: [PATCH 04/18] Remove bybug file Signed-off-by: nitin sanghi --- .byebug_history | 1 - post-bundle-install.rb | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 .byebug_history diff --git a/.byebug_history b/.byebug_history deleted file mode 100644 index 5b6985884..000000000 --- a/.byebug_history +++ /dev/null @@ -1 +0,0 @@ -next diff --git a/post-bundle-install.rb b/post-bundle-install.rb index 85451e912..d35308c70 100644 --- a/post-bundle-install.rb +++ b/post-bundle-install.rb @@ -17,7 +17,7 @@ %w[chef-utils chef-config].each do |gem_need_install| dir_path = "#{gempath}/#{gem_need_install}" - gem_name = File.basename(Dir["#{dir_path}/*.gemspec"].first, '.gemspec') + gem_name = File.basename(Dir["#{dir_path}/*.gemspec"].first, ".gemspec") # FIXME: should strip any valid ruby platform off of the gem_name if it matches next unless gem_name @@ -25,8 +25,8 @@ puts "re-installing #{gem_name}..." Dir.chdir(dir_path) do - system("gem build #{gem_name}.gemspec") or raise 'gem build failed' - system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise 'gem install failed' + system("gem build #{gem_name}.gemspec") or raise "gem build failed" + system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed" end end end From 30ed8625b9f4f883fa68220bad8349c0838c07e8 Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Thu, 17 Oct 2024 12:57:35 +0530 Subject: [PATCH 05/18] fixinf chefstyle changes Signed-off-by: nikhil2611 --- post-bundle-install.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/post-bundle-install.rb b/post-bundle-install.rb index d35308c70..f20728b8a 100644 --- a/post-bundle-install.rb +++ b/post-bundle-install.rb @@ -15,9 +15,9 @@ matches = File.basename(gempath).match(/.*-[A-Fa-f0-9]{12}/) next unless matches - %w[chef-utils chef-config].each do |gem_need_install| + %w{chef-utils chef-config}.each do |gem_need_install| dir_path = "#{gempath}/#{gem_need_install}" - gem_name = File.basename(Dir["#{dir_path}/*.gemspec"].first, ".gemspec") + gem_name = File.basename(Dir["#{dir_path}/*.gemspec"].first, ".gemspec") # FIXME: should strip any valid ruby platform off of the gem_name if it matches next unless gem_name @@ -25,8 +25,8 @@ puts "re-installing #{gem_name}..." Dir.chdir(dir_path) do - system("gem build #{gem_name}.gemspec") or raise "gem build failed" - system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed" + system("gem build #{gem_name}.gemspec") or raise "gem build failed" + system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed" end end end From 3f276d8d76a0ef945d97c3ec603266edccc6a7c8 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Tue, 3 Dec 2024 14:15:08 +0530 Subject: [PATCH 06/18] Added pipeline for buliding hab and publish hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 117 ++++++++++++++++++++++++++ .github/workflows/habitat-publish.yml | 112 ++++++++++++++++++++++++ habitat/tests/test.ps1 | 21 +++++ habitat/tests/test.sh | 26 ++++++ 4 files changed, 276 insertions(+) create mode 100644 .github/workflows/habitat-build.yml create mode 100644 .github/workflows/habitat-publish.yml create mode 100644 habitat/tests/test.ps1 create mode 100755 habitat/tests/test.sh diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml new file mode 100644 index 000000000..620528908 --- /dev/null +++ b/.github/workflows/habitat-build.yml @@ -0,0 +1,117 @@ +name: Build Habitat packages + +on: + push: + branches: + - workstation-LTS + pull_request: + branches: + - workstation-LTS + +env: + # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. + BLDR_URL: ${{vars.BLDR_URL}} + # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. + HAB_ORIGIN: ${{vars.HAB_ORIGIN}} + # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} + # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. + HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} + # HAB_AUTH_TOKEN your orgs/projects auth token value + HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} + # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 + #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} + HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} + +permissions: + contents: write + +jobs: + pre-build: + name: Setup before building packages + runs-on: ubuntu-latest + outputs: + app_version: ${{ steps.app_version.outputs.APP_VERSION }} + steps: + - name: Get branch name + id: get_branch_name + run: | + echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" + - name: Get version from tag + id: app_version + run: | + echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" + agent-matrix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + + runs-on: ${{ matrix.os }} + # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners + # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 + # included software packages on runners are at https://github.com/actions/runner-images#available-images + # defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + # environment: unstable + steps: + - name: print OS + run: echo "--- ${{ matrix.os }}" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + + - name: install habitat on Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" + export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" + export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" + HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" + HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" + curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" + - name: run Habitat packaging (linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + hab license accept + hab origin key download $HAB_ORIGIN + hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN + echo "--- running linux hab build" + hab pkg build . + hartfile=$(ls ./results | grep "ohai" | tail -n 1) + sudo hab license accept + export CHEF_LICENSE="accept-no-persist" + export HAB_LICENSE="accept-no-persist" + export HAB_NONINTERACTIVE="true" + sudo hab pkg install ./results/$hartfile + . ./results/last_build.env + export pkg_ident + chmod +x habitat/tests/test.sh + habitat/tests/test.sh + - name: Install Habitat on Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" + $env:HAB_LICENSE = "accept-no-persist" + $env:HAB_NONINTERACTIVE = "true" + $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" + Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" + - name: run habitat packaging windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + $env:Path += ";C:\ProgramData\Habitat" + hab license accept + hab origin key download ${{ env.HAB_ORIGIN }} + hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} + write-output "--- running windows hab build" + hab pkg build . + $hartfile=(ls ./results -Name | findstr "ohai") + hab pkg install ./results/$hartfile + . ./results/last_build.ps1 + habitat/tests/test.ps1 $pkg_ident \ No newline at end of file diff --git a/.github/workflows/habitat-publish.yml b/.github/workflows/habitat-publish.yml new file mode 100644 index 000000000..956eb1321 --- /dev/null +++ b/.github/workflows/habitat-publish.yml @@ -0,0 +1,112 @@ +name: Publish Habitat packages + +on: + push: + branches: + - workstation-LTS + release: + types: + - created + +env: + # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. + BLDR_URL: ${{vars.BLDR_URL}} + # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. + HAB_ORIGIN: ${{vars.HAB_ORIGIN}} + # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} + # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. + HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} + # HAB_PACKAGE is the name of the project you are on, IE: node-management-agent + HAB_PACKAGE: ${{vars.HAB_PACKAGE}} + # HAB_AUTH_TOKEN your orgs/projects auth token value + HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} + HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} + # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 + #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} + # org-wide access token on https://github.com/organizations/progress-platform-services/settings/secrets/actions + +permissions: + contents: write + +jobs: + pre-build: + name: Setup before building packages + runs-on: ubuntu-latest + outputs: + app_version: ${{ steps.app_version.outputs.APP_VERSION }} + steps: + - name: Get branch name + id: get_branch_name + run: | + echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" + - name: Get version from tag + id: app_version + run: | + echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" + agent-matrix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + + runs-on: ${{ matrix.os }} + # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners + # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 + # included software packages on runners are at https://github.com/actions/runner-images#available-images + # environment: unstable + steps: + - name: print OS + run: echo "--- ${{ matrix.os }}" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + + - name: install habitat on Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" + export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" + HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" + HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" + export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" + curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" + - name: run Habitat packaging (linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + hab license accept + hab origin key download $HAB_ORIGIN + hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN + echo "--- running linux hab build" + hab pkg build . + echo "--- pushing to ${{ env.BLDR_URL }}/#/${{ env.HAB_ORIGIN }}/${{ env.HAB_PACKAGE }}..." + source results/last_build.env + hab pkg upload --auth $HAB_AUTH_TOKEN results/$pkg_artifact + echo "--- push complete!!" + - name: Install Habitat on Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" + $env:HAB_LICENSE = "accept-no-persist" + $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" + Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" + - name: run habitat packaging windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + $env:Path += ";C:\ProgramData\Habitat" + hab license accept + hab origin key download ${{ env.HAB_ORIGIN }} + hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} + write-output "--- running windows hab build" + hab pkg build . + write-output "--- pushing hab to unstable channel" + . results\last_build.ps1 + hab pkg upload results\$pkg_artifact --auth ${{ secrets.HAB_AUTH_TOKEN }} + write-output "--- push complete!!" \ No newline at end of file diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 new file mode 100644 index 000000000..cce3cd444 --- /dev/null +++ b/habitat/tests/test.ps1 @@ -0,0 +1,21 @@ +param ( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") +) + + +Write-Host "--- :fire: Smokish test" +# Pester the Package +$version=hab pkg exec "${pkg_ident}" ohai -v +$actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value +$package_version=$PackageIdentifier.split("/",4)[2] + +Write-Host "package_version $package_version actual version $actual_version" +if ($package_version -eq $actual_version) +{ + Write "ohai working fine" +} +else { + Write-Error "ohai version not met expected $package_version actual version $actual_version " + throw "ohai windows pipeline not working for hab pkg" +} \ No newline at end of file diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh new file mode 100755 index 000000000..7208d9981 --- /dev/null +++ b/habitat/tests/test.sh @@ -0,0 +1,26 @@ + +set -euo pipefail + + +project_root="$(git rev-parse --show-toplevel)" + +# print error message followed by usage and exit +error () { + local message="$1" + + echo -e "\nERROR: ${message}\n" >&2 + + exit 1 +} + +[[ -n "$pkg_ident" ]] || error 'no hab package identity provided' + +package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") + +cd "${project_root}" + +echo "--- :mag_right: Testing ${pkg_ident} executables" +actual_version=$(hab pkg exec "${pkg_ident}" ohai -v | sed -E 's/.*: ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') +[[ "$package_version" = "$actual_version" ]] || error "ohai version is not the expected version. Expected '$package_version', got '$actual_version'" + + From a536b5d78c668805ae7a0bfea2d49c6ad87c8546 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 15:54:26 +0530 Subject: [PATCH 07/18] Change the pipeline to expeditor Signed-off-by: nitin sanghi --- .expeditor/build.habitat.yml | 9 ++ .../buildkite/artifact.habitat.test.ps1 | 86 +++++++++++++ .expeditor/buildkite/artifact.habitat.test.sh | 70 +++++++++++ .expeditor/config.yml | 31 ++++- .expeditor/habitat-test.pipeline.yml | 36 ++++++ .github/workflows/habitat-build.yml | 117 ------------------ .github/workflows/habitat-publish.yml | 112 ----------------- 7 files changed, 231 insertions(+), 230 deletions(-) create mode 100644 .expeditor/build.habitat.yml create mode 100755 .expeditor/buildkite/artifact.habitat.test.ps1 create mode 100755 .expeditor/buildkite/artifact.habitat.test.sh create mode 100644 .expeditor/habitat-test.pipeline.yml delete mode 100644 .github/workflows/habitat-build.yml delete mode 100644 .github/workflows/habitat-publish.yml diff --git a/.expeditor/build.habitat.yml b/.expeditor/build.habitat.yml new file mode 100644 index 000000000..72ea2567a --- /dev/null +++ b/.expeditor/build.habitat.yml @@ -0,0 +1,9 @@ +--- +origin: chef + +expeditor: + defaults: + buildkite: + retry: + automatic: + limit: 1 diff --git a/.expeditor/buildkite/artifact.habitat.test.ps1 b/.expeditor/buildkite/artifact.habitat.test.ps1 new file mode 100755 index 000000000..209c4c832 --- /dev/null +++ b/.expeditor/buildkite/artifact.habitat.test.ps1 @@ -0,0 +1,86 @@ +#!/usr/bin/env powershell + +#Requires -Version 5 +# https://stackoverflow.com/questions/9948517 +# TODO: Set-StrictMode -Version Latest +$PSDefaultParameterValues['*:ErrorAction']='Stop' +$ErrorActionPreference = 'Stop' +$env:HAB_BLDR_CHANNEL = "LTS-2024" +$env:HAB_ORIGIN = 'ci' +$env:CHEF_LICENSE = 'accept-no-persist' +$env:HAB_LICENSE = 'accept-no-persist' +$Plan = 'chef-cli' + +Write-Host "--- system details" +$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' +Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize + +Write-Host "--- Installing the version of Habitat required" + +function Stop-HabProcess { + $habProcess = Get-Process hab -ErrorAction SilentlyContinue + if ($habProcess) { + Write-Host "Stopping hab process..." + Stop-Process -Name hab -Force + } +} + +# Installing Habitat +function Install-Habitat { + Write-Host "Downloading and installing Habitat..." + Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1')) +} + +try { + hab --version +} +catch { + Set-ExecutionPolicy Bypass -Scope Process -Force + + Stop-HabProcess + + # Remove the existing hab.exe if it exists and if you have permissions + $habPath = "C:\ProgramData\Habitat\hab.exe" + if (Test-Path $habPath) { + Write-Host "Attempting to remove existing hab.exe..." + Remove-Item $habPath -Force -ErrorAction SilentlyContinue + if (Test-Path $habPath) { + Write-Host "Failed to remove hab.exe, re-running script with elevated permissions." + Start-Process powershell -Verb runAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" + exit + } + } + + Install-Habitat +} +finally { + Write-Host ":habicat: I think I have the version I need to build." +} + + +Write-Host "--- Generating fake origin key" +hab origin key generate $env:HAB_ORIGIN + +Write-Host "--- Building $Plan" +$project_root = "$(git rev-parse --show-toplevel)" +Set-Location $project_root + +$env:DO_CHECK=$true; hab pkg build . + +. $project_root/results/last_build.ps1 + +Write-Host "--- Installing $pkg_ident/$pkg_artifact" +hab pkg install -b $project_root/results/$pkg_artifact + +Write-Host "+++ Testing $Plan" + +Push-Location $project_root + +try { + Write-Host "Running unit tests..." + habitat/tests/test.ps1 $pkg_ident +} +finally { + # Ensure we always return to the original directory + Pop-Location +} \ No newline at end of file diff --git a/.expeditor/buildkite/artifact.habitat.test.sh b/.expeditor/buildkite/artifact.habitat.test.sh new file mode 100755 index 000000000..fb195d1d4 --- /dev/null +++ b/.expeditor/buildkite/artifact.habitat.test.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -eo pipefail + +export HAB_ORIGIN='ci' +export PLAN='chef-cli' +export CHEF_LICENSE="accept-no-persist" +export HAB_LICENSE="accept-no-persist" +export HAB_BLDR_CHANNEL="LTS-2024" + +echo "--- checking if git is installed" +if ! command -v git &> /dev/null; then + echo "Git is not installed. Installing Git..." + sudo yum install -y git +else + echo "Git is already installed." + git --version +fi + +echo "--- add an exception for this directory since detected dubious ownership in repository at /workdir" +git config --global --add safe.directory /workdir + +echo "--- git status for this workdir" +git status + +echo "--- ruby version" +ruby -v + +export project_root="$(git rev-parse --show-toplevel)" +echo "The value for project_root is: $project_root" + +export HAB_NONINTERACTIVE=true +export HAB_NOCOLORING=true +export HAB_STUDIO_SECRET_HAB_NONINTERACTIVE=true + +echo "--- system details" +uname -a + +echo "--- Installing Habitat" +id -a +curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | bash + +echo "--- :key: Generating fake origin key" +hab origin key generate "$HAB_ORIGIN" + + +echo "--- Building $PLAN" +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 +fi +echo "+++ Installing ${pkg_ident:?is undefined}" +echo "++++" +echo $project_root +echo "+++" +hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}" + +echo "+++ Testing $PLAN" + +PATH="$(hab pkg path ci/chef-cli)/bin:$PATH" +export PATH +echo "PATH is $PATH" + +echo "--- :mag_right: Testing $PLAN" +${project_root}/habitat/tests/test.sh "$pkg_ident" || error 'failures during test of executables' \ No newline at end of file diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 417289fc0..e0bf063ab 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -27,6 +27,8 @@ github: release_branches: - main: version_constraint: 19.* + - workstation-LTS: + version_constraint: 19.* - 18-stable: version_constraint: 18.* - 17-stable: @@ -36,7 +38,22 @@ release_branches: changelog: rollup_header: Changes not yet released to rubygems.org - +pipelines: + - habitat/publish: + description: Create artiface and publish on BLDR + definition: .expeditor/build.habitat.yml + env: + - HAB_NONINTERACTIVE: "true" + - HAB_NOCOLORING: "true" + - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" + - habitat/build-test: + description: Execute tests against the habitat artifact + definition: .expeditor/habitat-test.pipeline.yml + env: + - HAB_NONINTERACTIVE: "true" + - HAB_NOCOLORING: "true" + - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" + trigger: pull_request subscriptions: # These actions are taken, in order they are specified, anytime a Pull Request is merged. - workload: pull_request_merged:{{github_repo}}:{{release_branch}}:* @@ -53,8 +70,20 @@ subscriptions: - "Expeditor: Skip All" - built_in:build_gem: only_if: built_in:bump_version + - trigger_pipeline:habitat/publish: + ignore_labels: + - "Expeditor: Skip Habitat" + - "Expeditor: Skip All" + - trigger_pipeline:habitat/build-test: + ignore_labels: + - "Expeditor: Skip Habitat" + - "Expeditor: Skip All" - workload: project_promoted:{{agent_id}}:* actions: - built_in:rollover_changelog - built_in:publish_rubygems + - workload: buildkite_hab_build_group_published:{{agent_id}}:* + actions: + # when all of the hab package publish to the unstable channel, test and promote them + - trigger_pipeline:habitat/publish \ No newline at end of file diff --git a/.expeditor/habitat-test.pipeline.yml b/.expeditor/habitat-test.pipeline.yml new file mode 100644 index 000000000..a86366933 --- /dev/null +++ b/.expeditor/habitat-test.pipeline.yml @@ -0,0 +1,36 @@ +--- +expeditor: + defaults: + buildkite: + timeout_in_minutes: 30 + retry: + automatic: + limit: 1 + + +steps: + + - label: ":linux: Validate Habitat Builds of Chef-cli" + commands: + - .expeditor/buildkite/artifact.habitat.test.sh + expeditor: + executor: + docker: + image: ruby:3.1 + privileged: true + + - label: ":windows: Validate Habitat Builds of Test Kitchen" + commands: + - .expeditor/buildkite/artifact.habitat.test.ps1 + expeditor: + executor: + docker: + host_os: windows + shell: ["powershell", "-Command"] + image: rubydistros/windows-2019:3.1 + user: 'NT AUTHORITY\SYSTEM' + environment: + - FORCE_FFI_YAJL=ext + - EXPIRE_CACHE=true + - CHEF_LICENSE=accept-no-persist + - CHEF_LICENSE_SERVER=http://hosted-license-service-lb-8000-606952349.us-west-2.elb.amazonaws.com:8000/ diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml deleted file mode 100644 index 620528908..000000000 --- a/.github/workflows/habitat-build.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Build Habitat packages - -on: - push: - branches: - - workstation-LTS - pull_request: - branches: - - workstation-LTS - -env: - # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. - BLDR_URL: ${{vars.BLDR_URL}} - # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. - HAB_ORIGIN: ${{vars.HAB_ORIGIN}} - # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} - # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. - HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} - # HAB_AUTH_TOKEN your orgs/projects auth token value - HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} - # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 - #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} - HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} - -permissions: - contents: write - -jobs: - pre-build: - name: Setup before building packages - runs-on: ubuntu-latest - outputs: - app_version: ${{ steps.app_version.outputs.APP_VERSION }} - steps: - - name: Get branch name - id: get_branch_name - run: | - echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" - - name: Get version from tag - id: app_version - run: | - echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" - agent-matrix: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs - - runs-on: ${{ matrix.os }} - # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners - # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 - # included software packages on runners are at https://github.com/actions/runner-images#available-images - # defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - # environment: unstable - steps: - - name: print OS - run: echo "--- ${{ matrix.os }}" - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - - name: install habitat on Linux - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" - export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" - export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" - HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" - HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" - curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - - name: run Habitat packaging (linux) - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - hab license accept - hab origin key download $HAB_ORIGIN - hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN - echo "--- running linux hab build" - hab pkg build . - hartfile=$(ls ./results | grep "ohai" | tail -n 1) - sudo hab license accept - export CHEF_LICENSE="accept-no-persist" - export HAB_LICENSE="accept-no-persist" - export HAB_NONINTERACTIVE="true" - sudo hab pkg install ./results/$hartfile - . ./results/last_build.env - export pkg_ident - chmod +x habitat/tests/test.sh - habitat/tests/test.sh - - name: Install Habitat on Windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" - $env:HAB_LICENSE = "accept-no-persist" - $env:HAB_NONINTERACTIVE = "true" - $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" - Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" - - name: run habitat packaging windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - $env:Path += ";C:\ProgramData\Habitat" - hab license accept - hab origin key download ${{ env.HAB_ORIGIN }} - hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} - write-output "--- running windows hab build" - hab pkg build . - $hartfile=(ls ./results -Name | findstr "ohai") - hab pkg install ./results/$hartfile - . ./results/last_build.ps1 - habitat/tests/test.ps1 $pkg_ident \ No newline at end of file diff --git a/.github/workflows/habitat-publish.yml b/.github/workflows/habitat-publish.yml deleted file mode 100644 index 956eb1321..000000000 --- a/.github/workflows/habitat-publish.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Publish Habitat packages - -on: - push: - branches: - - workstation-LTS - release: - types: - - created - -env: - # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. - BLDR_URL: ${{vars.BLDR_URL}} - # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. - HAB_ORIGIN: ${{vars.HAB_ORIGIN}} - # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} - # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. - HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} - # HAB_PACKAGE is the name of the project you are on, IE: node-management-agent - HAB_PACKAGE: ${{vars.HAB_PACKAGE}} - # HAB_AUTH_TOKEN your orgs/projects auth token value - HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} - HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} - # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 - #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} - # org-wide access token on https://github.com/organizations/progress-platform-services/settings/secrets/actions - -permissions: - contents: write - -jobs: - pre-build: - name: Setup before building packages - runs-on: ubuntu-latest - outputs: - app_version: ${{ steps.app_version.outputs.APP_VERSION }} - steps: - - name: Get branch name - id: get_branch_name - run: | - echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" - - name: Get version from tag - id: app_version - run: | - echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" - agent-matrix: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs - - runs-on: ${{ matrix.os }} - # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners - # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 - # included software packages on runners are at https://github.com/actions/runner-images#available-images - # environment: unstable - steps: - - name: print OS - run: echo "--- ${{ matrix.os }}" - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - - name: install habitat on Linux - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" - export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" - HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" - HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" - export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" - curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - - name: run Habitat packaging (linux) - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - hab license accept - hab origin key download $HAB_ORIGIN - hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN - echo "--- running linux hab build" - hab pkg build . - echo "--- pushing to ${{ env.BLDR_URL }}/#/${{ env.HAB_ORIGIN }}/${{ env.HAB_PACKAGE }}..." - source results/last_build.env - hab pkg upload --auth $HAB_AUTH_TOKEN results/$pkg_artifact - echo "--- push complete!!" - - name: Install Habitat on Windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" - $env:HAB_LICENSE = "accept-no-persist" - $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" - Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" - - name: run habitat packaging windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - $env:Path += ";C:\ProgramData\Habitat" - hab license accept - hab origin key download ${{ env.HAB_ORIGIN }} - hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} - write-output "--- running windows hab build" - hab pkg build . - write-output "--- pushing hab to unstable channel" - . results\last_build.ps1 - hab pkg upload results\$pkg_artifact --auth ${{ secrets.HAB_AUTH_TOKEN }} - write-output "--- push complete!!" \ No newline at end of file From c9933d820272be447db2feee540085b961bb8deb Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 15:59:52 +0530 Subject: [PATCH 08/18] Testing pipeline Signed-off-by: nitin sanghi --- habitat/tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 7208d9981..52f9461fd 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -3,7 +3,7 @@ set -euo pipefail project_root="$(git rev-parse --show-toplevel)" - +pkg_ident="$1" # print error message followed by usage and exit error () { local message="$1" From 48aaf6a324417869ec3e1bd86dbd17bc589af411 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 16:09:57 +0530 Subject: [PATCH 09/18] Testing pipeline Signed-off-by: nitin sanghi --- .expeditor/buildkite/artifact.habitat.test.ps1 | 2 +- .expeditor/buildkite/artifact.habitat.test.sh | 4 ++-- .expeditor/habitat-test.pipeline.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.expeditor/buildkite/artifact.habitat.test.ps1 b/.expeditor/buildkite/artifact.habitat.test.ps1 index 209c4c832..61e95d222 100755 --- a/.expeditor/buildkite/artifact.habitat.test.ps1 +++ b/.expeditor/buildkite/artifact.habitat.test.ps1 @@ -9,7 +9,7 @@ $env:HAB_BLDR_CHANNEL = "LTS-2024" $env:HAB_ORIGIN = 'ci' $env:CHEF_LICENSE = 'accept-no-persist' $env:HAB_LICENSE = 'accept-no-persist' -$Plan = 'chef-cli' +$Plan = 'ohai' Write-Host "--- system details" $Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' diff --git a/.expeditor/buildkite/artifact.habitat.test.sh b/.expeditor/buildkite/artifact.habitat.test.sh index fb195d1d4..021c715f3 100755 --- a/.expeditor/buildkite/artifact.habitat.test.sh +++ b/.expeditor/buildkite/artifact.habitat.test.sh @@ -3,7 +3,7 @@ set -eo pipefail export HAB_ORIGIN='ci' -export PLAN='chef-cli' +export PLAN='ohai' export CHEF_LICENSE="accept-no-persist" export HAB_LICENSE="accept-no-persist" export HAB_BLDR_CHANNEL="LTS-2024" @@ -62,7 +62,7 @@ hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is und echo "+++ Testing $PLAN" -PATH="$(hab pkg path ci/chef-cli)/bin:$PATH" +PATH="$(hab pkg path ci/ohai)/bin:$PATH" export PATH echo "PATH is $PATH" diff --git a/.expeditor/habitat-test.pipeline.yml b/.expeditor/habitat-test.pipeline.yml index a86366933..12a3d1922 100644 --- a/.expeditor/habitat-test.pipeline.yml +++ b/.expeditor/habitat-test.pipeline.yml @@ -10,7 +10,7 @@ expeditor: steps: - - label: ":linux: Validate Habitat Builds of Chef-cli" + - label: ":linux: Validate Habitat Builds of ohai" commands: - .expeditor/buildkite/artifact.habitat.test.sh expeditor: @@ -19,7 +19,7 @@ steps: image: ruby:3.1 privileged: true - - label: ":windows: Validate Habitat Builds of Test Kitchen" + - label: ":windows: Validate Habitat Builds of ohai" commands: - .expeditor/buildkite/artifact.habitat.test.ps1 expeditor: From 299868a6268bd481be561de6596b998a46c66aa6 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 16:12:29 +0530 Subject: [PATCH 10/18] Publish hab on merge Signed-off-by: nitin sanghi --- .expeditor/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index e0bf063ab..9d8967553 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -71,6 +71,7 @@ subscriptions: - built_in:build_gem: only_if: built_in:bump_version - trigger_pipeline:habitat/publish: + only_if: built_in:bump_version ignore_labels: - "Expeditor: Skip Habitat" - "Expeditor: Skip All" From ea7d6dbfce56f61e553f74764bf4f23de1c8cb41 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 16:27:35 +0530 Subject: [PATCH 11/18] Remove pipeline cofing Signed-off-by: nitin sanghi --- .expeditor/config.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 9d8967553..4518a3e53 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -38,22 +38,7 @@ release_branches: changelog: rollup_header: Changes not yet released to rubygems.org -pipelines: - - habitat/publish: - description: Create artiface and publish on BLDR - definition: .expeditor/build.habitat.yml - env: - - HAB_NONINTERACTIVE: "true" - - HAB_NOCOLORING: "true" - - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" - - habitat/build-test: - description: Execute tests against the habitat artifact - definition: .expeditor/habitat-test.pipeline.yml - env: - - HAB_NONINTERACTIVE: "true" - - HAB_NOCOLORING: "true" - - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" - trigger: pull_request + subscriptions: # These actions are taken, in order they are specified, anytime a Pull Request is merged. - workload: pull_request_merged:{{github_repo}}:{{release_branch}}:* @@ -76,6 +61,7 @@ subscriptions: - "Expeditor: Skip Habitat" - "Expeditor: Skip All" - trigger_pipeline:habitat/build-test: + only_if: built_in:bump_version ignore_labels: - "Expeditor: Skip Habitat" - "Expeditor: Skip All" From fc1d14dd07b477ea04746547c59fecbe6bc7464f Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 16:46:16 +0530 Subject: [PATCH 12/18] Plan file changed Signed-off-by: nitin sanghi --- habitat/plan.sh | 132 +++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 85 deletions(-) diff --git a/habitat/plan.sh b/habitat/plan.sh index e01a51fbb..d184e3bc7 100644 --- a/habitat/plan.sh +++ b/habitat/plan.sh @@ -1,4 +1,5 @@ -_chef_client_ruby="core/ruby31" +export HAB_BLDR_CHANNEL="LTS-2024" +ruby_pkg="core/ruby3_1" pkg_name="ohai" pkg_origin="chef" pkg_maintainer="The Chef Maintainers " @@ -6,117 +7,78 @@ pkg_description="The Chef Ohai" pkg_license=('Apache-2.0') pkg_bin_dirs=( bin - vendor/bin ) pkg_build_deps=( core/make core/gcc core/git ) -pkg_deps=( - $_chef_client_ruby - core/coreutils -) +pkg_deps=(${ruby_pkg} core/coreutils) + pkg_svc_user=root -pkg_version() { - cat "${SRC_PATH}/VERSION" +do_setup_environment() { + build_line 'Setting GEM_HOME="$pkg_prefix/vendor"' + export GEM_HOME="$pkg_prefix/vendor" + + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" } +pkg_version() { + cat "$SRC_PATH/VERSION" +} do_before() { - do_default_before update_pkg_version - # We must wait until we update the pkg_version to use the pkg_version - pkg_filename="${pkg_name}-${pkg_version}.tar.gz" -} - -do_download() { - build_line "Locally creating archive of latest repository commit at ${HAB_CACHE_SRC_PATH}/${pkg_filename}" - # source is in this repo, so we're going to create an archive from the - # appropriate path within the repo and place the generated tarball in the - # location expected by do_unpack - ( cd "${SRC_PATH}" || exit_with "unable to enter hab-src directory" 1 - git archive --prefix="${pkg_name}-${pkg_version}/" --output="${HAB_CACHE_SRC_PATH}/${pkg_filename}" HEAD - ) } - -do_verify() { - build_line "Skipping checksum verification on the archive we just created." - return 0 -} - -do_setup_environment() { - push_runtime_env GEM_PATH "${pkg_prefix}/vendor" - - set_runtime_env APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH - set_runtime_env LANG "en_US.UTF-8" - set_runtime_env LC_CTYPE "en_US.UTF-8" +do_unpack() { + mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname" + cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" } +do_build() { -do_prepare() { - export GEM_HOME="${pkg_prefix}/vendor" - export CPPFLAGS="${CPPFLAGS} ${CFLAGS}" + export GEM_HOME="$pkg_prefix/vendor" - ( cd "$CACHE_PATH" - bundle config --local jobs "$(nproc)" - bundle config --local without server docgen maintenance pry travis integration ci - bundle config --local shebang "$(pkg_path_for "$_chef_client_ruby")/bin/ruby" + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" + bundle config --local without integration deploy maintenance + bundle config --local jobs 4 bundle config --local retry 5 bundle config --local silence_root_warning 1 - ) - - build_line "Setting link for /usr/bin/env to 'coreutils'" - if [ ! -f /usr/bin/env ]; then - ln -s "$(pkg_interpreter_for core/coreutils bin/env)" /usr/bin/env - fi -} - -do_build() { - ( cd "$CACHE_PATH" || exit_with "unable to enter hab-cache directory" 1 - build_line "Installing gem dependencies ..." - bundle install --jobs=3 --retry=3 - build_line "Installing gems from git repos properly ..." + bundle install ruby ./post-bundle-install.rb - build_line "Installing this project's gems ..." - bundle exec rake install:local - ) + gem build ohai.gemspec } - do_install() { - ( cd "$pkg_prefix" || exit_with "unable to enter pkg prefix directory" 1 - export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" - build_line "** fixing binstub shebangs" - fix_interpreter "${pkg_prefix}/vendor/bin/*" "$_chef_client_ruby" bin/ruby - export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" - for gem in ohai; do - build_line "** generating binstubs for $gem with precise version pins" - appbundler $CACHE_PATH $pkg_prefix/bin $gem - done - ) + export GEM_HOME="$pkg_prefix/vendor" + + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" + gem install ohai-*.gem --no-document + set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor" + wrap_ruby_bin } +wrap_ruby_bin() { + local bin="$pkg_prefix/bin/$pkg_name" + local real_bin="$GEM_HOME/gems/ohai-${pkg_version}/bin/ohai" + build_line "Adding wrapper $bin to $real_bin" + cat < "$bin" +#!$(pkg_path_for core/bash)/bin/bash +set -e -do_after() { - build_line "Trimming the fat ..." +# Set binary path that allows Ohai to use non-Hab pkg binaries +export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH" - # We don't need the cache of downloaded .gem files ... - rm -r "$pkg_prefix/vendor/cache" - # ... or bundler's cache of git-ref'd gems - rm -r "$pkg_prefix/vendor/bundler" - # We don't need the gem docs. - rm -r "$pkg_prefix/vendor/doc" - # We don't need to ship the test suites for every gem dependency, - # only Chef's for package verification. - find "$pkg_prefix/vendor/gems" -name spec -type d | grep -v "ohai-${pkg_version}" \ - | while read spec_dir; do rm -r "$spec_dir"; done -} +# Set Ruby paths defined from 'do_setup_environment()' + export GEM_HOME="$pkg_prefix/vendor" + export GEM_PATH="$GEM_PATH" -do_end() { - if [ "$(readlink /usr/bin/env)" = "$(pkg_interpreter_for core/coreutils bin/env)" ]; then - build_line "Removing the symlink we created for '/usr/bin/env'" - rm /usr/bin/env - fi +exec $(pkg_path_for ${ruby_pkg})/bin/ruby $real_bin \$@ +EOF + chmod -v 755 "$bin" } + do_strip() { return 0 } \ No newline at end of file From 48caaf128fed402552af24c497fb571fd9345e6d Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 17:01:30 +0530 Subject: [PATCH 13/18] Publish test pipeline Signed-off-by: nitin sanghi --- habitat/tests/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 52f9461fd..ed2519714 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -24,3 +24,4 @@ actual_version=$(hab pkg exec "${pkg_ident}" ohai -v | sed -E 's/.*: ([0-9]+\.[0 [[ "$package_version" = "$actual_version" ]] || error "ohai version is not the expected version. Expected '$package_version', got '$actual_version'" + From a2a47e5ae1efd3261b2a6b2c93061bf319132814 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Fri, 6 Dec 2024 17:11:49 +0530 Subject: [PATCH 14/18] Publish pipeline change Signed-off-by: nitin sanghi --- .expeditor/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 4518a3e53..093b08cd4 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -73,4 +73,4 @@ subscriptions: - workload: buildkite_hab_build_group_published:{{agent_id}}:* actions: # when all of the hab package publish to the unstable channel, test and promote them - - trigger_pipeline:habitat/publish \ No newline at end of file + - trigger_pipeline:habitat/build-test \ No newline at end of file From 3f8183ae318a15b68cc7cb8dd3368b21cdf35c52 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Tue, 17 Dec 2024 15:52:22 +0530 Subject: [PATCH 15/18] Adding dev channel publish hab channel Signed-off-by: nitin sanghi --- .expeditor/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 093b08cd4..17fafbcbf 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -8,6 +8,8 @@ slack: # This publish is triggered by the `built_in:publish_rubygems` artifact_action. rubygems: - ohai +artifact_channels: + - dev github: # This deletes the GitHub PR branch after successfully merged into the release branch @@ -73,4 +75,5 @@ subscriptions: - workload: buildkite_hab_build_group_published:{{agent_id}}:* actions: # when all of the hab package publish to the unstable channel, test and promote them - - trigger_pipeline:habitat/build-test \ No newline at end of file + - trigger_pipeline:habitat/build-test + - built_in:promote_habitat_packages From 002cd0649a549b880b0753a529b116e6387be093 Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Thu, 19 Dec 2024 14:17:35 +0530 Subject: [PATCH 16/18] adding branch to github Signed-off-by: nikhil2611 From b891d7354ef05d1e268784a0e5baf194b0a61a70 Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Thu, 19 Dec 2024 14:27:43 +0530 Subject: [PATCH 17/18] checking agents creation Signed-off-by: nikhil2611 --- .expeditor/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index cebe00737..91edb4b51 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -21,6 +21,7 @@ github: major_bump_labels: - "Expeditor: Bump Version Major" + # Which Github branches to build Omnibus releases from, and what versions # (as determined by the value in the VERSION file) those branches are responsible # for building. From cf578230b856cbcd2de3d2090b22f2a71b51402d Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Thu, 19 Dec 2024 14:33:47 +0530 Subject: [PATCH 18/18] checking agents creation Signed-off-by: nikhil2611 --- .expeditor/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 91edb4b51..bcfdc8c67 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -5,6 +5,7 @@ slack: notify_channel: chef-infra-notify + # This publish is triggered by the `built_in:publish_rubygems` artifact_action. rubygems: - ohai