From 9d6dacb0f830a80c324b037f26e90aa04ccc3103 Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Fri, 20 Mar 2026 12:07:10 +0000 Subject: [PATCH] ci: cache go modules and build outputs in workflows --- .gitea/workflows/pr-validation.yml | 20 ++++++++++++++++++++ .gitea/workflows/push-validation.yml | 20 ++++++++++++++++++++ .gitea/workflows/tag-build-artifacts.yml | 21 +++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/.gitea/workflows/pr-validation.yml b/.gitea/workflows/pr-validation.yml index b0b8bc1..65edb40 100644 --- a/.gitea/workflows/pr-validation.yml +++ b/.gitea/workflows/pr-validation.yml @@ -11,6 +11,7 @@ jobs: validate: runs-on: ubuntu-latest env: + RUNNER_TOOL_CACHE: /cache/tools ARTEFACT_BUCKET_NAME: ${{ vars.ARTEFACT_BUCKET_NAME }} ARTEFACT_BUCKET_ENDPONT: ${{ vars.ARTEFACT_BUCKET_ENDPONT }} ARTEFACT_BUCKET_REGION: ${{ vars.ARTEFACT_BUCKET_REGION }} @@ -27,6 +28,25 @@ jobs: with: go-version-file: go.mod + - name: Get go-hashfiles + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: |- + go.mod + go.sum + + - name: Cache go + id: cache-go + uses: https://github.com/actions/cache@v3 + with: + path: |- + /root/go/pkg/mod + /root/.cache/go-build + key: go_cache-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + - name: Ensure tooling is available run: | set -euo pipefail diff --git a/.gitea/workflows/push-validation.yml b/.gitea/workflows/push-validation.yml index 16df285..060c037 100644 --- a/.gitea/workflows/push-validation.yml +++ b/.gitea/workflows/push-validation.yml @@ -11,6 +11,7 @@ jobs: validate: runs-on: ubuntu-latest env: + RUNNER_TOOL_CACHE: /cache/tools ARTEFACT_BUCKET_NAME: ${{ vars.ARTEFACT_BUCKET_NAME }} ARTEFACT_BUCKET_ENDPONT: ${{ vars.ARTEFACT_BUCKET_ENDPONT }} ARTEFACT_BUCKET_REGION: ${{ vars.ARTEFACT_BUCKET_REGION }} @@ -27,6 +28,25 @@ jobs: with: go-version-file: go.mod + - name: Get go-hashfiles + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: |- + go.mod + go.sum + + - name: Cache go + id: cache-go + uses: https://github.com/actions/cache@v3 + with: + path: |- + /root/go/pkg/mod + /root/.cache/go-build + key: go_cache-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + - name: Ensure tooling is available run: | set -euo pipefail diff --git a/.gitea/workflows/tag-build-artifacts.yml b/.gitea/workflows/tag-build-artifacts.yml index d1d633a..b39007b 100644 --- a/.gitea/workflows/tag-build-artifacts.yml +++ b/.gitea/workflows/tag-build-artifacts.yml @@ -8,6 +8,8 @@ on: jobs: build: runs-on: ubuntu-latest + env: + RUNNER_TOOL_CACHE: /cache/tools strategy: fail-fast: false matrix: @@ -30,6 +32,25 @@ jobs: with: go-version-file: go.mod + - name: Get go-hashfiles + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: |- + go.mod + go.sum + + - name: Cache go + id: cache-go + uses: https://github.com/actions/cache@v3 + with: + path: |- + /root/go/pkg/mod + /root/.cache/go-build + key: go_cache-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + - name: Build binary run: | mkdir -p dist