Move test commands into Makefile.
This commit is contained in:
parent
465a59bc88
commit
4f4cd62a87
3 changed files with 45 additions and 18 deletions
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
|
|
@ -1,14 +1,19 @@
|
||||||
name: Release (goreleaser)
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
release:
|
||||||
tags:
|
types: [published]
|
||||||
- '*'
|
branches: [main]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: '1.20'
|
GO_VERSION: '1.20'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
uses: ./.github/workflows/test.yml
|
||||||
|
|
||||||
goreleaser:
|
goreleaser:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
27
.github/workflows/test.yml
vendored
27
.github/workflows/test.yml
vendored
|
|
@ -1,6 +1,11 @@
|
||||||
name: Test
|
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:
|
env:
|
||||||
GO_VERSION: '1.20'
|
GO_VERSION: '1.20'
|
||||||
|
|
@ -16,8 +21,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Run gofmt
|
- run: make test-format
|
||||||
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
|
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint (golangci-lint)
|
name: Lint (golangci-lint)
|
||||||
|
|
@ -29,13 +33,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Run golangci-lint
|
- run: make test-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:
|
test:
|
||||||
name: Test (go test)
|
name: Tests (go test)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [lint]
|
needs: [lint]
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -44,8 +45,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Run go test
|
- run: make test-unit
|
||||||
run: go test -race ./...
|
|
||||||
|
|
||||||
build-cli:
|
build-cli:
|
||||||
name: Build CLI (go build)
|
name: Build CLI (go build)
|
||||||
|
|
@ -57,7 +57,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: Run go build
|
- run: |
|
||||||
run: |
|
make build-cli
|
||||||
go build ./cli/battlesnake
|
battlesnake --help
|
||||||
./battlesnake --help
|
|
||||||
|
|
|
||||||
23
Makefile
Normal file
23
Makefile
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue