Skip to content

Commit cc9f965

Browse files
tac0turtleclaude
andauthored
ci: optimize Go and Docker layer caching (#3213)
* 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> * fix(ci): copy testapp go.mod/go.sum before download, fix hadolint warnings Also copy apps/testapp/go.mod and apps/testapp/go.sum before running go mod download so the testapp's own dependencies are cached in their own layer (separate from the root module). Replace RUN cd ... && go install with WORKDIR + go build to resolve hadolint DL3003 and DL3062. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * bump docker go versions --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4a70e0b commit cc9f965

8 files changed

Lines changed: 27 additions & 9 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.4.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.4.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.4.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.4.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.4.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.4.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.4.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.4.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.4.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.4.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/evm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25-alpine AS build-env
1+
FROM golang:1.26-alpine AS build-env
22

33
WORKDIR /src
44

apps/grpc/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM golang:1.25-alpine AS builder
2+
FROM golang:1.26-alpine AS builder
33

44
#hadolint ignore=DL3018
55
RUN apk add --no-cache git gcc musl-dev linux-headers

apps/testapp/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25 AS base
1+
FROM golang:1.26 AS base
22

33
#hadolint ignore=DL3018
44
RUN apt-get update && \
@@ -17,11 +17,17 @@ FROM base AS builder
1717

1818
WORKDIR /ev-node
1919

20-
# Copy all source code first
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+
COPY apps/testapp/go.mod apps/testapp/go.sum ./apps/testapp/
24+
RUN go mod download && (cd apps/testapp && go mod download)
25+
26+
# Copy the rest of the source and build.
2127
COPY . .
2228

23-
# Now download dependencies and build
24-
RUN go mod download && cd apps/testapp && go install .
29+
WORKDIR /ev-node/apps/testapp
30+
RUN go build -o /go/bin/testapp .
2531

2632
## prep the final image.
2733
#

tools/local-da/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25-alpine AS build-env
1+
FROM golang:1.26-alpine AS build-env
22

33
WORKDIR /src
44

0 commit comments

Comments
 (0)