diff --git a/util/cron/common-tarball.bash b/util/cron/common-tarball.bash new file mode 100644 index 000000000000..787c2175f096 --- /dev/null +++ b/util/cron/common-tarball.bash @@ -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} +} diff --git a/util/cron/create_tarball.bash b/util/cron/create_tarball.bash index 2f76231bb737..819930e23fa1 100755 --- a/util/cron/create_tarball.bash +++ b/util/cron/create_tarball.bash @@ -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. @@ -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 diff --git a/util/cron/test-homebrew-linux.bash b/util/cron/test-homebrew-linux.bash new file mode 100755 index 000000000000..088bcd7434d9 --- /dev/null +++ b/util/cron/test-homebrew-linux.bash @@ -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" diff --git a/util/cron/test-homebrew.bash b/util/cron/test-homebrew.bash index 78103e76ad06..805828236bd1 100755 --- a/util/cron/test-homebrew.bash +++ b/util/cron/test-homebrew.bash @@ -6,33 +6,19 @@ # 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 @@ -40,13 +26,13 @@ cd $CHPL_HOME # 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. @@ -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 ] @@ -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"