From 4383c924fe60d42621ae6da70a47fb40660e3215 Mon Sep 17 00:00:00 2001 From: albttx Date: Thu, 9 May 2024 08:56:26 +0100 Subject: [PATCH] chore: add go-cache --- .github/workflows/docker.yml | 26 ++++++++++++++++++++++++++ .github/workflows/portal-loop.yml | 7 +++++++ Dockerfile | 11 ++++++----- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1dd188d1e0e..c0c0dd16f97 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -36,6 +36,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Go Build Cache for Docker + uses: actions/cache@v3 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: inject go-build-cache into docker + # v1 was composed of two actions: "inject" and "extract". + # v2 is unified to a single action. + uses: reproducible-containers/buildkit-cache-dance@v2.1.2 + with: + cache-source: go-build-cache + - name: Build and push uses: docker/build-push-action@v5 with: @@ -76,6 +89,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Go Build Cache for Docker + uses: actions/cache@v3 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: inject go-build-cache into docker + # v1 was composed of two actions: "inject" and "extract". + # v2 is unified to a single action. + uses: reproducible-containers/buildkit-cache-dance@v2.1.2 + with: + cache-source: go-build-cache + - name: Build and push uses: docker/build-push-action@v5 with: diff --git a/.github/workflows/portal-loop.yml b/.github/workflows/portal-loop.yml index 6db5ffe4225..17a35d78aab 100644 --- a/.github/workflows/portal-loop.yml +++ b/.github/workflows/portal-loop.yml @@ -46,3 +46,10 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + build-gno: + uses: ./.github/workflows/docker.yml + + test-portal-loop: + runs-on: ubuntu-latest + needs: build-gno diff --git a/Dockerfile b/Dockerfile index a18c7125a82..4c8dd732141 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ # build gno FROM golang:1.22 AS build-gno +RUN go env -w GOMODCACHE=/root/.cache/go-build RUN mkdir -p /opt/gno/src /opt/build WORKDIR /opt/build ADD go.mod go.sum . -RUN go mod download +RUN --mount=type=cache,target=/root/.cache/go-build go mod download ADD . ./ -RUN go build -o ./build/gnoland ./gno.land/cmd/gnoland -RUN go build -o ./build/gnokey ./gno.land/cmd/gnokey -RUN go build -o ./build/gnoweb ./gno.land/cmd/gnoweb -RUN go build -o ./build/gno ./gnovm/cmd/gno +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoland ./gno.land/cmd/gnoland +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnokey ./gno.land/cmd/gnokey +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoweb ./gno.land/cmd/gnoweb +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gno ./gnovm/cmd/gno RUN ls -la ./build ADD . /opt/gno/src/ RUN rm -rf /opt/gno/src/.git