From eb052deca11195a6bacb60aae7ca08592452f18f Mon Sep 17 00:00:00 2001 From: sdarwin Date: Wed, 15 Mar 2023 09:59:45 -0600 Subject: [PATCH] drone always uses cache --- .drone.star | 5 ++--- .drone/drone.sh | 37 ++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.drone.star b/.drone.star index 0feeedf9..329b9530 100644 --- a/.drone.star +++ b/.drone.star @@ -410,7 +410,7 @@ def generate(compiler_ranges, cxx_range, max_cxx=2, coverage=True, docs=True, as if cache_dir != None and image_supports_caching(image, compiler): environment['drone_cache_mount'] = cache_dir - if image in images_used: + if image in images_used or buildtype != "boost": environment['drone_cache_rebuild'] = 'false' else: environment['drone_cache_rebuild'] = 'true' @@ -509,8 +509,7 @@ def compiler_supports(compiler, version, cxx): # This is based on an exclude-list since we want to assume # new images will support caching def image_supports_caching(image_str, compiler_str): - return image_str == None or not (image_str[:19] == 'cppalliance/dronevs' or compiler_str[:6] == 's390x-') - + return image_str != None and not (image_str[:19] == 'cppalliance/dronevs' or compiler_str[:6] == 's390x-') # Get list of available compiler versions in a semver range # - compilers_in_range('gcc >=10') -> [('gcc', '12'), ('gcc', '11'), ('gcc', '10')] diff --git a/.drone/drone.sh b/.drone/drone.sh index 21e4e60c..99e78c0e 100755 --- a/.drone/drone.sh +++ b/.drone/drone.sh @@ -70,7 +70,13 @@ common_install() { fi # Boost cache key - boost_hash=$(git ls-remote https://github.com/boostorg/boost.git $BOOST_BRANCH | awk '{ print $1 }') + # + # This key varies every few hours on an update of boost: + # boost_hash=$(git ls-remote https://github.com/boostorg/boost.git $BOOST_BRANCH | awk '{ print $1 }') + # + # This key finds the most recent git tag and will vary every few months: + boost_hash=$(git ls-remote --tags https://github.com/boostorg/boost | fgrep -v ".beta" | fgrep -v ".rc" | tail -n 1 | cut -f 1) + os_name=$(uname -s) boost_cache_key=$os_name-boost-$boost_hash @@ -106,30 +112,31 @@ common_install() { git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1 cp -prf boost-ci-cloned/ci . rm -rf boost-ci-cloned - if [ "$boost_cache_hit" != true ]; then - . ./ci/common_install.sh - if command -v rsync &>/dev/null && [ "$drone_cache_rebuild" == true ]; then - if command -v apt-get &>/dev/null; then - apt-get install -y rsync - fi - mkdir "$cache_dir"/boost - rsync -a "$BOOST_ROOT/" "$cache_dir/boost" - echo "$boost_cache_key" >"$cache_dir/boost_cache_key.txt" - fi - else + if [ "$boost_cache_hit" = true ]; then cd .. mkdir boost-root cd boost-root BOOST_ROOT="$(pwd)" export BOOST_ROOT - ls "$cache_dir/boost" if command -v apt-get &>/dev/null; then apt-get install -y rsync fi rsync -a "$cache_dir/boost/" "$BOOST_ROOT" rm -rf "$BOOST_ROOT/libs/$SELF" - rsync -a "$BOOST_CI_SRC_FOLDER/" "$BOOST_ROOT/libs/$SELF" --exclude cache - $python_executable tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools "$SELF" + mkdir "$BOOST_ROOT/libs/$SELF" + cd $DRONE_WORKSPACE + fi + . ./ci/common_install.sh + + if [ "$drone_cache_rebuild" == true ]; then + if command -v apt-get &>/dev/null; then + apt-get install -y rsync + fi + mkdir -p "$cache_dir"/boost + rsync -a --delete "$BOOST_ROOT/" "$cache_dir/boost" --exclude "$BOOST_ROOT/libs/$SELF/cache" + # and as a double measure + rm -rf $cache_dir/boost/libs/$SELF/cache + echo "$boost_cache_key" >"$cache_dir/boost_cache_key.txt" fi }