Skip to content

Commit

Permalink
Merge pull request #76 from OffchainLabs/fix_ci_cache
Browse files Browse the repository at this point in the history
Fix docker layers caching in CI
  • Loading branch information
tsahee authored Oct 28, 2024
2 parents 40376f8 + 749dc24 commit 3086f24
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Startup Nitro testnode
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

./test-node.bash "$@"
./test-node.bash "$@" --ci

if [ $? -ne 0 ]; then
echo "test-node.bash failed"
Expand Down
37 changes: 37 additions & 0 deletions docker-compose-ci-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"target": {
"scripts": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"rollupcreator": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"tokenbridge": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
}
}
}
19 changes: 15 additions & 4 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ else
fi

run=true
ci=false
validate=false
detach=false
blockscout=false
Expand Down Expand Up @@ -107,6 +108,10 @@ while [[ $# -gt 0 ]]; do
done
fi
;;
--ci)
ci=true
shift
;;
--build)
build_dev_nitro=true
build_dev_blockscout=true
Expand Down Expand Up @@ -342,11 +347,17 @@ if $build_utils; then
if $tokenbridge || $l3_token_bridge; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
UTILS_NOCACHE=""
if $force_build_utils; then

if [ "$ci" == true ]; then
# workaround to cache docker layers and keep using docker-compose in CI
docker buildx bake --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES
else
UTILS_NOCACHE=""
if $force_build_utils; then
UTILS_NOCACHE="--no-cache"
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi

if $dev_nitro; then
Expand All @@ -366,7 +377,7 @@ if $blockscout; then
fi

if $build_node_images; then
docker compose build --no-rm $NODES scripts
docker compose build --no-rm $NODES
fi

if $force_init; then
Expand Down

0 comments on commit 3086f24

Please sign in to comment.