Move test commands into Makefile.

This commit is contained in:
bvanvugt 2023-02-20 00:25:17 +00:00
parent 465a59bc88
commit 4f4cd62a87
3 changed files with 45 additions and 18 deletions

View file

@ -1,14 +1,19 @@
name: Release (goreleaser)
name: Release
on:
push:
tags:
- '*'
release:
types: [published]
branches: [main]
env:
GO_VERSION: '1.20'
jobs:
test:
name: Test
uses: ./.github/workflows/test.yml
goreleaser:
runs-on: ubuntu-latest
steps:

View file

@ -1,6 +1,11 @@
name: Test
on: [push, pull_request]
on:
push: # Branch pushes only, not tags
branches:
- '**'
pull_request:
workflow_call: # Allow other workflows to call this one
env:
GO_VERSION: '1.20'
@ -16,8 +21,7 @@ jobs:
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run gofmt
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
- run: make test-format
lint:
name: Lint (golangci-lint)
@ -29,13 +33,10 @@ jobs:
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 ./...
- run: make test-lint
test:
name: Test (go test)
name: Tests (go test)
runs-on: ubuntu-latest
needs: [lint]
steps:
@ -44,8 +45,7 @@ jobs:
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run go test
run: go test -race ./...
- run: make test-unit
build-cli:
name: Build CLI (go build)
@ -57,7 +57,6 @@ jobs:
with:
go-version: '${{ env.GO_VERSION }}'
check-latest: true
- name: Run go build
run: |
go build ./cli/battlesnake
./battlesnake --help
- run: |
make build-cli
battlesnake --help

23
Makefile Normal file
View file

@ -0,0 +1,23 @@
GOLANGCI_LINT_VERSION ?= 1.51.1
/go/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${GOPATH}/bin v${GOLANGCI_LINT_VERSION}
build-cli:
go install ./cli/battlesnake
.PHONY: cli
test: test-format test-lint test-unit
.PHONY: test
test-format:
test -z $(gofmt -l .) || (gofmt -l . && exit 1)
.PHONY: test-format
test-lint: /go/bin/golangci-lint
/go/bin/golangci-lint run -v ./...
.PHONY: test-lint
test-unit:
go test -race ./...
.PHONY: test-unit