Skip to content

Commit

Permalink
Cache go-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tnasu committed May 18, 2022
1 parent 05c5d34 commit e0fb3f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit e0fb3f3

Please sign in to comment.