Skip to content

Commit 1f4a1f9

Browse files
committed
cleanup github actions config
- cancel previous workflow runs - limit actions to changes on master branch - update actions/cache config - only upload code coverage status once
1 parent 6c9448a commit 1f4a1f9

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

.github/workflows/tests.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
29
name: tests
310

411
jobs:
512
test:
613
strategy:
714
matrix:
8-
go-version: [1.x, 1.14.x]
15+
go-version: [1.x, 1.15.x]
916
platform: [ubuntu-latest]
17+
include:
18+
# only update test coverage stats with most recent go version on linux
19+
- go-version: 1.x
20+
platform: ubuntu-latest
21+
update-coverage: true
1022
runs-on: ${{ matrix.platform }}
1123

1224
steps:
25+
- name: Cancel previous workflow runs
26+
uses: styfle/cancel-workflow-action@0.8.0
27+
with:
28+
access_token: ${{ github.token }}
29+
30+
- uses: actions/checkout@v2
1331
- uses: actions/setup-go@v2
1432
with:
1533
go-version: ${{ matrix.go-version }}
16-
- uses: actions/checkout@v2
34+
- run: go version
1735

1836
- name: Cache go modules
1937
uses: actions/cache@v2
2038
with:
2139
path: ~/go/pkg/mod
22-
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
40+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2341
restore-keys: ${{ runner.os }}-go-
2442

2543
- name: Run go test
2644
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
2745

2846
- name: Upload coverage to Codecov
47+
if: ${{ matrix.update-coverage }}
2948
uses: codecov/codecov-action@v1

0 commit comments

Comments
 (0)