Skip to content

Commit

Permalink
CI: utility scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasdewally committed Nov 3, 2023
1 parent 785ca26 commit 4799c42
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
13 changes: 13 additions & 0 deletions etc/ci/get_caching_paths.sh
Original file line number Diff line number Diff line change
@@ -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/'
13 changes: 13 additions & 0 deletions etc/ci/get_submodule_paths.sh
Original file line number Diff line number Diff line change
@@ -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}'

22 changes: 22 additions & 0 deletions etc/ci/get_submodules_hash.sh
Original file line number Diff line number Diff line change
@@ -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 ''

0 comments on commit 4799c42

Please sign in to comment.