Skip to content

Commit

Permalink
chore(ci): fix docker cache overwriting (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvolin authored Jan 16, 2025
1 parent 4c56ac8 commit ea77cc8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
49 changes: 17 additions & 32 deletions .github/actions/local-devnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,33 @@ runs:
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-buildx-${{ hashFiles('./ci/Dockerfile*', './ci/*.yml', './ci/*.sh') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build the docker-compose stack
shell: bash
run: |
cache_from="type=local,src=${{ runner.temp }}/.buildx-cache"
cache_to="type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max"
cat > ci/cache.json <<EOF
{
"target": {
"validator": {
"cache-from": ["$cache_from,scope=validator"],
"cache-to": ["$cache_to,scope=validator"],
"output": ["type=docker"]
},
"bridge-0": {
"cache-from": ["$cache_from,scope=bridge-0"],
"cache-to": ["$cache_to,scope=bridge-0"],
"output": ["type=docker"]
},
"bridge-1": {
"cache-from": ["$cache_from,scope=bridge-1"],
"cache-to": ["$cache_to,scope=bridge-1"],
"output": ["type=docker"]
},
"grpcwebproxy": {
"cache-from": ["$cache_from,scope=grpcwebproxy"],
"cache-to": ["$cache_to,scope=grpcwebproxy"],
"output": ["type=docker"]
}
}
}
EOF
cd ci && docker buildx bake --file docker-compose.yml --file cache.json --load
mkdir -p ${{ runner.temp }}/.buildx-cache-new
cd ci
for image in "validator" "bridge" "grpcwebproxy"; do
docker buildx build \
--file "Dockerfile.$image" \
--tag "$image" \
--load \
--cache-from="type=local,src=${{ runner.temp }}/.buildx-cache/$image" \
--cache-to="type=local,dest=${{ runner.temp }}/.buildx-cache-new/$image" \
. &
done
wait $(jobs -p)
# Needed because otherwise cache would grow indefinitely
# Needed because otherwise cache would grow infinitely
# https://github.com/moby/buildkit/issues/1896
- name: Overwrite cache
shell: bash
run: mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
run: |
rm -rf ${{ runner.temp }}/.buildx-cache
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
- name: Run the docker-compose stack
shell: bash
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
target: wasm32-unknown-unknown
cache-key: ${{ matrix.crate }}

- name: Celestia devnet
uses: ./.github/actions/local-devnet

- name: Run clippy for native
run: cargo clippy --all-targets --all-features -p ${{ matrix.crate }} -- --no-deps

Expand Down Expand Up @@ -79,7 +76,7 @@ jobs:
run: cargo test --all-features -p ${{ matrix.crate }}


wasm-test:
test-wasm:
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -209,14 +206,15 @@ jobs:
- name: Check for unused dependencies
run: cargo udeps --all-targets --all-features


required:
runs-on: ubuntu-latest
name: Required checks
if: ${{ !cancelled() }}
needs:
- clippy
- test
- wasm-test
- test-wasm
- build-wasm
- fmt
- docs
Expand Down

0 comments on commit ea77cc8

Please sign in to comment.