Byte-snake-engine/.github/workflows/test.yml

68 lines
1.6 KiB
YAML

name: Test
on:
push: # Branch pushes only, not tags
branches:
- '**'
pull_request:
workflow_call: # Allow other workflows to call this one
env:
GO_VERSION: '1.20'
jobs:
format:
name: Format (gofmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run gofmt
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
lint:
name: Lint (golangci-lint)
runs-on: ubuntu-latest
needs: [format]
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.1
golangci-lint run -v ./...
test:
name: Test (go test)
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run go test
run: go test -race ./...
build-cli:
name: Build CLI (go build)
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run go build
run: |
go build ./cli/battlesnake
./battlesnake --help