Merge pull request #192 from c-bata/github-actions-test

Run tests on GitHub Actions
This commit is contained in:
Masashi SHIBATA 2020-09-19 00:12:12 +09:00 committed by GitHub
commit 7e3ac9d2e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 56 deletions

62
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,62 @@
name: Run tests
on:
pull_request:
branches:
- master
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Running go tests
env:
GO111MODULE: on
run: make test
examples:
name: Build examples
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Building go examples
env:
GO111MODULE: on
run: ./_example/build.sh
lint:
name: Run lint checks
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: Download golangci-lint
run: |
wget https://github.com/golangci/golangci-lint/releases/download/v1.31.0/golangci-lint-1.31.0-linux-amd64.tar.gz
tar -xvf ./golangci-lint-1.31.0-linux-amd64.tar.gz
- name: Running golangci-lint
env:
GO111MODULE: on
GOPATH: /home/runner/work/
run: GOCILINT=./golangci-lint-1.31.0-linux-amd64/golangci-lint make lint

View File

@ -1,50 +0,0 @@
sudo: false
language: go
go:
- "1.11.x"
- tip
os:
- linux
- osx
- windows
env:
- GO111MODULE=on
cache:
directories:
- $GOPATH/pkg/mod/cache
install:
- GO111MODULE=off go get -u golang.org/x/lint/golint
- GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
stages:
- lint
- examples
- test
jobs:
include:
- stage: lint
script:
- diff <(goimports -d $(find . -type f -name '*.go')) <(echo -n "")
- make lint
go: "1.11.x"
os: osx
- stage: examples
script:
- ./_example/build.sh
go: "1.11.x"
os: osx
script:
- go test -race ./...
matrix:
fast_finish: true
allow_failures:
- go: tip
- os: windows

View File

@ -1,22 +1,23 @@
.DEFAULT_GOAL := help
PKGS := $(shell go list ./...)
SOURCES := $(shell find . -prune -o -name "*.go" -not -name '*_test.go' -print)
GOIMPORTS ?= goimports
GOCILINT ?= golangci-lint
.PHONY: setup
setup: ## Setup for required tools.
go get -u golang.org/x/lint/golint
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u golang.org/x/tools/cmd/stringer
.PHONY: fmt
fmt: $(SOURCES) ## Formatting source codes.
@goimports -w $^
@$(GOIMPORTS) -w $^
.PHONY: lint
lint: ## Run golint and go vet.
@golint -set_exit_status=1 $(PKGS)
@go vet $(PKGS)
lint: ## Run golangci-lint.
@$(GOCILINT) run --no-config --disable-all --enable=goimports --enable=misspell ./...
.PHONY: test
test: ## Run tests with race condition checking.