From e0fb3f369181f0580e5c3cf5c36616b4be7aa33d Mon Sep 17 00:00:00 2001 From: tnasu Date: Wed, 18 May 2022 18:33:47 +0900 Subject: [PATCH] Cache go-modules --- .github/workflows/e2e.yml | 8 ++++++++ test/e2e/docker/Dockerfile | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3bc5d34ee..fc68fad7c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -28,6 +28,13 @@ jobs: go.mod go.sum + - name: Download go modules + id: gomodules + run: | + go mod download + GOMODCACHE=$(go env GOMODCACHE) + echo "::set-output name=GOMODCACHE::${GOMODCACHE}" + - name: Create cache directory run: mkdir -p /tmp/.buildx-cache @@ -53,6 +60,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max load: true + build-args: GOMODCACHE=${{ steps.gomodules.outputs.GOMODCACHE }} if: "env.GIT_DIFF != ''" - name: Move cached Docker layers diff --git a/test/e2e/docker/Dockerfile b/test/e2e/docker/Dockerfile index 280128e2b..c5d7d8b4f 100644 --- a/test/e2e/docker/Dockerfile +++ b/test/e2e/docker/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # We need to build in a Linux environment to support C libraries, e.g. RocksDB. # We use Debian instead of Alpine, so that we can use binary database packages # instead of spending time compiling them. @@ -39,8 +41,9 @@ ENV CGO_LDFLAGS -lrocksdb ENV LIBSODIUM 1 # Fetch dependencies separately (for layer caching) +ARG GOMODCACHE COPY go.mod go.sum ${SRCDIR} -RUN cd ${SRCDIR} && go mod download +RUN --mount=type=cache,target=${GOMODCACHE} cd ${SRCDIR} && go mod download # Build Ostracon and install into /usr/bin/ostracon COPY . ${SRCDIR}