Skip to content

Commit

Permalink
Make GitHub actions output of setup step more readable
Browse files Browse the repository at this point in the history
Use groups to wrap parts of the steps
  • Loading branch information
Flamefire committed Dec 27, 2024
1 parent 065e896 commit e5cab25
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
27 changes: 24 additions & 3 deletions ci/common_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,20 @@ set -ex

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

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

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,6 +83,7 @@ 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::"

# Deduce B2_TOOLSET if unset from B2_COMPILER
if [ -z "$B2_TOOLSET" ] && [ -n "$B2_COMPILER" ]; then
Expand Down Expand Up @@ -121,9 +134,10 @@ if [[ "$B2_TOOLSET" == clang* ]]; then
fi

# Setup ccache
print_on_gha "::group::Setup CCache"
if [ "$B2_USE_CCACHE" == "1" ]; then
if ! "$CI_DIR"/setup_ccache.sh 2>&1; then
set +x
{ set +x; } &> /dev/null
echo
printf '=%.0s' {1..120}
echo
Expand All @@ -133,10 +147,14 @@ if [ "$B2_USE_CCACHE" == "1" ]; then
echo
echo
B2_USE_CCACHE=0
print_on_gha "::error title=CCache::CCache disabled due to an error!"
set -x
fi
print_on_gha "::error title=CCache::CCache22 disabled due to an error!"
fi
print_on_gha "::endgroup::"

print_on_gha "::group::Setup B2"
# Set up user-config to actually use B2_COMPILER if set
if [ -n "$B2_COMPILER" ]; then
# Get C++ compiler
Expand All @@ -152,7 +170,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 +201,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 +225,5 @@ if [[ "$B2_DONT_BOOTSTRAP" != "1" ]]; then
fi
trap - ERR
${B2_WRAPPER} ./b2 -d0 headers
print_on_gha "::endgroup::"
fi
10 changes: 9 additions & 1 deletion ci/setup_ccache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
#
# Installs and sets up ccache

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

function print_on_gha {
if [[ "${GITHUB_ACTIONS:-false}" == "true" ]]; then
echo "$@"
fi
} 2> /dev/null

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,6 +33,7 @@ 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
Expand Down

0 comments on commit e5cab25

Please sign in to comment.