diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0a704f2..6ebbb0a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,12 +22,25 @@ jobs: with: go-version-file: "go.mod" - - 'name': 'Set up tools cache' - 'uses': 'actions/cache@v4' - 'with': - 'path': "${{ github.workspace }}/bin" - 'key': "${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }}" - 'restore-keys': '${{ runner.os }}-${{ github.job }}-tools-' + # Cache Go build cache and module cache (speeds up module downloads & rebuilds) + - name: Cache Go modules and build cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-${{ github.job }}-go-mod-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-go-mod- + + # Cache toolbox binaries produced by .toolbox.mk + - name: Cache toolbox binaries + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/bin + key: ${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-tools- - name: Lint run: make lint @@ -49,12 +62,23 @@ jobs: with: go-version-file: "go.mod" - - 'name': 'Set up tools cache' - 'uses': 'actions/cache@v4' - 'with': - 'path': "${{ github.workspace }}/bin" - 'key': "${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }}" - 'restore-keys': '${{ runner.os }}-${{ github.job }}-tools-' + - name: Cache Go modules and build cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-${{ github.job }}-go-mod-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-go-mod- + + - name: Cache toolbox binaries + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/bin + key: ${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-tools- - name: Model run: make model @@ -82,13 +106,23 @@ jobs: with: go-version-file: "go.mod" - - 'name': 'Set up tools cache' - 'uses': 'actions/cache@v4' - 'with': - 'path': "${{ github.workspace }}/bin" - 'key': "${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }}" - 'restore-keys': '${{ runner.os }}-${{ github.job }}-tools-' + - name: Cache Go modules and build cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-${{ github.job }}-go-mod-${{ hashFiles('go.sum') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-go-mod- + + - name: Cache toolbox binaries + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/bin + key: ${{ runner.os }}-${{ github.job }}-tools-${{ hashFiles('.toolbox.mk') }} + restore-keys: | + ${{ runner.os }}-${{ github.job }}-tools- - name: Run GoReleaser run: make test-release -