Fix CI workflow to make the cache action really work (#174)

This commit is contained in:
thinkgo 2021-07-21 11:21:49 +08:00 committed by GitHub
parent 63489606ef
commit cfb27797a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 11 deletions

View File

@ -27,20 +27,13 @@ jobs:
runs-on: ${{ matrix.os}} runs-on: ${{ matrix.os}}
steps: steps:
- name: Installing Go - name: Installing Go
uses: actions/setup-go@v1 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 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 - name: Print Go environment
id: vars id: vars
run: | run: |
@ -53,10 +46,25 @@ jobs:
# Calculate the short SHA1 hash of the git commit # Calculate the short SHA1 hash of the git commit
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
echo "::set-output name=go_cache::$(go env GOCACHE)" echo "::set-output name=go_cache::$(go env GOCACHE)"
- name: Cache go modules - name: Cache go modules
uses: actions/cache@v2 uses: actions/cache@v2
with: 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') }} key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go-ci ${{ 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