ci: improve caching (#84)

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-09 11:40:11 +01:00 committed by GitHub
parent cef931a971
commit 56a163b46c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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
@ -45,4 +48,4 @@ WORKDIR /
COPY --from=gobuilder /workspace/manager . COPY --from=gobuilder /workspace/manager .
USER 65532:65532 USER 65532:65532
ENTRYPOINT ["/manager"] ENTRYPOINT ["/manager"]

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/