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

Make GitHub actions output of setup step more readable #256

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 34 additions & 19 deletions ci/common_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,35 @@ set -ex

CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

. "$CI_DIR"/enforce.sh
function print_on_gha {
{ set +x; } &> /dev/null
[[ "${GITHUB_ACTIONS:-false}" != "true" ]] || echo "$@"
set -x
}

# Setup ccache
if [ "$B2_USE_CCACHE" == "1" ]; then
if ! "$CI_DIR"/setup_ccache.sh 2>&1; then
{ set +x; } &> /dev/null
echo
printf '=%.0s' {1..120}
echo
echo "Failed to install & setup ccache!"
echo "Will NOT use CCache for building."
printf '=%.0s' {1..120}
echo
echo
B2_USE_CCACHE=0
print_on_gha "::error title=CCache::CCache disabled due to an error!"
set -x
fi
fi

print_on_gha "::group::Setup B2 variables"
. "$CI_DIR"/enforce.sh 2>&1
print_on_gha "::endgroup::"

print_on_gha "::group::Checkout and setup Boost build tree"
pythonexecutable=$(get_python_executable)

if [ -z "$SELF" ]; then
Expand Down Expand Up @@ -71,7 +98,9 @@ if [[ -n "$GIT_FETCH_JOBS" ]]; then
fi

$pythonexecutable tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools "${DEPINST_ARGS[@]}" $DEPINST $SELF
print_on_gha "::endgroup::"

print_on_gha "::group::Setup B2"
# Deduce B2_TOOLSET if unset from B2_COMPILER
if [ -z "$B2_TOOLSET" ] && [ -n "$B2_COMPILER" ]; then
if [[ "$B2_COMPILER" =~ clang ]]; then
Expand Down Expand Up @@ -120,23 +149,6 @@ if [[ "$B2_TOOLSET" == clang* ]]; then
fi
fi

# Setup ccache
if [ "$B2_USE_CCACHE" == "1" ]; then
if ! "$CI_DIR"/setup_ccache.sh 2>&1; then
set +x
echo
printf '=%.0s' {1..120}
echo
echo "Failed to install & setup ccache!"
echo "Will NOT use CCache for building."
printf '=%.0s' {1..120}
echo
echo
B2_USE_CCACHE=0
set -x
fi
fi

# Set up user-config to actually use B2_COMPILER if set
if [ -n "$B2_COMPILER" ]; then
# Get C++ compiler
Expand All @@ -152,7 +164,7 @@ if [ -n "$B2_COMPILER" ]; then
exit 1
fi

set +x
{ set +x; } &> /dev/null
echo "Compiler location: $(command -v $CXX)"
if [[ "$CXX" == *"clang++"* ]] && [ -z "$GCC_TOOLCHAIN_ROOT" ]; then
# Show also information on selected GCC lib
Expand Down Expand Up @@ -183,8 +195,10 @@ function show_bootstrap_log
{
cat bootstrap.log
}
print_on_gha "::endgroup::"

if [[ "$B2_DONT_BOOTSTRAP" != "1" ]]; then
print_on_gha "::group::Bootstrap B2"
trap show_bootstrap_log ERR
# Check if b2 already exists. This would (only) happen in a caching scenario. The purpose of caching is to save time by not recompiling everything.
# The user may clear cache or delete b2 beforehand if they wish to rebuild.
Expand All @@ -205,4 +219,5 @@ if [[ "$B2_DONT_BOOTSTRAP" != "1" ]]; then
fi
trap - ERR
${B2_WRAPPER} ./b2 -d0 headers
print_on_gha "::endgroup::"
fi
50 changes: 27 additions & 23 deletions ci/github/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,30 @@ fi
# Persist the environment for all future steps

# Set by common_install.sh
echo "SELF=$SELF" >> $GITHUB_ENV
echo "BOOST_ROOT=$BOOST_ROOT" >> $GITHUB_ENV
echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV
echo "B2_COMPILER=$B2_COMPILER" >> $GITHUB_ENV
# Usually set by the env-key of the "Setup Boost" step
[ -z "$B2_CXXSTD" ] || echo "B2_CXXSTD=$B2_CXXSTD" >> $GITHUB_ENV
[ -z "$B2_JOBS" ] || echo "B2_JOBS=$B2_JOBS" >> $GITHUB_ENV
[ -z "$B2_CXXFLAGS" ] || echo "B2_CXXFLAGS=$B2_CXXFLAGS" >> $GITHUB_ENV
[ -z "$B2_DEFINES" ] || echo "B2_DEFINES=$B2_DEFINES" >> $GITHUB_ENV
[ -z "$B2_INCLUDE" ] || echo "B2_INCLUDE=$B2_INCLUDE" >> $GITHUB_ENV
[ -z "$B2_LINKFLAGS" ] || echo "B2_LINKFLAGS=$B2_LINKFLAGS" >> $GITHUB_ENV
[ -z "$B2_TESTFLAGS" ] || echo "B2_TESTFLAGS=$B2_TESTFLAGS" >> $GITHUB_ENV
[ -z "$B2_ADDRESS_MODEL" ] || echo "B2_ADDRESS_MODEL=$B2_ADDRESS_MODEL" >> $GITHUB_ENV
[ -z "$B2_LINK" ] || echo "B2_LINK=$B2_LINK" >> $GITHUB_ENV
[ -z "$B2_VISIBILITY" ] || echo "B2_VISIBILITY=$B2_VISIBILITY" >> $GITHUB_ENV
[ -z "$B2_STDLIB" ] || echo "B2_STDLIB=$B2_STDLIB" >> $GITHUB_ENV
[ -z "$B2_THREADING" ] || echo "B2_THREADING=$B2_THREADING" >> $GITHUB_ENV
[ -z "$B2_VARIANT" ] || echo "B2_VARIANT=$B2_VARIANT" >> $GITHUB_ENV
[ -z "$B2_ASAN" ] || echo "B2_ASAN=$B2_ASAN" >> $GITHUB_ENV
[ -z "$B2_TSAN" ] || echo "B2_TSAN=$B2_TSAN" >> $GITHUB_ENV
[ -z "$B2_UBSAN" ] || echo "B2_UBSAN=$B2_UBSAN" >> $GITHUB_ENV
[ -z "$B2_FLAGS" ] || echo "B2_FLAGS=$B2_FLAGS" >> $GITHUB_ENV
[ -z "$B2_TARGETS" ] || echo "B2_TARGETS=$B2_TARGETS" >> $GITHUB_ENV
{
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
echo "B2_TOOLSET=$B2_TOOLSET"
echo "B2_COMPILER=$B2_COMPILER"
# Usually set by the env-key of the "Setup Boost" step
[ -z "$B2_CXXSTD" ] || echo "B2_CXXSTD=$B2_CXXSTD"
[ -z "$B2_JOBS" ] || echo "B2_JOBS=$B2_JOBS"
[ -z "$B2_CXXFLAGS" ] || echo "B2_CXXFLAGS=$B2_CXXFLAGS"
[ -z "$B2_DEFINES" ] || echo "B2_DEFINES=$B2_DEFINES"
[ -z "$B2_INCLUDE" ] || echo "B2_INCLUDE=$B2_INCLUDE"
[ -z "$B2_LINKFLAGS" ] || echo "B2_LINKFLAGS=$B2_LINKFLAGS"
[ -z "$B2_TESTFLAGS" ] || echo "B2_TESTFLAGS=$B2_TESTFLAGS"
[ -z "$B2_ADDRESS_MODEL" ] || echo "B2_ADDRESS_MODEL=$B2_ADDRESS_MODEL"
[ -z "$B2_LINK" ] || echo "B2_LINK=$B2_LINK"
[ -z "$B2_VISIBILITY" ] || echo "B2_VISIBILITY=$B2_VISIBILITY"
[ -z "$B2_STDLIB" ] || echo "B2_STDLIB=$B2_STDLIB"
[ -z "$B2_THREADING" ] || echo "B2_THREADING=$B2_THREADING"
[ -z "$B2_VARIANT" ] || echo "B2_VARIANT=$B2_VARIANT"
[ -z "$B2_ASAN" ] || echo "B2_ASAN=$B2_ASAN"
[ -z "$B2_TSAN" ] || echo "B2_TSAN=$B2_TSAN"
[ -z "$B2_UBSAN" ] || echo "B2_UBSAN=$B2_UBSAN"
[ -z "$B2_FLAGS" ] || echo "B2_FLAGS=$B2_FLAGS"
[ -z "$B2_TARGETS" ] || echo "B2_TARGETS=$B2_TARGETS"
# Filter out (only) the conditions from set -x
# Write the stdout to the GitHub env file
} 2> >(grep -vF ' -z ' >&2) >> $GITHUB_ENV
12 changes: 9 additions & 3 deletions ci/setup_ccache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
#
# Installs and sets up ccache

{ set +x; } &> /dev/null
set -eu
set +x

function print_on_gha {
[[ "${GITHUB_ACTIONS:-false}" != "true" ]] || echo "$@"
}

if ! command -v ccache &> /dev/null; then
print_on_gha "::group::Installing CCache"
if [ -f "/etc/debian_version" ]; then
sudo apt-get install ${NET_RETRY_COUNT:+ -o Acquire::Retries=$NET_RETRY_COUNT} -y ccache
elif command -v brew &> /dev/null; then
Expand All @@ -26,16 +31,17 @@ if ! command -v ccache &> /dev/null; then
brew install ccache 2>&1
fi
fi
print_on_gha "::endgroup::"
fi

# Sanity check that CCache is installed, executable and works at all
print_on_gha "::group::Configuring CCache"
ccache --version

# This also sets the default values
echo "Using cache directory of size ${B2_CCACHE_SIZE:=500M} at '${B2_CCACHE_DIR:=$HOME/.ccache}'"


ccache --set-config=cache_dir="$B2_CCACHE_DIR"
ccache --set-config=max_size="$B2_CCACHE_SIZE"
ccache -z
echo "CCache config: $(ccache -p)"
print_on_gha "::endgroup::"
Loading