Files
pezkuwi-subxt/scripts/ci/pre_cache.sh
T
Denis Pisarev 3883f73391 CI: build a test artifact (#527)
* CI: build a test artifact

* CI: try building before testing

* CI: try proper bin name

* CI: preempty cache to benchmark properly

* CI: run build after test

* CI: change target source

* CI: try build before test once again

* CI: chore

* CI: prepopulate target cache

* CI: conditional build; aws sync

* CI: mock building to test publishing

* CI: lacks permissions in the other job

* CI: undebug
2021-07-23 17:06:57 +02:00

29 lines
999 B
Bash
Executable File

#!/bin/bash
set -u
# if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME
# create such directory and
# copy recursively all the files from the newest dir which has $CI_JOB_NAME, if it exists
# cache lives in /ci-cache/${CI_PROJECT_NAME}/${2}/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}
function prepopulate {
if [[ ! -d $1 ]]; then
mkdir -p "/ci-cache/$CI_PROJECT_NAME/$2/$CI_COMMIT_REF_NAME";
FRESH_CACHE=$(find "/ci-cache/$CI_PROJECT_NAME/$2" -mindepth 2 -maxdepth 2 \
-type d -name "$CI_JOB_NAME" -exec stat --printf="%Y\t%n\n" {} \; |sort -n -r |head -1 |cut -f2);
if [[ -d $FRESH_CACHE ]]; then
echo "____Using" "$FRESH_CACHE" "to prepopulate the cache____";
time cp -r "$FRESH_CACHE" "$1";
else
echo "_____No such $2 dir, proceeding from scratch_____";
fi
else
echo "____No need to prepopulate $2 cache____";
fi
}
# CARGO_HOME cache is still broken so would be handled some other way.
prepopulate "$CARGO_TARGET_DIR" targets