From cfb27797a83ff7ea787acf1c6627657ac174dca3 Mon Sep 17 00:00:00 2001 From: thinkgo <49174849+thinkgos@users.noreply.github.com> Date: Wed, 21 Jul 2021 11:21:49 +0800 Subject: [PATCH] Fix CI workflow to make the cache action really work (#174) --- .github/workflows/ci.yml | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1603bd6..41d6cdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,20 +27,13 @@ jobs: runs-on: ${{ matrix.os}} steps: - name: Installing Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} + - name: Checkout code uses: actions/checkout@v2 - - name: Run unit tests - run: go test -race -coverprofile=coverage -covermode=atomic -v - - name: Upload code coverage report to Codecov - uses: codecov/codecov-action@v1.2.1 - with: - file: ./coverage - flags: unittests - verbose: true - name: codecov-ants + - name: Print Go environment id: vars run: | @@ -53,10 +46,25 @@ jobs: # Calculate the short SHA1 hash of the git commit echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" echo "::set-output name=go_cache::$(go env GOCACHE)" + - name: Cache go modules uses: actions/cache@v2 with: - path: ${{ steps.vars.outputs.go_cache }} + path: | + ${{ steps.vars.outputs.go_cache }} + ~/go/pkg/mod key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-${{ matrix.go }}-go-ci + + - name: Run unit tests + run: go test -race -coverprofile=coverage -covermode=atomic -v + + - name: Upload code coverage report to Codecov + uses: codecov/codecov-action@v2 + with: + file: ./coverage + flags: unittests + verbose: true + name: codecov-ants +