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

GHA: Cache boost checkout #241

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ jobs:
BDDE_ARCH: ${{matrix.arch}}
run: ci/github/setup_bdde.sh

- name: Cache Boost checkout
uses: actions/cache@v4
with:
path: boost-root
key: boost-checkout-cache-${{matrix.os}}-${{matrix.container}}-${{github.sha}}
restore-keys: boost-checkout-cache-${{matrix.os}}-${{matrix.container}}-

- name: Setup Boost
env:
B2_ADDRESS_MODEL: ${{matrix.address-model}}
Expand Down Expand Up @@ -272,6 +279,10 @@ jobs:
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

- name: Prepare for cache
if: ${{ env.BOOST_ROOT_CACHE != '' }}
run: rm -rf boost-root; mv "${BOOST_ROOT_CACHE}" boost-root
working-directory: ${{github.workspace}}
windows:
defaults:
run:
Expand Down
10 changes: 9 additions & 1 deletion ci/common_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ else
export BOOST_BRANCH="develop"
fi

# CI cache might have restored the boost-root folder in the current directory
[ ! -d boost-root ] || mv boost-root ..
cd ..

if [ ! -d boost-root ]; then
Expand Down Expand Up @@ -176,9 +178,10 @@ if [[ "$B2_DONT_BOOTSTRAP" != "1" ]]; then
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.
if [ ! -f b2 ] || ! b2_version_output=$(./b2 --version); then
if [ ! -f b2 ]; then
${B2_WRAPPER} ./bootstrap.sh
else
b2_version_output=$(./b2 --version)
# b2 expects versions to match
engineversion=$(echo "$b2_version_output" | tr -s ' ' | cut -d' ' -f2 | cut -d'-' -f1)
enginemajorversion=$(echo "${engineversion}" | cut -d'.' -f1)
Expand All @@ -188,6 +191,11 @@ if [[ "$B2_DONT_BOOTSTRAP" != "1" ]]; then
if [[ "${enginemajorversion}" == "${coremajorversion}" ]] && [[ "${engineminorversion}" == "${coreminorversion}" ]]; then
echo "b2 already exists and has the same version number"
else
if [[ "$engineversion" =~ ^[0-9]\.[0-9]\. ]]; then
echo "b2 binary version: $enginemajorversion:$engineminorversion vs source version $coremajorversion:$coreminorversion"
else
echo "Unable to extract B2 version from $b2_version_output"
fi
${B2_WRAPPER} ./bootstrap.sh
fi
fi
Expand Down
5 changes: 5 additions & 0 deletions ci/github/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ fi

. $(dirname "${BASH_SOURCE[0]}")/../common_install.sh

# Save the state before building anything to avoid caching build artefacts
BOOST_ROOT_CACHE="${BOOST_ROOT}-for-cache"
echo "BOOST_ROOT_CACHE=$BOOST_ROOT_CACHE" >> $GITHUB_ENV
cp -r "$BOOST_ROOT" "$BOOST_ROOT_CACHE"

# Persist the environment for all future steps

# Set by common_install.sh
Expand Down
Loading