Skip to content

Commit

Permalink
ci(actions): add a yaml file to run tests and coverage in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed Apr 2, 2021
1 parent 47a1ced commit 7b1dd86
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/test.yaml
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 }}

0 comments on commit 7b1dd86

Please sign in to comment.