Skip to content

Commit

Permalink
Split linuxbrew testing out of homebrew test script (chapel-lang#25721)
Browse files Browse the repository at this point in the history
This moves the portion of our homebrew testing that checks homebrew on
linux and performs the same/similar checks as homebrew's CI into its own
test. Previously one homebrew script was responsible for testing both a
local homebrew installation and the linuxbrew installation using docker.
Because the only machines we had for testing were ARM macs, the x86
based docker image that homebrew uses for linuxbrew CI testing was
encountering issues ranging from extra output messages to segfaults.

This separation allows us to specify an x86 based machine be used for
doing the linuxbrew testing while still testing our homebrew install on
ARM macs.

In the process, refactored some common functionality into a helper which
should be usable by any test that needs to create a tarball.

requires a companion change to CI in
https://github.hpe.com/hpe/hpc-chapel-ci-config/pull/1261/ - merged!

[reviewed by @riftEmber - thanks!]
  • Loading branch information
arezaii authored Aug 22, 2024
2 parents b85b1b6 + 4f23623 commit 3b13bda
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 53 deletions.
23 changes: 23 additions & 0 deletions util/cron/common-tarball.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
source $CWD/common.bash

export CHPL_HOME=$(cd $CWD/../.. ; pwd)
log_info "Setting CHPL_HOME to: ${CHPL_HOME}"

source ${CHPL_HOME}/util/build_configs/functions.bash

major=$(get_src_major_version ${CHPL_HOME})
minor=$(get_src_minor_version ${CHPL_HOME})
patch=$(get_src_patch_version ${CHPL_HOME})
sha=$(git rev-parse --short HEAD)

short_version="${major}.${minor}"
version="${short_version}.${patch}.${sha}"

function gen_release()
{
local version=$@
log_info "Building tarball with version: ${version}"
./util/buildRelease/gen_release ${version}
}
19 changes: 3 additions & 16 deletions util/cron/create_tarball.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# The tarball is left in root of repo in tar/ directory.

CWD=$(cd $(dirname $0) ; pwd)
source $CWD/common.bash
source $CWD/functions.bash

source $CWD/common-tarball.bash

# Tell gen_release to use existing repo instead of creating a new one with
# git-archive.
Expand All @@ -18,17 +18,4 @@ log_info "Setting CHPL_HOME to: ${CHPL_HOME}"

export CHPL_LLVM=none

source ${CHPL_HOME}/util/build_configs/functions.bash
major=$(get_src_major_version ${CHPL_HOME})
minor=$(get_src_minor_version ${CHPL_HOME})
patch=$(get_src_patch_version ${CHPL_HOME})
sha=$(git rev-parse --short HEAD)

short_version="${major}.${minor}"
version="${short_version}.${patch}.${sha}"

log_info "Moving to ${CHPL_HOME}"
cd $CHPL_HOME

log_info "Building tarball with version: ${version}"
./util/buildRelease/gen_release ${version}
gen_release $version
68 changes: 68 additions & 0 deletions util/cron/test-homebrew-linux.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

# This script is to test the current homebrew formula on the local repository.
# Using the Homebrew for linux CI tests and docker image.

# This script will copy the chapel formula in chapel-lang repo under
# util/packaging/home-brew,
# replace the url and sha in the chapel formula with the url pointing to the
# tarball created and sha of the tarball,
# and run home-brew test-bot commands as homebrew CI does

# Create a tarball from current repo.
# The tarball is left in root of repo in tar/ directory.
CWD=$(cd $(dirname $0) ; pwd)

# common-tarball sets CHPL_HOME
source $CWD/common-tarball.bash


# Tell gen_release to use existing repo instead of creating a new one with
# git-archive.
export CHPL_GEN_RELEASE_NO_CLONE=true

export CHPL_LLVM=none

log_info "Moving to ${CHPL_HOME}"
cd $CHPL_HOME

# This will copy the chapel formula in chapel-lang repo under util/packaging/home-brew
# replace the url and sha in the chapel formula with the url pointing to the tarball created and sha of the tarball.
# run home-brew scripts to install chapel.

# gen_release $short_version

cp ${CHPL_HOME}/util/packaging/homebrew/chapel-main.rb ${CHPL_HOME}/util/packaging/homebrew/chapel.rb
cd ${CHPL_HOME}/util/packaging/homebrew
# Get the tarball from the root tar/ directory and replace the url in chapel.rb with the tarball location
location="${CHPL_HOME}/tar/chapel-${short_version}.tar.gz"
log_info $location

# Replace the url and sha256 in chapel.rb with the location of the tarball and sha256 of the tarball generated.
# create sed -i '' -e for macOS
sed_command="sed -i '' -e"
$sed_command "s#url.*#url \"file\:///$location\"#" chapel.rb
sha=($(shasum -a 256 $location))
sha256=${sha[0]}
log_info $sha256
$sed_command "1s/sha256.*/sha256 \"$sha256\"/;t" -e "1,/sha256.*/s//sha256 \"$sha256\"/" chapel.rb

#To mimic home-brew CI. Run home-brew chpl install inside a container.
# check if docker desktop is installed, if not fail the test.
# TODO: maybe change this for linux?
source ${CHPL_HOME}/util/cron/docker.bash
start_docker
# This mimics homebrew-ci
# This will test homebrew installation inside ubuntu VM using the lastest chapel.rb using the tarball built
cd ${CHPL_HOME}/util/packaging/homebrew

# Replace the tarball location in the container where the tarball is copied over
$sed_command "s#url.*#url \"file\:////home/linuxbrew/chapel-${short_version}.tar.gz\"#" chapel.rb

cp ${CHPL_HOME}/util/packaging/homebrew/chapel.rb ${CHPL_HOME}/util/packaging/docker/test
cp $location ${CHPL_HOME}/util/packaging/docker/test

#This will start a docker container that is similar to the one used by homebrew-ci and test the homebrew installation inside it.
source ${CHPL_HOME}/util/packaging/docker/test/homebrew_ci.bash

export CHPL_NIGHTLY_TEST_CONFIG_NAME="homebrew-linux"
43 changes: 6 additions & 37 deletions util/cron/test-homebrew.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,33 @@
# replace the url and sha in the chapel formula with the url pointing to the tarball created and sha of the tarball.
# run home-brew scripts to install chapel.

# !IMPORTANT! Make sure REPO_PATH is set to where the homebrew-core repository should go
# before running this script, or it will fail on the step where it diffs the current
# formula with the copy we store in chapel-release.rb

# Create a tarball from current repo.
# The tarball is left in root of repo in tar/ directory.
CWD=$(cd $(dirname $0) ; pwd)
source $CWD/functions.bash

# common-tarball sets CHPL_HOME
source $CWD/common-tarball.bash

# Tell gen_release to use existing repo instead of creating a new one with
# git-archive.
export CHPL_GEN_RELEASE_NO_CLONE=true

export CHPL_HOME=$(cd $CWD/../.. ; pwd)
log_info "Setting CHPL_HOME to: ${CHPL_HOME}"

export CHPL_LLVM=none

source ${CHPL_HOME}/util/build_configs/functions.bash
major=$(get_src_major_version ${CHPL_HOME})
minor=$(get_src_minor_version ${CHPL_HOME})
sha=$(git rev-parse --short HEAD)

short_version="${major}.${minor}"
version="${short_version}"

log_info "Moving to ${CHPL_HOME}"
cd $CHPL_HOME

# This will copy the chapel formula in chapel-lang repo under util/packaging/home-brew
# replace the url and sha in the chapel formula with the url pointing to the tarball created and sha of the tarball.
# run home-brew scripts to install chapel.

log_info "Building tarball with version: ${version}"
./util/buildRelease/gen_release ${version}
gen_release $short_version

cp ${CHPL_HOME}/util/packaging/homebrew/chapel-main.rb ${CHPL_HOME}/util/packaging/homebrew/chapel.rb
cd ${CHPL_HOME}/util/packaging/homebrew

# Get the tarball from the root tar/ directory and replace the url in chapel.rb with the tarball location
location="${CHPL_HOME}/tar/chapel-${version}.tar.gz"
location="${CHPL_HOME}/tar/chapel-${short_version}.tar.gz"
log_info $location

# Replace the url and sha256 in chapel.rb with the location of the tarball and sha256 of the tarball generated.
Expand All @@ -62,7 +48,7 @@ $sed_command "1s/sha256.*/sha256 \"$sha256\"/;t" -e "1,/sha256.*/s//sha256 \"$s
brew upgrade
brew uninstall --force chapel
# Remove the cached chapel tar file before running brew install --build-from-source chapel.rb
rm $HOME/Library/Caches/Homebrew/downloads/*--chapel-${version}.tar.gz
rm $HOME/Library/Caches/Homebrew/downloads/*--chapel-${short_version}.tar.gz
HOMEBREW_NO_INSTALL_FROM_API=1 brew install -v --build-from-source chapel.rb
INSTALL_STATUS=$?
if [ $INSTALL_STATUS -ne 0 ]
Expand Down Expand Up @@ -101,21 +87,4 @@ chpl pidigits.chpl
log_info "./pidigits succeeded"
fi

#To mimic home-brew CI. Run home-brew chpl install inside a container.
# check if docker desktop is installed in mac if not fail the test.
source ${CHPL_HOME}/util/cron/docker.bash
start_docker
# This mimics homebrew-ci
# This will test homebrew installation inside ubuntu VM using the lastest chapel.rb using the tarball built
cd ${CHPL_HOME}/util/packaging/homebrew

# Replace the tarball location in the container where the tarball is copied over
$sed_command "s#url.*#url \"file\:////home/linuxbrew/chapel-${version}.tar.gz\"#" chapel.rb

cp ${CHPL_HOME}/util/packaging/homebrew/chapel.rb ${CHPL_HOME}/util/packaging/docker/test
cp $location ${CHPL_HOME}/util/packaging/docker/test

#This will start a docker container that is similar to the one used by homebrew-ci and test the homebrew installation inside it.
source ${CHPL_HOME}/util/packaging/docker/test/homebrew_ci.bash

export CHPL_NIGHTLY_TEST_CONFIG_NAME="homebrew"

0 comments on commit 3b13bda

Please sign in to comment.