| 1 |
name: Tests and linters |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: |
| 5 |
- master |
| 6 |
pull_request: |
| 7 |
|
| 8 |
permissions: |
| 9 |
contents: read |
| 10 |
|
| 11 |
jobs: |
| 12 |
test: |
| 13 |
runs-on: ubuntu-latest |
| 14 |
permissions: |
| 15 |
id-token: write |
| 16 |
steps: |
| 17 |
- name: Checkout code |
| 18 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 19 |
with: |
| 20 |
persist-credentials: false |
| 21 |
- name: Install Go |
| 22 |
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 |
| 23 |
with: |
| 24 |
go-version: 'stable' |
| 25 |
- name: Run linters |
| 26 |
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a |
| 27 |
with: |
| 28 |
version: "latest" |
| 29 |
- name: Run tests |
| 30 |
run: go test -race -shuffle=on ./... |
| 31 |
|
| 32 |
- name: Run tests -count=1000 |
| 33 |
run: go test -count=1000 -shuffle=on -short ./... |
| 34 |
|
| 35 |
- name: Run tests on 32 bit architecture |
| 36 |
run: GOARCH=386 go test -count=1 -shuffle=on ./... |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
- name: Generate coverage |
| 42 |
run: | |
| 43 |
export PKGS=$(go list ./...) |
| 44 |
export PKGS_DELIM=$(echo "$PKGS" | paste -sd "," -) |
| 45 |
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -covermode count -coverprofile {{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $PKGS_DELIM {{.ImportPath}}{{end}}' $PKGS | xargs -I {} bash -c {} |
| 46 |
go install github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c |
| 47 |
gocovmerge `ls *.coverprofile` > cover.out |
| 48 |
rm *.coverprofile |
| 49 |
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f |
| 50 |
with: |
| 51 |
fail_ci_if_error: true |
| 52 |
files: cover.out |
| 53 |
use_oidc: true |