Skip to content

Commit

Permalink
build: use local repo cache in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Aug 13, 2024
1 parent 3607180 commit 241e139
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .docker/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 }} \
Expand Down Expand Up @@ -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 }} \
Expand Down

0 comments on commit 241e139

Please sign in to comment.