Skip to content

CHEF-37329: add Linux ARM Habitat validation in Expeditor pipeline - #347

Open
sanjain-progress wants to merge 3 commits into
mainfrom
sanjain/CHEF-37329/test_hab_pipeline
Open

CHEF-37329: add Linux ARM Habitat validation in Expeditor pipeline#347
sanjain-progress wants to merge 3 commits into
mainfrom
sanjain/CHEF-37329/test_hab_pipeline

Conversation

@sanjain-progress

Copy link
Copy Markdown
Contributor

Summary

Adds Linux ARM64 (aarch64) Habitat build validation to the chef-cli Expeditor/Buildkite pipeline.

What Changed

  • Added a new ":linux: Arm64 Validate Habitat Builds of Chef-cli" step to .expeditor/habitat-test.pipeline.yml
  • Runs on Buildkite queue default-privileged-aarch64
  • Uses the docker#v3.5.0 plugin with image ruby:3.4, privileged: true, propagate-environment: true
  • Sets BUILD_PKG_TARGET: "aarch64-linux"
  • Keeps HAB_AUTH_TOKEN propagated via the environment, consistent with the existing Linux/Windows steps

Result

Habitat package builds for chef-cli are now validated on Linux ARM64 via Buildkite/Expeditor, in addition to the existing Linux (x86_64) and Windows validation steps.

Jira

CHEF-37329

Add an Arm64 Habitat validation step to .expeditor/habitat-test.pipeline.yml using Buildkite queue default-privileged-aarch64, docker plugin (ruby:3.4), and BUILD_PKG_TARGET=aarch64-linux, keeping HAB_AUTH_TOKEN propagation consistent with the existing Linux/Windows steps.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Sachin Jain <Sachin.jain@chef.io>
@github-actions

Copy link
Copy Markdown

Simplecov Report

Covered Threshold
98.51% 90%

Introduce habitat/aarch64-linux/plan.sh, sourcing the existing habitat/plan.sh to reuse the default Linux build logic for aarch64 (ARM) targets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Sachin Jain <Sachin.jain@chef.io>
@sanjain-progress
sanjain-progress marked this pull request as ready for review July 30, 2026 07:27
@sanjain-progress
sanjain-progress requested review from a team as code owners July 30, 2026 07:27
ashiqueps
ashiqueps previously approved these changes Aug 3, 2026
nikhil2611
nikhil2611 previously approved these changes Aug 3, 2026
sanghinitin
sanghinitin previously approved these changes Aug 3, 2026
habitat/aarch64-linux/plan.sh (added earlier in this branch) reuses
habitat/plan.sh via 'source', so the same do_install/do_unpack code runs
for both x86_64-linux and aarch64-linux builds. That code referenced
paths relative to $PLAN_CONTEXT (e.g.
"${PLAN_CONTEXT}/../binstub_patch.rb"), assuming PLAN_CONTEXT always
points at habitat/.

However, Habitat sets PLAN_CONTEXT to the directory it started the build
from, not the directory of the file that's actually executing. When
building aarch64-linux, that's habitat/aarch64-linux/, one level deeper
than habitat/plan.sh's own location -- even though the code being run is
sourced from habitat/plan.sh. So "${PLAN_CONTEXT}/.." resolved to
habitat/ instead of the repo root on aarch64-linux builds, and
binstub_patch.rb / NOTICE were silently not found at that (wrong) path.

The 'sed -i ... r binstub_patch.rb' patch command doesn't error when its
referenced file is missing/its pattern isn't found -- it just does nothing
and still exits 0. So an aarch64-linux chef-cli build would silently ship
a binstub without the patch that pre-sets APPBUNDLER_ALLOW_RVM=true. This
leaves appbundler's own guard (which nils GEM_HOME/GEM_PATH unless that
var is already 'true') unprotected on aarch64-linux specifically, causing
Gem::MissingSpecError when chef-cli is binlinked and invoked directly
(bypassing hab pkg exec, which normally sets that var via
RUNTIME_ENVIRONMENT). This is the same bug already fixed in chef/ohai,
chef/fauxhai, chef/cookstyle, chef/berkshelf, and chef/chef-vault.

Fix: resolve the repo root from this file's own location via
BASH_SOURCE[0] (which always points at habitat/plan.sh, regardless of
which plan sourced it) instead of PLAN_CONTEXT, and use that for all
repo-root-relative paths (binstub_patch.rb, NOTICE, VERSION source copy).
This makes the path resolution correct on both x86_64-linux and
aarch64-linux. The existing bin/chef-cli wrapper is left untouched --
once the sed patch reliably applies on aarch64-linux, it works the same
way it already does on x86_64-linux.

Also hardened while in this code path (no behavior change on x86_64):
- Quoted the pkg_prefix/bin/* glob in the binstub-patching loop.
- Used "${GEM_PATH:?}" guards on the rm -rf cleanup lines so they fail
  safely instead of operating on an empty/unset path.

Verified: manually sourced habitat/plan.sh with PLAN_CONTEXT deliberately
set to a wrong/aarch64-linux-style path -- CHEF_CLI_REPO_ROOT still
resolves correctly and both binstub_patch.rb and NOTICE are found.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Sachin Jain <Sachin.jain@chef.io>
Copilot AI lite review requested due to automatic review settings August 25, 2026 19:42
@sanjain-progress

Copy link
Copy Markdown
Contributor Author

Follow-up: fixed binstub_patch.rb/NOTICE path resolution on aarch64-linux

While reviewing the aarch64-linux plan added in this branch, found that habitat/plan.sh (the shared plan reused via source by habitat/aarch64-linux/plan.sh) referenced several paths relative to $PLAN_CONTEXT, assuming it always points at habitat/.

That assumption doesn't hold: Habitat sets PLAN_CONTEXT to the directory it started the build from, which for aarch64-linux is habitat/aarch64-linux/ — one level deeper than habitat/plan.sh's own location, even though the executing code is source'd from there. This broke:

  • ${PLAN_CONTEXT}/../binstub_patch.rb (used to patch the appbundler binstub so chef-cli can be invoked directly, e.g. via hab pkg binlink, without appbundler's own guard wiping GEM_HOME/GEM_PATH)
  • ${PLAN_CONTEXT}/../NOTICE
  • ${PLAN_CONTEXT}/.. (used in do_unpack's source copy)

Since sed -i "...r <missing-file>" silently no-ops (exits 0) when the referenced file doesn't exist, this bug would have caused aarch64-linux builds of chef-cli to silently ship without the APPBUNDLER_ALLOW_RVM patch — reproducing the same Gem::MissingSpecError on direct invocation (hab pkg binlink + chef-cli) already found and fixed in chef/ohai, chef/fauxhai, chef/cookstyle, chef/berkshelf, and chef/chef-vault.

Fix (latest commit): resolve the repo root from this file's own location via BASH_SOURCE[0] instead of $PLAN_CONTEXT, since BASH_SOURCE[0] always points at habitat/plan.sh regardless of which plan sourced it. All repo-root-relative paths now use that resolved root.

Verified by manually sourcing habitat/plan.sh with PLAN_CONTEXT deliberately set to a wrong/aarch64-linux-style path — the resolved root still correctly finds both binstub_patch.rb and NOTICE.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends chef-cli’s Expeditor/Buildkite Habitat validation pipeline to also validate Habitat builds on Linux ARM64 (aarch64), complementing the existing Linux (x86_64) and Windows validation coverage.

Changes:

  • Added a new Buildkite step to run Habitat build validation on an aarch64 Buildkite queue.
  • Added a Linux aarch64 Habitat plan wrapper and adjusted the shared Linux plan to resolve the repo root reliably when sourced.
  • Hardened cleanup in the Habitat plan by guarding rm -rf with ${GEM_PATH:?}.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
habitat/plan.sh Resolve repo root via BASH_SOURCE (not PLAN_CONTEXT) and use it for copy/patch paths; tighten rm -rf safety.
habitat/aarch64-linux/plan.sh New wrapper plan to reuse the default Linux Habitat plan for aarch64 builds.
.expeditor/habitat-test.pipeline.yml Add a new Linux ARM64 Habitat validation step running on the aarch64 privileged Buildkite queue.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .expeditor/habitat-test.pipeline.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants