From 05675fa2549c3b8d053c4a8274b0548798e65d0b Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 14 Mar 2024 11:14:39 +0100 Subject: [PATCH] GitHub: separate build caches To avoid build caches getting larger and larger, causing our builds to fail, we separate the caches of the different job types. If we don't separate them, then the caches can end up being a combination of the different jobs, which isn't useful (for example the build cache of the cross compilation build isn't useful in an integration test and vice versa). --- .github/actions/setup-go/action.yml | 9 ++++++--- .github/workflows/main.yml | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index f0d7b9abf..522b94dca 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -4,6 +4,9 @@ inputs: go-version: description: "The version of Golang to set up" required: true + key-prefix: + description: "A prefix to use for the cache key, to separate cache entries from other workflows" + required: false runs: using: "composite" @@ -27,10 +30,10 @@ runs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}- - ${{ runner.os }}-go-${{ inputs.go-version }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}- - name: set GOPATH shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index deceba636..4a87854bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -154,6 +154,7 @@ jobs: uses: ./.github/actions/setup-go with: go-version: '${{ env.GO_VERSION }}' + key-prefix: cross-compile - name: build release for all architectures run: make release @@ -211,6 +212,7 @@ jobs: uses: ./.github/actions/setup-go with: go-version: '${{ env.GO_VERSION }}' + key-prefix: unit-test - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -266,6 +268,7 @@ jobs: uses: ./.github/actions/setup-go with: go-version: '${{ env.GO_VERSION }}' + key-prefix: integration-test - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -302,6 +305,7 @@ jobs: uses: ./.github/actions/setup-go with: go-version: '${{ env.GO_VERSION }}' + key-prefix: integration-test - name: run itest run: make itest-parallel windows=1