Configure github actions #1
Workflow file for this run
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
name: Test | |
on: | |
push: | |
branches: [ "master" ] | |
tags: | |
- '*' | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Go tidy | |
run: go mod tidy | |
- name: Run tests | |
run: go test -v -coverprofile coverage.csv ./... | |
- name: Create coverage report | |
run: go tool cover -html=coverage.csv -o coverage.html | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage.html | |
path: coverage.html | |
gofmt: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Go tidy | |
run: go mod tidy | |
- name: gofmt | |
# Run gofmt, list the changes made. The dev needs to run gofmt if this reports more than 0 | |
run: "[ $(gofmt -l . | wc -l) -eq 0 ]" | |
staticcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Go tidy | |
run: go mod tidy | |
- name: staticcheck | |
uses: dominikh/[email protected] | |
with: | |
working-directory: "./" | |
install-go: false |