-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from danvergara/test-actions
ci(actions): add a yaml file to run tests and coverage in actions
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Run Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
goVer: [1.12, 1.13, 1.14, 1.15, 1.16] | ||
## Defines the platform for each test run | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
## the steps that will be run through for each version and platform | ||
## combination | ||
- name: Set up Go ${{ matrix.goVer }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.goVer }} | ||
## checks out our code locally so we can work with the files | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
## runs go test ./... | ||
- name: Test | ||
run: go test -v ./... | ||
|
||
coverage: | ||
name: Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
## Installs go | ||
# Using a sigle version | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
## checks out our code locally so we can work with the files | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
## run the test coverage command | ||
- name: Calc coverage | ||
run: | | ||
go test -v -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |