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: changes to configure hab test #3913

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
350dc98
Initial commit for bookself.
talktovikas Sep 17, 2024
274fa4d
Adding more cases for Habitat.
talktovikas Sep 17, 2024
76b8bef
fixing build issue in pipeline.
talktovikas Sep 17, 2024
9221c13
adding quotes in package name
talktovikas Sep 17, 2024
38d165c
seeing the pushd
talktovikas Sep 17, 2024
a85cced
adding the shell interpreter.
talktovikas Sep 17, 2024
fbe8b4d
adding test for chef-server in automate.
talktovikas Sep 19, 2024
0484d48
adding build for automate.
talktovikas Sep 20, 2024
2220c8a
My first commit.
sreepuramsudheer Sep 20, 2024
94b67d1
corrected .sh file location.
sreepuramsudheer Sep 20, 2024
6dbdb77
corrected .sh file location.
sreepuramsudheer Sep 20, 2024
7f380fc
corrected download location for buildkite artifact.
sreepuramsudheer Sep 20, 2024
84b69e5
corrected download location for buildkite artifact.
sreepuramsudheer Sep 20, 2024
0e0d7fe
refactoring code
talktovikas Sep 23, 2024
568390a
test commit for rebuild.
talktovikas Sep 23, 2024
2c9e48e
trying search and replace.
talktovikas Sep 23, 2024
591da97
fixing name of bookself.
talktovikas Sep 23, 2024
72d7386
debug log
talktovikas Sep 23, 2024
7d17250
changing the name.
talktovikas Sep 23, 2024
1e95219
initial step.
sreepuramsudheer Sep 23, 2024
08cf127
Made few changes.
sreepuramsudheer Sep 23, 2024
515bfd3
added env variables.
sreepuramsudheer Sep 23, 2024
42b2358
added hab environment setup step
sreepuramsudheer Sep 23, 2024
2a7666e
hab setup fix.
sreepuramsudheer Sep 23, 2024
9a44fe9
added script to edit plan.sh files.
sreepuramsudheer Sep 24, 2024
b7504e5
added script to edit plan.sh files.
sreepuramsudheer Sep 24, 2024
56e9925
Check results dir
kalroy Sep 24, 2024
3084da4
adding more env variables
kalroy Sep 24, 2024
2dc0e3d
Trying to run verify_build
kalroy Sep 24, 2024
9c3a318
Reverting
kalroy Sep 24, 2024
2c35993
use hab studio
kalroy Sep 24, 2024
85efaa6
hab install results pkg
kalroy Sep 24, 2024
fd63da4
changes we need to do
kalroy Sep 24, 2024
1e889ac
Trying out to build and use key
kalroy Sep 24, 2024
2b283f7
fix err
kalroy Sep 24, 2024
56fefb0
fix err
kalroy Sep 24, 2024
f7ba632
fix err
kalroy Sep 24, 2024
6183304
Check pwd
kalroy Sep 24, 2024
bddda1f
check ls
kalroy Sep 24, 2024
a9287b8
check ls
kalroy Sep 24, 2024
a1279dc
made changes to build package sequence.
sreepuramsudheer Sep 25, 2024
3b08533
changes to fix nginx build issue.
sreepuramsudheer Sep 25, 2024
73a90de
checking with cheftest origin.
sreepuramsudheer Sep 25, 2024
6076fee
Added few environment variables.
sreepuramsudheer Sep 25, 2024
68026d9
Added quotes in nginx plan.sh for build to succede.
sreepuramsudheer Sep 25, 2024
44d36d4
Made changes to build automate components.
sreepuramsudheer Sep 25, 2024
0ceb70b
Made changes to cp command to fix issue coppiend log directory.
sreepuramsudheer Sep 25, 2024
8297d2f
One last change.
sreepuramsudheer Sep 25, 2024
d8a3dd1
One last change.
sreepuramsudheer Sep 25, 2024
89174cb
Removing unnecessary artifact
kalroy Sep 26, 2024
fffa409
Removing unnecessary steps.
kalroy Sep 26, 2024
1925d82
changing automate branch to obtain build record in results.tar
talktovikas Sep 30, 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
73 changes: 73 additions & 0 deletions .expeditor/automate_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash -e

export ORIGIN=chef
export HAB_ORIGIN=chef
export HAB_LICENSE=accept-no-persist
export OCTOKIT_ACCESS_TOKEN
export CHEF_LICENSE="accept-no-persist"
export CI=true
export HAB_ORIGIN_KEYS=chef
export HAB_STUDIO_SECRET_HAB_FEAT_IGNORE_LOCAL=false
export HAB_FEAT_IGNORE_LOCAL=false
export HAB_STUDIO_HOST_ARCH=x86_64-linux
export HAB_FEAT_OFFLINE_INSTALL=true

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

for pkg_name in `echo "bookshelf chef-server-ctl oc-id oc_bifrost oc_erchef openresty-noroot"`
do
echo "generating package for $pkg_name"
hab pkg build "src/$pkg_name"
done

./.expeditor/replace.sh "nginx" "src"

echo "generating package for nginx"
openresty_hart=$(ls -1t results/chef-openresty*.hart | head -1)
HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $openresty_hart; hab pkg build src/nginx"

git clone https://github.com/chef/automate.git
cd automate
git checkout kalroy/cs_plan_changes

RESOLVED_RESULTS_DIR=$(realpath results/)
export DO_CHECK=true

cp ../results/*.hart $HAB_CACHE_KEY_PATH/* results

#cp ../results/*.hart ../results/chef*.pub ../results/chef*.key results
../.expeditor/replace.sh
bookshelf_hart=$(ls -1t results/chef-bookshelf*.hart | head -1)
chef_server_ctl_hart=$(ls -1t results/chef-chef-server-ctl*.hart | head -1)
nginx=$(ls -1t results/chef-chef-server-nginx*.hart | head -1)
oc_id=$(ls -1t results/chef-oc_id*.hart | head -1)
bifrost_hart=$(ls -1t results/chef-oc_bifrost*.hart | head -1)
erchef_hart=$(ls -1t results/chef-oc_erchef*.hart | head -1)


HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $bookshelf_hart; hab pkg build components/automate-cs-bookshelf"

HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $bifrost_hart; hab pkg build components/automate-cs-oc-bifrost"

HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $erchef_hart; hab pkg build components/automate-cs-oc-erchef"

HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $oc_id; hab pkg build components/automate-cs-ocid"

HAB_FEAT_OFFLINE_INSTALL=true HAB_FEAT_IGNORE_LOCAL=false HAB_ORIGIN=chef HAB_CACHE_KEY_PATH="$JOB_TEMP_ROOT/keys" DO_CHECK=true HAB_BLDR_CHANNEL=dev hab studio run -D "set -e; hab pkg install $nginx; hab pkg build components/automate-cs-nginx"

echo "after build" `ls -l results`

ls results/*.hart | grep -v automate | xargs rm

tar -cvf results.tar results
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=chef
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
77 changes: 77 additions & 0 deletions .expeditor/replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

DEFAULT_COMPONENTS="automate-cs-bookshelf automate-cs-nginx automate-cs-oc-bifrost automate-cs-oc-erchef automate-cs-ocid"
DEFAULT_COMPONENTS_DIR="components"
tmp_file_name=""

if [[ $# -ge 1 ]]
then
components=$1
else
components=${DEFAULT_COMPONENTS}
fi

if [[ $# -ge 2 ]]
then
components_dir="$2"
else
components_dir="${DEFAULT_COMPONENTS_DIR}"
fi

check_hart() {
formated=` echo $1 | awk -F'-' -v b=2 -v e=7 '{printf "%s %s ", $(NF-2), $(NF-3); for (i=b;i<= (NF - 4);i++) printf "%s%s", $i, (i< (NF -4) ? "-" : "\n")}'`
IFS=' ' read -r timestamp version component <<< "${formated}"
echo "timestamp $timestamp, version $version, component $component"
component1=`echo $component | tr -d "_\-\""`
export ${component1}="$component/$version/$timestamp"
}

escape_char() {
echo $1 | sed 's/\([-]\)/\\\1/g'
}

make_tmp() {
count=0
while [ -f "tmp_$count" ]
do
count=`expr $count + 1`
done
tmp_file_name="tmp_$count"
}

for hart in `ls results/*.hart`
do
check_hart $hart
done

for component in `echo "$components"`
do
plan_file="${components_dir}/$component/habitat/plan.sh"
echo "Processing $plan_file"
make_tmp
tmp_file=${tmp_file_name}
cp $plan_file "$tmp_file"
sed -n '/pkg_deps/,/)/p' < "$plan_file" | grep "/" |
while read dep
do
echo "processing $dep in $plan_file"
dep_component=`echo $dep | awk -F'/' '{print $2}' | tr -d "_\-\""`
echo "dep_component = ${dep_component}, value = ${!dep_component}"
if [[ -n "${!dep_component}" ]]
then
IFS='/' read -r CScomponent version timestamp <<< "${!dep_component}"
echo "timestamp $timestamp, version $version, component $CScomponent"
CScomponent1=`escape_char $CScomponent`
echo "sed \"/\/$CScomponent1/ s|\/$CScomponent1.*|$CScomponent1/$version/$timestamp|\""
sed -i "/pkg_deps/,/)/ s|\/$CScomponent1.*|/$CScomponent1/$version/$timestamp\"|" "${tmp_file}"
fi
done
cp $tmp_file $plan_file
rm $tmp_file
echo "=================================="
echo "file content after replace"
cat $plan_file
echo "=================================="
done

exit 0
66 changes: 28 additions & 38 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,44 +131,34 @@ steps:
- LUALIB=~/.luarocks/lib/lua/5.2
- COMPONENT=src/bookshelf

# #########################################################################
# # Pedant Tests
# #########################################################################

- label: With chef-zero
command:
- /workdir/scripts/bk_tests/bk_install.sh
- gem uninstall bundler -v '>= 2.0.1' -a
- cp scripts/bk_tests/chef_zero-Gemfile oc-chef-pedant/Gemfile
- bundle install --jobs=3 --retry=3 --path=/workdir/vendor/bundle
- cd /workdir/oc-chef-pedant
- bundle exec rake chef_zero_spec
expeditor:
executor:
docker:
image: "chefes/a1-buildkite"
environment:
- LUALIB=~/.luarocks/lib/lua/5.2
- USE_OMNIBUS_FILES=0
- PEDANT_OPTS="--skip-oc_id"
- BUNDLE_GEMFILE=/workdir/oc-chef-pedant/Gemfile

- label: With ChefFS=1
- label: automate_build
command:
- /workdir/scripts/bk_tests/bk_install.sh
- gem install bundler -v 2.2.4
- gem uninstall bundler -v '> 2.2.4' -a
- cp scripts/bk_tests/chef_zero-Gemfile oc-chef-pedant/Gemfile
- bundle install --jobs=3 --retry=3 --path=/workdir/vendor/bundle
- cd /workdir/oc-chef-pedant
- bundle exec rake chef_zero_spec
- .expeditor/automate_build.sh
env:
ALLOW_LOCAL_PACKAGES: true
HAB_STUDIO_SUP: false
HAB_NONINTERACTIVE: true
expeditor:
secrets:
HAB_STUDIO_SECRET_GITHUB_TOKEN:
account: github/chef
field: token
OPENSEARCH_ROOT_CA_PEM:
path: secret/a2/a2ha/opensearch
field: root-ca.pem
OPENSEARCH_ADMIN_PEM:
path: secret/a2/a2ha/opensearch
field: admin.pem
OPENSEARCH_ADMIN_KEY_PEM:
path: secret/a2/a2ha/opensearch
field: admin-key.pem
OPENSEARCH_NODE1_PEM:
path: secret/a2/a2ha/opensearch
field: node1.pem
OPENSEARCH_NODE1_KEY_PEM:
path: secret/a2/a2ha/opensearch
field: node1-key.pem
executor:
docker:
image: "chefes/a1-buildkite"
environment:
- LUALIB=~/.luarocks/lib/lua/5.2
- USE_OMNIBUS_FILES=0
- PEDANT_OPTS="--skip-oc_id"
- CHEF_FS=1
- BUNDLE_GEMFILE=/workdir/oc-chef-pedant/Gemfile
linux:
privileged: true

2 changes: 1 addition & 1 deletion src/nginx/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pkg_license=('Apache-2.0')
pkg_deps=(
core/curl
core/libossp-uuid
${HAB_ORIGIN:-chef}/openresty-noroot
"${HAB_ORIGIN:-chef}/openresty-noroot"
)
pkg_build_deps=()
pkg_exposes=(port ssl-port)
Expand Down
Loading