diff --git a/etc/ci/get_caching_paths.sh b/etc/ci/get_caching_paths.sh new file mode 100755 index 0000000000..8a35e8fee7 --- /dev/null +++ b/etc/ci/get_caching_paths.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# get_caching_paths.sh +# +# get the paths to be cached by Github Actions. +# paths are seperated by new lines + +sh get_submodule_paths.sh +echo '~/.cargo/bin' +echo '~/.cargo/registry/index' +echo '~/.cargo/registry/cache' +echo '~/.cargo/git/db' +echo 'target/' diff --git a/etc/ci/get_submodule_paths.sh b/etc/ci/get_submodule_paths.sh new file mode 100755 index 0000000000..b796b17481 --- /dev/null +++ b/etc/ci/get_submodule_paths.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# get_submodule_paths +# +# returns the paths of each submodule in this repository, seperated by a new line +# these paths are relative to the git repository. + +# go to top level of git repo +cd $(git rev-parse --show-toplevel) + +# https://stackoverflow.com/questions/12641469/list-submodules-in-a-git-repository +git config --file .gitmodules --get-regexp path | awk '{print $2}' + diff --git a/etc/ci/get_submodules_hash.sh b/etc/ci/get_submodules_hash.sh new file mode 100755 index 0000000000..337949535c --- /dev/null +++ b/etc/ci/get_submodules_hash.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +# get_submodules_hash +# +# compute a hash that represents the current state of all git submodule +# dependencies. Primarily used for cache invalidation in GitHub Actions. + + +CI_SCRIPTS_DIR=$(realpath $(dirname "$0")) + +# go to top level of git repo +cd $(git rev-parse --show-toplevel) + +git submodule update --init --recursive + +{ + for module in $(sh "$CI_SCRIPTS_DIR/get_submodule_paths.sh") + do + git rev-parse "HEAD:$module" >> $SHAS + done; +} 2>/dev/null | sha256sum | head -c 40 # note: sha256sum print a - at the end - this is removed here. +echo ''