Skip to content

Commit

Permalink
Refine test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Apr 4, 2021
1 parent 13dac45 commit 3c4eba7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 48 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/test.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Testing

on:
push:
branches:
- "*"
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/testing.yml"
pull_request:
branches: [ main ]
types: [ opened, synchronize, reopened ]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/testing.yml"

jobs:
test:
name: Testing
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go: [ "1.13", "1.14", "1.15", "1.16" ]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Run test
run: |
make test
make test-cover
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.*

- name: Run integration test
run: make test-integration
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,21 @@ fmt:
test:
@echo "-> Running go test"
@CGO_ENABLED=1 go test -v -race -cover -coverprofile=coverage.out -covermode=atomic ./...

test-integration:
@echo 'mode: atomic' > coverage.out
@go list ./... | xargs -n1 -I{} sh -c 'CGO_ENABLED=1 go test -race -tags=integration -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.out || exit 255'
@rm coverage.tmp

test-cover:
@echo "-> Running go tool cover"
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out -o coverage.html

bench:
@echo "-> Running benchmark"
@go test -v -bench .

profile:
@echo "-> Running profile"
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench .

0 comments on commit 3c4eba7

Please sign in to comment.