Skip to content

Commit 91fd6fa

Browse files
tac0turtleclaude
andcommitted
ci: optimize Go and Docker layer caching across CI workflows
- Fix apps/testapp/Dockerfile: copy go.mod/go.sum before source so the go mod download layer is stable across code-only changes - Add cache-from/cache-to GHA cache to docker-build-push.yml with per-app scopes to prevent cache eviction between parallel builds - Add cache-dependency-path: "**/go.sum" to all actions/setup-go steps in test.yml, docker-tests.yml, and lint.yml so the module cache key covers all go.sum files in the multi-module repo - Add explicit scope to the e2e Docker build cache in test.yml to align with the docker-build-push.yml scope naming Closes #3196 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8d68f9d commit 91fd6fa

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/docker-build-push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ jobs:
4848
push: true
4949
platforms: linux/amd64,linux/arm64
5050
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.app.name }}:${{ inputs.image-tag }}
51+
cache-from: type=gha,scope=${{ matrix.app.name }}
52+
cache-to: type=gha,mode=max,scope=${{ matrix.app.name }}

.github/workflows/docker-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: actions/setup-go@v6.3.0
2828
with:
2929
go-version-file: ./test/docker-e2e/go.mod
30+
cache-dependency-path: "**/go.sum"
3031
- name: Install just
3132
uses: extractions/setup-just@v3
3233
- name: Run Docker E2E Tests
@@ -46,6 +47,7 @@ jobs:
4647
uses: actions/setup-go@v6.3.0
4748
with:
4849
go-version-file: ./test/docker-e2e/go.mod
50+
cache-dependency-path: "**/go.sum"
4951
- name: Install just
5052
uses: extractions/setup-just@v3
5153
- name: Run Docker Upgrade E2E Tests
@@ -65,6 +67,7 @@ jobs:
6567
uses: actions/setup-go@v6.3.0
6668
with:
6769
go-version-file: ./test/docker-e2e/go.mod
70+
cache-dependency-path: "**/go.sum"
6871
- name: Install just
6972
uses: extractions/setup-just@v3
7073
- name: Run Docker Compat E2E Tests

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- uses: actions/setup-go@v6.3.0
1717
with:
1818
go-version-file: ./go.mod
19+
cache-dependency-path: "**/go.sum"
1920
# This steps sets the GIT_DIFF environment variable to true
2021
# if files defined in PATTERS changed
2122
- uses: technote-space/get-diff-action@v6.1.2

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: actions/setup-go@v6.3.0
1818
with:
1919
go-version-file: ./go.mod
20+
cache-dependency-path: "**/go.sum"
2021
- name: Install just
2122
uses: extractions/setup-just@v3
2223
- name: Build all ev-node binaries
@@ -30,6 +31,7 @@ jobs:
3031
- uses: actions/setup-go@v6.3.0
3132
with:
3233
go-version-file: ./go.mod
34+
cache-dependency-path: "**/go.sum"
3335
- uses: extractions/setup-just@v3
3436
- run: just deps
3537
- name: check for diff
@@ -47,6 +49,7 @@ jobs:
4749
uses: actions/setup-go@v6.3.0
4850
with:
4951
go-version-file: ./go.mod
52+
cache-dependency-path: "**/go.sum"
5053
- name: Install just
5154
uses: extractions/setup-just@v3
5255
- name: Run unit test
@@ -66,6 +69,7 @@ jobs:
6669
uses: actions/setup-go@v6.3.0
6770
with:
6871
go-version-file: ./go.mod
72+
cache-dependency-path: "**/go.sum"
6973
- name: Install just
7074
uses: extractions/setup-just@v3
7175
- name: Run integration test
@@ -89,6 +93,7 @@ jobs:
8993
uses: actions/setup-go@v6.3.0
9094
with:
9195
go-version-file: ./go.mod
96+
cache-dependency-path: "**/go.sum"
9297
- name: Set up Docker Buildx
9398
uses: docker/setup-buildx-action@v4
9499
- name: Build evstack:local-dev (cached)
@@ -98,8 +103,8 @@ jobs:
98103
file: apps/testapp/Dockerfile
99104
load: true
100105
tags: evstack:local-dev
101-
cache-from: type=gha
102-
cache-to: type=gha,mode=max
106+
cache-from: type=gha,scope=ev-node-testapp
107+
cache-to: type=gha,mode=max,scope=ev-node-testapp
103108
- name: Install just
104109
uses: extractions/setup-just@v3
105110
- name: E2E Tests
@@ -115,6 +120,7 @@ jobs:
115120
uses: actions/setup-go@v6.3.0
116121
with:
117122
go-version-file: ./go.mod
123+
cache-dependency-path: "**/go.sum"
118124
- name: Install just
119125
uses: extractions/setup-just@v3
120126
- name: EVM Tests

apps/testapp/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ FROM base AS builder
1717

1818
WORKDIR /ev-node
1919

20-
# Copy all source code first
21-
COPY . .
20+
# Copy module files first to leverage Docker layer caching.
21+
# Dependencies are only re-downloaded when go.mod or go.sum change.
22+
COPY go.mod go.sum ./
23+
RUN go mod download
2224

23-
# Now download dependencies and build
24-
RUN go mod download && cd apps/testapp && go install .
25+
# Copy the rest of the source and build.
26+
COPY . .
27+
RUN cd apps/testapp && go install .
2528

2629
## prep the final image.
2730
#

0 commit comments

Comments
 (0)