From 991346621cd9d64dffd0cd50f92f6aed4e8c5668 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 12 Mar 2026 22:13:00 +0100 Subject: [PATCH 1/5] Speedup docker builds by using cache --- .github/workflows/ci.yaml | 14 +++----------- Dockerfile | 6 +++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d85c508..262be17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -123,14 +123,6 @@ jobs: - name: Setup BuildX uses: docker/setup-buildx-action@v3 - - name: Setup cache - uses: actions/cache@v5 - with: - path: /tmp/buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -147,7 +139,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: pull: true context: . @@ -155,5 +147,5 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/buildx-cache - cache-to: type=local,dest=/tmp/buildx-cache + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 43d996b..9824196 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,13 @@ RUN set -x \ ca-certificates \ git -COPY . /app +COPY go.mod go.sum /app/ WORKDIR /app +RUN go mod download + +COPY . /app + RUN set -x \ && version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \ && go build \ From 3db1be068795ac559814234f2f67cb72529be983 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 12 Mar 2026 22:13:17 +0100 Subject: [PATCH 2/5] Use cache to speed up jobs --- .github/workflows/ci.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 262be17..0161e01 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,6 +48,16 @@ jobs: - uses: jdx/mise-action@v3 name: Install mise + - name: Cache Go modules and build + uses: actions/cache@v5 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run tests run: mise tasks run covtest @@ -69,6 +79,16 @@ jobs: - uses: jdx/mise-action@v3 name: Install mise + - name: Cache Go modules and build + uses: actions/cache@v5 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run fuzzing run: mise tasks run 'test:fuzz:*' @@ -86,6 +106,16 @@ jobs: - uses: jdx/mise-action@v3 name: Install mise + - name: Cache Go modules and build + uses: actions/cache@v5 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run linter run: mise tasks run lint From d4822989ecb5c23784cdac728add586996fa1884 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 12 Mar 2026 22:22:00 +0100 Subject: [PATCH 3/5] Add count number to covtest --- .mise.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mise.toml b/.mise.toml index c5bdf73..18e8245 100644 --- a/.mise.toml +++ b/.mise.toml @@ -37,7 +37,7 @@ run = "go test -v ./..." [tasks.covtest] description = "Run tests with code coverage" -run = "go test -coverprofile=coverage.txt -covermode=atomic -parallel 2 -race -v ./..." +run = "go test -coverprofile=coverage.txt -covermode=atomic -count=2 -race -v ./..." [tasks.test-all] description = "Run all tests" From 287a794772110b7d795d5239c2d68268cd9e867b Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 12 Mar 2026 22:22:09 +0100 Subject: [PATCH 4/5] Always run tests with race detector --- .mise.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mise.toml b/.mise.toml index 18e8245..e49496c 100644 --- a/.mise.toml +++ b/.mise.toml @@ -33,7 +33,7 @@ run = "govulncheck ./..." [tasks.test] description = "Run tests" -run = "go test -v ./..." +run = "go test -v -race ./..." [tasks.covtest] description = "Run tests with code coverage" From 4dca1d2b071a3b33ff068220840647743dd525de Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 12 Mar 2026 22:46:19 +0100 Subject: [PATCH 5/5] Add cache mount for apk downloads --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9824196..fdb4b56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,12 @@ FROM golang:1.26-alpine AS build ENV CGO_ENABLED=0 -RUN set -x \ - && apk --no-cache --update add \ - bash \ - ca-certificates \ - git +RUN --mount=type=cache,target=/var/cache/apk \ + set -x \ + && apk --update add \ + bash \ + ca-certificates \ + git COPY go.mod go.sum /app/ WORKDIR /app