Skip to content

test

test #11

Workflow file for this run

name: test
on:
pull_request:
types: [opened, synchronize]
push:
branches: [main]
schedule:
- cron: "0 12 1 * *" # first day of the month at 12:00
jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: Check out repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Prepare cache
id: cache
run: |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
echo "GOVERSION=$(go env GOVERSION)" >> $GITHUB_OUTPUT
mkdir -p $(go env GOCACHE) || true
mkdir -p $(go env GOMODCACHE) || true
- name: Cache
uses: actions/cache@v3
with:
path: |
${{ steps.cache.outputs.GOCACHE }}
${{ steps.cache.outputs.GOMODCACHE }}
key: test.1-${{ runner.os }}-${{ steps.cache.outputs.GOVERSION }}-${{ hashFiles('**/go.mod') }}
restore-keys: |
test.1-${{ runner.os }}-${{ steps.cache.outputs.GOVERSION }}-${{ hashFiles('**/go.mod') }}
test.1-${{ runner.os }}-${{ steps.cache.outputs.GOVERSION }}-
test.1-${{ runner.os }}-
- name: Install tools
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
go install mvdan.cc/gofumpt@latest
go install github.com/mgechev/revive@latest
- name: Run gofmt
if: matrix.platform != 'windows-latest' # :<
run: diff <(gofmt -d . 2>/dev/null) <(printf '')
- name: Run go vet
run: go vet ./...
- name: Run staticcheck
run: staticcheck ./...
- name: Run gofumpt
run: gofumpt -d -e -l .
- name: Run go test
run: go test -v -race ./...