From 5d1ce9891b8481188453a791cd56269c89e087aa Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 21 Nov 2023 12:00:47 +0200 Subject: [PATCH] .github/workflows: add Go version to Go artifacts cache key When Go version changes, artifacts for the previous Go version may becomes useless, so there is a little sense in re-using them. --- .github/workflows/check-licenses.yml | 11 +++++++---- .github/workflows/main.yml | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check-licenses.yml b/.github/workflows/check-licenses.yml index b96eccedc..1551b6d2c 100644 --- a/.github/workflows/check-licenses.yml +++ b/.github/workflows/check-licenses.yml @@ -14,14 +14,16 @@ jobs: name: Build runs-on: ubuntu-latest steps: + - name: Code checkout + uses: actions/checkout@master + - name: Setup Go + id: go uses: actions/setup-go@main with: go-version: stable cache: false - id: go - - name: Code checkout - uses: actions/checkout@master + - name: Cache Go artifacts uses: actions/cache@v3 with: @@ -29,7 +31,8 @@ jobs: ~/.cache/go-build ~/go/pkg/mod ~/go/bin - key: go-artifacts-${{ runner.os }}-check-licenses-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} + key: go-artifacts-${{ runner.os }}-check-licenses-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} restore-keys: go-artifacts-${{ runner.os }}-check-licenses- + - name: Check License run: make check-licenses diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f37755abf..ed62202c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,6 +30,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Go + id: go uses: actions/setup-go@v4 with: go-version: stable @@ -42,7 +43,7 @@ jobs: ~/.cache/go-build ~/go/pkg/mod ~/go/bin - key: go-artifacts-${{ runner.os }}-check-all-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} + key: go-artifacts-${{ runner.os }}-check-all-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} restore-keys: go-artifacts-${{ runner.os }}-check-all- - name: Run check-all @@ -72,7 +73,7 @@ jobs: ~/.cache/go-build ~/go/pkg/mod ~/go/bin - key: go-artifacts-${{ runner.os }}-crossbuild-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} + key: go-artifacts-${{ runner.os }}-crossbuild-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} restore-keys: go-artifacts-${{ runner.os }}-crossbuild- - name: Build @@ -90,6 +91,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Go + id: go uses: actions/setup-go@v4 with: go-version: stable @@ -102,7 +104,7 @@ jobs: ~/.cache/go-build ~/go/pkg/mod ~/go/bin - key: go-artifacts-${{ runner.os }}-${{ matrix.scenario }}-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} + key: go-artifacts-${{ runner.os }}-${{ matrix.scenario }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.sum', 'Makefile', 'app/**/Makefile') }} restore-keys: go-artifacts-${{ runner.os }}-${{ matrix.scenario }}- - name: run tests