Skip to content

Commit b966555

Browse files
authored
Merge pull request #333 from chef/rishichawda/add-arm-builds
add arm build/upload and promotion pipeline
2 parents 2624ddf + bba1451 commit b966555

6 files changed

Lines changed: 213 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# Expeditor's built-in habitat/build does not support aarch64 targets.
3+
# This pipeline builds the aarch64-linux habitat package and uploads it
4+
# to the habitat builder (unstable channel).
5+
6+
expeditor:
7+
defaults:
8+
buildkite:
9+
timeout_in_minutes: 120
10+
retry:
11+
automatic:
12+
limit: 1
13+
14+
steps:
15+
16+
- label: ":habicat: Build aarch64-linux habitat package"
17+
commands:
18+
- sudo -E ./.expeditor/buildkite/build_hab_aarch64.sh
19+
- ./.expeditor/buildkite/upload_hab_aarch64.sh
20+
agents:
21+
queue: default-privileged-aarch64
22+
plugins:
23+
- docker#v3.5.0:
24+
image: chefes/omnibus-toolchain-ubuntu-2204:aarch64
25+
privileged: true
26+
propagate-environment: true
27+
environment:
28+
- HAB_AUTH_TOKEN
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
# Builds the aarch64-linux chef-cli habitat package.
4+
# Expeditor's built-in habitat/build pipeline does not support aarch64 targets,
5+
# so this script handles the build as part of the hab_aarch64/build pipeline.
6+
7+
set -euo pipefail
8+
9+
export HAB_ORIGIN='chef'
10+
export PLAN='chef-cli'
11+
export CHEF_LICENSE="accept-no-persist"
12+
export HAB_LICENSE="accept-no-persist"
13+
export HAB_NONINTERACTIVE="true"
14+
export HAB_BLDR_CHANNEL="base-2025"
15+
export HAB_REFRESH_CHANNEL="base-2025"
16+
17+
echo "--- :git: Checking for git"
18+
if ! command -v git &> /dev/null; then
19+
echo "Git is not installed. Installing Git..."
20+
sudo apt-get update -yq && sudo apt-get install -yq git
21+
else
22+
echo "Git is already installed."
23+
git --version
24+
fi
25+
26+
echo "--- :git: Adding safe directory exception"
27+
git config --global --add safe.directory /workdir
28+
29+
echo "--- :linux: Installing Habitat"
30+
curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | bash
31+
32+
echo "--- :key: Downloading origin keys"
33+
hab origin key download "$HAB_ORIGIN"
34+
hab origin key download "$HAB_ORIGIN" --secret
35+
36+
echo "--- :construction: Building $PLAN aarch64-linux package"
37+
hab pkg build . --refresh-channel base-2025
38+
39+
project_root="$(pwd)"
40+
source "${project_root}/results/last_build.env" || { echo "ERROR: unable to determine build details"; exit 1; }
41+
42+
echo "--- :package: Uploading artifact to Buildkite"
43+
cd "${project_root}/results"
44+
buildkite-agent artifact upload "$pkg_artifact" || { echo "ERROR: unable to upload artifact"; exit 1; }
45+
46+
echo "--- Setting CHEF_CLI_HAB_ARTIFACT_LINUX_AARCH64 metadata for buildkite agent"
47+
buildkite-agent meta-data set "CHEF_CLI_HAB_ARTIFACT_LINUX_AARCH64" "$pkg_artifact"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
# Promotes the aarch64-linux chef-cli package between
4+
# habitat channels. Expeditor's built-in promote_habitat_packages does not
5+
# support aarch64 targets, so this script handles it manually at each
6+
# promotion stage.
7+
#
8+
# Context is auto-detected from EXPEDITOR_ environment variables:
9+
# - project_promoted: uses EXPEDITOR_SOURCE_CHANNEL → EXPEDITOR_TARGET_CHANNEL
10+
# - buildkite_hab_build_group_published: defaults to unstable → current
11+
12+
set -euo pipefail
13+
14+
PKG_ORIGIN="chef"
15+
PKG_NAME="chef-cli"
16+
PKG_TARGET="aarch64-linux"
17+
18+
export HAB_LICENSE="accept-no-persist"
19+
export HAB_NONINTERACTIVE="true"
20+
21+
# Determine the package version from Expeditor environment variables.
22+
# For buildkite_hab_build_group_published, the aarch64 build is a separate
23+
# pipeline (hab_aarch64/build) that runs in parallel with habitat/build.
24+
# Both build from the same git commit so they produce the same version.
25+
# The aarch64 target is NOT in .bldr.toml so it's absent from pkg_idents;
26+
# we extract the version from the x86_64-linux ident instead.
27+
# Expeditor flattens Hash metadata keys by appending with "_" and stripping
28+
# non-word chars (\W), then uppercases the key, so:
29+
# pkg_idents["chef-cli-x86_64-linux"]
30+
# -> EXPEDITOR_PKG_IDENTS_CHEFCLIX86_64LINUX
31+
PKG_VERSION="${EXPEDITOR_PKG_VERSION:-${EXPEDITOR_PROMOTABLE:-}}"
32+
if [[ -z "$PKG_VERSION" && -n "${EXPEDITOR_PKG_IDENTS_CHEFCLIX86_64LINUX:-}" ]]; then
33+
PKG_VERSION=$(echo "${EXPEDITOR_PKG_IDENTS_CHEFCLIX86_64LINUX}" | cut -d'/' -f3)
34+
fi
35+
36+
# Determine source and target channels based on Expeditor workload context
37+
if [[ -n "${EXPEDITOR_TARGET_CHANNEL:-}" ]]; then
38+
# project_promoted workload
39+
SOURCE_CHANNEL="${EXPEDITOR_SOURCE_CHANNEL}"
40+
TARGET_CHANNEL="${EXPEDITOR_TARGET_CHANNEL}"
41+
else
42+
# buildkite_hab_build_group_published workload
43+
SOURCE_CHANNEL="unstable"
44+
TARGET_CHANNEL="current"
45+
fi
46+
47+
echo "--- Promoting ${PKG_ORIGIN}/${PKG_NAME} (${PKG_TARGET}) from ${SOURCE_CHANNEL} to ${TARGET_CHANNEL}"
48+
49+
# Use HAB_AUTH_TOKEN from the pipeline secret if available, otherwise fetch from vault
50+
if [[ -z "${HAB_AUTH_TOKEN:-}" ]]; then
51+
HAB_AUTH_TOKEN=$(vault kv get -field auth_token account/static/habitat/chef-ci)
52+
export HAB_AUTH_TOKEN
53+
fi
54+
55+
# Find the exact aarch64 package ident for this version
56+
if [[ -n "$PKG_VERSION" ]]; then
57+
echo "--- Looking up ${PKG_TARGET} package for version ${PKG_VERSION}"
58+
PKG_IDENT=$(curl -sf "https://bldr.habitat.sh/v1/depot/pkgs/${PKG_ORIGIN}/${PKG_NAME}/${PKG_VERSION}/latest?target=${PKG_TARGET}" | jq -r '.ident_array | join("/")')
59+
else
60+
echo "WARNING: No version info available. Skipping aarch64 promotion."
61+
exit 0
62+
fi
63+
64+
if [[ -z "$PKG_IDENT" || "$PKG_IDENT" == "null" ]]; then
65+
echo "WARNING: No ${PKG_TARGET} package found for version ${PKG_VERSION}. Skipping promotion."
66+
exit 0
67+
fi
68+
69+
echo "--- Found package: ${PKG_IDENT}"
70+
echo "--- Promoting ${PKG_IDENT} to ${TARGET_CHANNEL} channel"
71+
72+
hab pkg promote "${PKG_IDENT}" "${TARGET_CHANNEL}" "${PKG_TARGET}"
73+
74+
echo "--- Successfully promoted ${PKG_IDENT} (${PKG_TARGET}) to ${TARGET_CHANNEL}"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Uploads the aarch64-linux habitat package to the habitat builder.
4+
# Expeditor's built-in habitat/build pipeline does not support aarch64 targets,
5+
# so this script handles the upload as part of the build pipeline.
6+
7+
set -euo pipefail
8+
9+
export HAB_ORIGIN='chef'
10+
export CHEF_LICENSE="accept-no-persist"
11+
export HAB_LICENSE="accept-no-persist"
12+
export HAB_NONINTERACTIVE="true"
13+
14+
error () {
15+
local message="$1"
16+
echo -e "\nERROR: ${message}\n" >&2
17+
exit 1
18+
}
19+
20+
echo "--- Downloading aarch64 package artifact"
21+
PKG_ARTIFACT=$(buildkite-agent meta-data get "CHEF_CLI_HAB_ARTIFACT_LINUX_AARCH64")
22+
buildkite-agent artifact download "$PKG_ARTIFACT" . || error 'unable to download aarch64 artifact'
23+
24+
echo "--- :habicat: Uploading aarch64 package to habitat builder (unstable channel)"
25+
hab pkg upload "$PKG_ARTIFACT" --auth "$HAB_AUTH_TOKEN" --channel unstable || error 'unable to upload aarch64 package to habitat builder'

.expeditor/config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ pipelines:
4343
- HAB_NONINTERACTIVE: "true"
4444
- HAB_NOCOLORING: "true"
4545
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
46+
- hab_aarch64/build:
47+
description: Build and upload aarch64-linux habitat package
48+
definition: .expeditor/build.habitat.aarch64.pipeline.yml
4649
- habitat/test:
4750
public: true
4851
description: Execute tests against the habitat artifact
@@ -52,6 +55,9 @@ pipelines:
5255
- HAB_NOCOLORING: "true"
5356
- HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true"
5457
trigger: pull_request
58+
- promote_hab_aarch64:
59+
description: Promote aarch64-linux habitat package between channels
60+
definition: .expeditor/promote.habitat.aarch64.pipeline.yml
5561

5662
subscriptions:
5763
# These actions are taken, in order they are specified, anytime a Pull Request is merged.
@@ -74,17 +80,24 @@ subscriptions:
7480
ignore_labels:
7581
- "Expeditor: Skip Habitat"
7682
- "Expeditor: Skip All"
83+
- trigger_pipeline:hab_aarch64/build:
84+
only_if: built_in:bump_version
85+
ignore_labels:
86+
- "Expeditor: Skip Habitat"
87+
- "Expeditor: Skip All"
7788

7889
# Automatically promote the Habitat packages from unstable to current upon successful build of habitat/build
7990
- workload: buildkite_hab_build_group_published:{{agent_id}}:*
8091
actions:
8192
- built_in:promote_habitat_packages
93+
# - trigger_pipeline:promote_hab_aarch64
8294

8395
# Promoting current to base-2025 channel
8496
# this works for symantec version promote
8597
- workload: project_promoted:{{agent_id}}:*
8698
actions:
8799
- built_in:rollover_changelog
88100
- built_in:promote_habitat_packages
101+
# - trigger_pipeline:promote_hab_aarch64
89102
- built_in:publish_rubygems
90103
- built_in:notify_chefio_slack_channels
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# Pipeline to promote the aarch64-linux chef-cli habitat
3+
# package between channels. Replaces the inline bash action so promotion runs
4+
# as a tracked Buildkite pipeline with its own logs and retry controls.
5+
#
6+
# The promote_hab_aarch64.sh script auto-detects source/target channels
7+
# from EXPEDITOR_ environment variables set by the triggering workload.
8+
9+
expeditor:
10+
defaults:
11+
buildkite:
12+
timeout_in_minutes: 10
13+
retry:
14+
automatic:
15+
limit: 1
16+
17+
steps:
18+
19+
- label: ":habicat: Promote aarch64-linux habitat package"
20+
command:
21+
- ./.expeditor/buildkite/promote_hab_aarch64.sh
22+
expeditor:
23+
secrets:
24+
HAB_AUTH_TOKEN:
25+
path: account/static/habitat/chef-ci
26+
field: auth_token

0 commit comments

Comments
 (0)