ci: improve caching

Improve cache usage for faster local ci runs.

Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
This commit is contained in:
Francesco Canovai 2024-12-06 14:07:52 +01:00 committed by Leonardo Cecchi
parent cef931a971
commit bc483db22b
3 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,9 @@ tasks:
cmds: cmds:
- > - >
GITHUB_REF= dagger -s call -m github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA} GITHUB_REF= dagger -s call -m github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA}
with-linter-cache --cache golangci-lint
with-build-cache --cache go-build
with-module-cache --cache go-mod
run --source . --config .golangci.yml stdout run --source . --config .golangci.yml stdout
sources: sources:
- ./**/*.go - ./**/*.go

View File

@ -16,6 +16,9 @@ COPY ../cmd/manager/main.go cmd/manager/main.go
COPY ../api/ api/ COPY ../api/ api/
COPY ../internal/ internal/ COPY ../internal/ internal/
ENV GOCACHE=/root/.cache/go-build
ENV GOMODCACHE=/go/pkg/mod
# Build # Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command # the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO

View File

@ -17,6 +17,9 @@ COPY ../go.sum go.sum
# and so that source changes don't invalidate our downloaded layer # and so that source changes don't invalidate our downloaded layer
RUN go mod download RUN go mod download
ENV GOCACHE=/root/.cache/go-build
ENV GOMODCACHE=/go/pkg/mod
# Copy the go source # Copy the go source
COPY ../cmd/manager/main.go cmd/manager/main.go COPY ../cmd/manager/main.go cmd/manager/main.go
COPY ../api/ api/ COPY ../api/ api/