Build and Test - Main Branch #519
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
# REFS: | |
# https://github.com/actions/starter-workflows/blob/main/ci/go.yml | |
# https://github.com/mvdan/github-actions-golang | |
# | |
name: Build and Test - Main Branch | |
on: | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: '0 0 * * 0' # run a build every Sunday at 00:00 to catch gremlins | |
jobs: | |
build: | |
strategy: | |
matrix: | |
go-version: ['stable', 'oldstable'] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
env: | |
AWS_REGION: us-east-1 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
check-latest: true | |
- name: Check code formatting | |
run: gofmt -s -w . && git diff --exit-code | |
- name: Ensure dep definitions are up-to-date | |
run: go mod tidy && git diff --exit-code | |
- name: Download deps | |
run: go mod download | |
- name: Verify deps | |
run: go mod verify | |
- name: Install govulncheck | |
run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
- name: Run govulncheck | |
run: govulncheck -test ./... | |
- name: Build | |
run: go build -v ./... | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v4.0.0 | |
- name: Test | |
run: go test -v -race -shuffle=on -coverprofile coverage.out ./... | |
- name: Go Benchmark | |
run: go test -v -shuffle=on -run=- -bench=. -benchtime=1x ./... | |
- name: Upload Coverage | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: ./coverage.out | |
force-coverage-parser: go |