From 818a16d7e8bae1023b54000f6f8feefd9655f0fc Mon Sep 17 00:00:00 2001 From: Sven Greb Date: Sun, 21 Nov 2021 14:37:59 +0100 Subject: [PATCH] Cache Go dependencies and build outputs in `ci-go` workflow To improve workflow execution time for the `ci-go` workflow [1] the `actions/cache` [2] GitHub action is now used to cache Go dependencies and build outputs. Also see the detailed documentation about "Caching dependencies to speed up workflows" [3] to learn more about the way `action/cache` works. [1]: https://github.com/svengreb/tmpl-go/blob/c099c6ee246eb402b63f7a605ca647c481a02eab/.github/workflows/ci-go.yaml [2]: https://github.com/actions/cache [3]: https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows GH-74 --- .github/workflows/ci-go.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/ci-go.yaml b/.github/workflows/ci-go.yaml index 6a786e1..2368cf5 100644 --- a/.github/workflows/ci-go.yaml +++ b/.github/workflows/ci-go.yaml @@ -56,3 +56,23 @@ jobs: go-version: "1.17.x" - name: Run tests with coverage and race detector run: go test -cover -race -v ./... + + post-tasks: + runs-on: ubuntu-latest + steps: + - name: Print metadata and context information + run: | + echo "Git SHA: $GITHUB_SHA" + echo "Git Ref: $GITHUB_REF" + echo "Workflow Actor: $GITHUB_ACTOR" + - name: Checkout repository + uses: actions/checkout@v2 + - name: Cache Go dependencies and build outputs + uses: actions/cache@v2 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-