build: use local repo cache in CI

This commit is contained in:
Marcus Holland-Moritz 2024-08-13 10:15:34 +02:00
parent 75e809776b
commit 2355aba67b
2 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,36 @@ set -ex
export CCACHE_DIR=/ccache
LOCAL_REPO_PATH=/local/repos
mkdir -p "$LOCAL_REPO_PATH"
LAST_UPDATE_FILE="$LOCAL_REPO_PATH/last-update"
if [ -f "$LAST_UPDATE_FILE" ] && [ $(find "$LAST_UPDATE_FILE" -mmin -180) ]; then
echo "Skipping git repo update because it already ran in the last three hours."
else
echo "Running git repo update."
for repo in "fmtlib/fmt" \
"google/googletest" \
"ericniebler/range-v3" \
"greg7mdp/parallel-hashmap"; do
reponame=$(basename "$repo")
cd "$LOCAL_REPO_PATH"
if [ -d "$reponame" ]; then
cd "$reponame"
time git fetch
else
time git clone "https://github.com/$repo.git"
fi
done
touch "$LAST_UPDATE_FILE"
fi
if [[ "$BUILD_TYPE" != "clang-release-ninja-static" ]]; then
export DWARFS_LOCAL_REPO_PATH="$LOCAL_REPO_PATH"
fi
cd "$HOME"
rm -rf dwarfs dwarfs-*

View File

@ -124,6 +124,7 @@ jobs:
--mount type=bind,source=${GITHUB_WORKSPACE},target=/workspace,readonly \
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \
--mount type=bind,source=/home/mhx/github-ccache,target=/ccache \
--mount type=bind,source=/home/mhx/github-local,target=/local \
--mount type=bind,source=/mnt/opensource/artifacts/dwarfs,target=/artifacts \
--env BUILD_TYPE=clang-release-ninja-source \
--env BUILD_ARCH=amd64 \
@ -233,6 +234,7 @@ jobs:
--mount type=bind,source=${GITHUB_WORKSPACE},target=/workspace,readonly \
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \
--mount type=bind,source=/home/mhx/github-ccache,target=/ccache \
--mount type=bind,source=/home/mhx/github-local,target=/local \
--env BUILD_FROM_TARBALL=1 \
--env BUILD_TYPE=${{ matrix.build_type }} \
--env BUILD_ARCH=${{ matrix.arch }} \
@ -372,6 +374,7 @@ jobs:
--mount type=bind,source=${GITHUB_WORKSPACE},target=/workspace,readonly \
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \
--mount type=bind,source=/home/mhx/github-ccache,target=/ccache \
--mount type=bind,source=/home/mhx/github-local,target=/local \
--mount type=bind,source=/mnt/opensource/artifacts/dwarfs,target=/artifacts \
--env BUILD_TYPE=${{ matrix.build_type }} \
--env BUILD_ARCH=${{ matrix.arch }} \