Merge pull request #356 from 9seconds/gh-cache

Speed up Github actions
This commit is contained in:
Sergei Arkhipov
2026-03-12 22:51:59 +01:00
committed by GitHub
3 changed files with 46 additions and 19 deletions
+33 -11
View File
@@ -48,6 +48,16 @@ jobs:
- uses: jdx/mise-action@v3 - uses: jdx/mise-action@v3
name: Install mise 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 - name: Run tests
run: mise tasks run covtest run: mise tasks run covtest
@@ -69,6 +79,16 @@ jobs:
- uses: jdx/mise-action@v3 - uses: jdx/mise-action@v3
name: Install mise 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 - name: Run fuzzing
run: mise tasks run 'test:fuzz:*' run: mise tasks run 'test:fuzz:*'
@@ -86,6 +106,16 @@ jobs:
- uses: jdx/mise-action@v3 - uses: jdx/mise-action@v3
name: Install mise 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 - name: Run linter
run: mise tasks run lint run: mise tasks run lint
@@ -123,14 +153,6 @@ jobs:
- name: Setup BuildX - name: Setup BuildX
uses: docker/setup-buildx-action@v3 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 - name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
@@ -147,7 +169,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
pull: true pull: true
context: . context: .
@@ -155,5 +177,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/buildx-cache cache-from: type=gha
cache-to: type=local,dest=/tmp/buildx-cache cache-to: type=gha,mode=max
+2 -2
View File
@@ -33,11 +33,11 @@ run = "govulncheck ./..."
[tasks.test] [tasks.test]
description = "Run tests" description = "Run tests"
run = "go test -v ./..." run = "go test -v -race ./..."
[tasks.covtest] [tasks.covtest]
description = "Run tests with code coverage" 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] [tasks.test-all]
description = "Run all tests" description = "Run all tests"
+11 -6
View File
@@ -5,14 +5,19 @@ FROM golang:1.26-alpine AS build
ENV CGO_ENABLED=0 ENV CGO_ENABLED=0
RUN set -x \ RUN --mount=type=cache,target=/var/cache/apk \
&& apk --no-cache --update add \ set -x \
bash \ && apk --update add \
ca-certificates \ bash \
git ca-certificates \
git
COPY go.mod go.sum /app/
WORKDIR /app
RUN go mod download
COPY . /app COPY . /app
WORKDIR /app
RUN set -x \ RUN set -x \
&& version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \ && version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \