Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adding Habitat packing building mechanism in verify pipeline. #3910

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5cde95c
Initial commit for bookself.
talktovikas Sep 17, 2024
a79307a
Adding more cases for Habitat.
talktovikas Sep 17, 2024
3f1886a
fixing build issue in pipeline.
talktovikas Sep 17, 2024
b34cfd3
adding quotes in package name
talktovikas Sep 17, 2024
7b24e04
seeing the pushd
talktovikas Sep 17, 2024
5e97544
adding the shell interpreter.
talktovikas Sep 17, 2024
29cfe6f
adding test for chef-server in automate.
talktovikas Sep 19, 2024
883eb6d
adding build for automate.
talktovikas Sep 20, 2024
0703996
My first commit.
sreepuramsudheer Sep 20, 2024
c9a0f97
corrected .sh file location.
sreepuramsudheer Sep 20, 2024
9abb7d1
corrected .sh file location.
sreepuramsudheer Sep 20, 2024
6da7dab
corrected download location for buildkite artifact.
sreepuramsudheer Sep 20, 2024
4b27c2b
corrected download location for buildkite artifact.
sreepuramsudheer Sep 20, 2024
4bb9295
refactoring code
talktovikas Sep 23, 2024
217adaf
test commit for rebuild.
talktovikas Sep 23, 2024
f1500be
trying search and replace.
talktovikas Sep 23, 2024
4a76fe5
fixing name of bookself.
talktovikas Sep 23, 2024
698b211
debug log
talktovikas Sep 23, 2024
99b08ea
changing the name.
talktovikas Sep 23, 2024
09731eb
changing the origin name.
talktovikas Sep 23, 2024
bf0d89b
testing the local package.
talktovikas Sep 23, 2024
2359ef6
testX
talktovikas Sep 23, 2024
57fcc22
more test
talktovikas Sep 23, 2024
cb72ea8
New env
talktovikas Sep 23, 2024
e67cc02
new
talktovikas Sep 23, 2024
a1dc06b
djh
talktovikas Sep 23, 2024
9acb826
new
talktovikas Sep 23, 2024
9fa169f
new hab test
talktovikas Sep 24, 2024
b919481
new hab test1
talktovikas Sep 24, 2024
10c3923
new hab test2
talktovikas Sep 24, 2024
0f87987
new hab test3
talktovikas Sep 24, 2024
76f25c9
new hab test3
talktovikas Sep 24, 2024
18dc11b
new test
talktovikas Sep 24, 2024
0cf460a
new test
talktovikas Sep 24, 2024
738cf0e
hopeful
talktovikas Sep 24, 2024
f5e3112
hopeful 1
talktovikas Sep 24, 2024
a728cd1
new
talktovikas Sep 24, 2024
779c111
new 1
talktovikas Sep 24, 2024
f832f50
new 2
talktovikas Sep 24, 2024
dcf8efe
debug
talktovikas Sep 24, 2024
7dfdce5
new3
talktovikas Sep 24, 2024
1174ac6
new3
talktovikas Sep 24, 2024
fe8db73
new6
talktovikas Sep 24, 2024
333a93e
new7
talktovikas Sep 24, 2024
d29bff2
new8
talktovikas Sep 24, 2024
fdb31ab
check results folder
kalroy Sep 24, 2024
8bbd219
running build inside hab studio
kalroy Sep 25, 2024
69d9f00
trying again
kalroy Sep 25, 2024
7bb80bf
building pkg
kalroy Sep 25, 2024
0d27c13
building fro dev
kalroy Sep 25, 2024
74424af
check if plan file is not pinned
kalroy Sep 25, 2024
27a9f83
use chef instead of cheftest
kalroy Sep 25, 2024
04f43ea
trying with making ignore local false
kalroy Sep 25, 2024
80b9f6a
More places
kalroy Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .expeditor/automate_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash -e


# =======================================================CS Things=======================================================
export CHEF_SERVER_SRC='/workdir/src'
export HAB_ORIGIN=chef
export HAB_LICENSE=accept-no-persist
# export pkg_name=bookshelf
export PACKAGE_NAME=bookshelf


curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash

echo "Is there relevant keys" ` ls -l /var/lib/buildkite-agent/.hab/cache/keys/`

export JOB_TEMP_ROOT
JOB_TEMP_ROOT=$(mktemp -d /tmp/job-root-XXXXXX)
export HAB_CACHE_KEY_PATH
HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys"

echo "--- :key: Generating fake origin key"
hab license accept
hab origin key generate chef

# cd /workdir/src/bookshelf
echo "generating package for $PACKAGE_NAME"
HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH=$HAB_CACHE_KEY_PATH DO_CHECK=true hab studio run -D "hab pkg build src/$PACKAGE_NAME"
# echo "which pushd " $(which pushd)


# At this point hart file is in cs results dir.
#What about keys? Line :15
# pushd results
# pkg_name=$(ls -1t *.hart | head -1)
# popd
# echo pkg_name is $pkg_name
# buildkite-agent artifact upload results/$pkg_name

echo "pwd is " `pwd`

# =======================================================Automate Things=======================================================

export OCTOKIT_ACCESS_TOKEN
export HAB_LICENSE=accept
export CHEF_LICENSE="accept-no-persist"
export CI=true
#export HAB_ORIGIN=cheftest
export HAB_ORIGIN=chef
#export HAB_ORIGIN_KEYS=cheftest
export HAB_ORIGIN_KEYS=chef
export HAB_STUDIO_SECRET_HAB_FEAT_IGNORE_LOCAL=false
export HAB_FEAT_IGNORE_LOCAL=false


git clone https://github.com/chef/automate.git
cd automate
# git checkout vikas/cs-changes-for-pipeline
git checkout kalroy/cs_plan_changes

cp ../results/*bookshelf*.hart results/

export HAB_STUDIO_HOST_ARCH=x86_64-linux
echo "automate results directory contents" `ls -l results`

Bookself_hart_file=$(ls results/*bookshelf*.hart)
echo "Found hart file: $Bookself_hart_file"
base_name=$(basename "$Bookself_hart_file") # Get just the filename
IFS='-' read -r name comp version timestamp os <<< "${base_name%.hart}"
formatted_output="$comp/$version/$timestamp"

# plan_file="components/automate-cs-bookshelf/habitat/plan.sh"
# sed -i "s|\${vendor_origin}/bookshelf|\${vendor_origin}/${formatted_output}|g" "$plan_file"
# echo "Replaced line in $plan_file"
# sed -i "s|pkg_origin=\"chef\"|pkg_origin=\"cheftest\"|g" "$plan_file"
# # sed -i "s|pkg_origin="chef"|pkg_origin="cheftest"|g" "$plan_file"
# sed -i "s|vendor_origin=\"chef\"|vendor_origin=\"cheftest\"|g" "$plan_file"
# cat components/automate-cs-bookshelf/habitat/plan.sh
# ./scripts/verify_build.sh

# curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash

# export JOB_TEMP_ROOT
# JOB_TEMP_ROOT=$(mktemp -d /tmp/job-root-XXXXXX)
# export HAB_CACHE_KEY_PATH
# # HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys"

# HAB_CACHE_KEY_PATH=$RESOLVED_RESULTS_DIR hab origin key generate cheftest

# hab license accept
# hab origin key generate cheftest

echo "This is the current dir: " `pwd`

echo "Building the package"

echo "contents of place where key should exist" `ls -l $HAB_CACHE_KEY_PATH`

cp $HAB_CACHE_KEY_PATH/* results/

RESOLVED_RESULTS_DIR=$(realpath results/)
HAB_CACHE_KEY_PATH=$RESOLVED_RESULTS_DIR
HAB_FEAT_OFFLINE_INSTALL=true
ls $HAB_CACHE_KEY_PATH

output_string_vikas=$(echo "$Bookself_hart_file" | sed 's|results/||')
DO_CHECK=true
echo "hab pkg install results/$output_string_vikas"
# hab pkg install results/$output_string_vikas

HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH=$RESOLVED_RESULTS_DIR DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "source .studiorc; set -e; hab pkg install results/$output_string_vikas; hab pkg build components/automate-cs-bookshelf"

# hab studio enter

# echo "Building the package"
# hab build results/$Bookself_hart_file
# exit


tar -cvf results.tar results
echo "results.tar created"
gzip results.tar

buildkite-agent artifact upload results.tar.gz
32 changes: 32 additions & 0 deletions .expeditor/habitat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -e

# this script builds all the essential habitat packages for running Chef Server
# additionaly, it exports them as a local docker image

export CHEF_SERVER_SRC='/workdir/src'
export ORIGIN=cheftest
export HAB_LICENSE=accept-no-persist
# export PACKAGE_NAME=$1


curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash

export JOB_TEMP_ROOT
JOB_TEMP_ROOT=$(mktemp -d /tmp/job-root-XXXXXX)
export HAB_CACHE_KEY_PATH
HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys"

echo "--- :key: Generating fake origin key"
hab license accept
hab origin key generate

# cd /workdir/src/bookshelf
echo "generating package for $PACKAGE_NAME"
hab pkg build "src/$PACKAGE_NAME"
echo "which pushd " $(which pushd)

pushd results
pkg_name=$(ls -1t *.hart | head -1)
popd
echo pkg_name is $pkg_name
buildkite-agent artifact upload results/$pkg_name
Loading
Loading