From fdda5e7464a3ab46388465e058655d4131c4d8fe Mon Sep 17 00:00:00 2001 From: Tijmen34 Date: Mon, 8 May 2023 16:46:54 +0200 Subject: [PATCH] feat(gh-workflows): Use cache-dependency-path in actions/setup-go for ci workflow Using cache-dependency-path (which is now a built-in functionality in actions/setup-go), the speed of runs on MacOS can be improved. Refs: #3911 --- .github/workflows/ci.yml | 56 ++++++++++++---------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be31d85a724..eba0038ad80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,23 +19,17 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - name: Checkout Repo uses: actions/checkout@v3 - name: Setup Environment run: | echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v3 - env: - cache-name: go-mod-cache + - name: Install Go + uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} + go-version: ${{ env.DEFAULT_GO_VERSION }} + cache-dependency-path: "**/go.sum" - name: Tools cache uses: actions/cache@v3 env: @@ -53,46 +47,34 @@ jobs: test-race: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - name: Checkout Repo uses: actions/checkout@v3 - name: Setup Environment run: | echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v3 - env: - cache-name: go-mod-cache + - name: Install Go + uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} + go-version: ${{ env.DEFAULT_GO_VERSION }} + cache-dependency-path: "**/go.sum" - name: Run tests with race detector run: make test-race test-coverage: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - name: Checkout Repo uses: actions/checkout@v3 - name: Setup Environment run: | echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v3 - env: - cache-name: go-mod-cache + - name: Install Go + uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} + go-version: ${{ env.DEFAULT_GO_VERSION }} + cache-dependency-path: "**/go.sum" - name: Run coverage tests run: | make test-coverage @@ -128,10 +110,6 @@ jobs: arch: "386" runs-on: ${{ matrix.os }} steps: - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v3 - name: Setup Environment @@ -139,13 +117,11 @@ jobs: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV echo "$(go env GOPATH)/bin" >> $GITHUB_PATH shell: bash - - name: Module cache - uses: actions/cache@v3 - env: - cache-name: go-mod-cache + - name: Install Go + uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} + go-version: ${{ matrix.go-version }} + cache-dependency-path: "**/go.sum" - name: Run tests env: GOARCH: ${{ matrix.arch }}