Improve CI

This commit is contained in:
Mark Sagi-Kazar 2020-01-16 19:27:10 +01:00
parent 9cd571279d
commit 4525543ce4
No known key found for this signature in database
GPG key ID: 34CC109EB5ED1C2A
2 changed files with 12 additions and 8 deletions

View file

@ -11,7 +11,6 @@ jobs:
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
max-parallel: 10
matrix: matrix:
go: ['1.11', '1.12', '1.13'] go: ['1.11', '1.12', '1.13']
env: env:
@ -26,7 +25,7 @@ jobs:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Checkout code - name: Checkout code
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Run tests - name: Run tests
run: make test run: make test

View file

@ -1,9 +1,12 @@
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
OS = $(shell uname | tr A-Z a-z) OS = $(shell uname | tr A-Z a-z)
export PATH := $(abspath bin/):${PATH}
# Build variables # Build variables
BUILD_DIR ?= build BUILD_DIR ?= build
export CGO_ENABLED ?= 0
export GOOS = $(shell go env GOOS)
ifeq (${VERBOSE}, 1) ifeq (${VERBOSE}, 1)
ifeq ($(filter -v,${GOARGS}),) ifeq ($(filter -v,${GOARGS}),)
GOARGS += -v GOARGS += -v
@ -12,7 +15,7 @@ TEST_FORMAT = short-verbose
endif endif
# Dependency versions # Dependency versions
GOTESTSUM_VERSION = 0.3.5 GOTESTSUM_VERSION = 0.4.0
GOLANGCI_VERSION = 1.21.0 GOLANGCI_VERSION = 1.21.0
# Add the ability to override some variables # Add the ability to override some variables
@ -33,20 +36,19 @@ bin/gotestsum-${GOTESTSUM_VERSION}:
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION} curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION}
TEST_PKGS ?= ./... TEST_PKGS ?= ./...
TEST_REPORT_NAME ?= results.xml
.PHONY: test .PHONY: test
test: TEST_REPORT ?= main
test: TEST_FORMAT ?= short test: TEST_FORMAT ?= short
test: SHELL = /bin/bash test: SHELL = /bin/bash
test: export CGO_ENABLED=1
test: bin/gotestsum ## Run tests test: bin/gotestsum ## Run tests
@mkdir -p ${BUILD_DIR}/test_results/${TEST_REPORT} @mkdir -p ${BUILD_DIR}
bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/test_results/${TEST_REPORT}/${TEST_REPORT_NAME} --format ${TEST_FORMAT} -- $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...) bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...)
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint @ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}: bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p bin @mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION} curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@ @mv bin/golangci-lint $@
.PHONY: lint .PHONY: lint
@ -57,6 +59,9 @@ lint: bin/golangci-lint ## Run linter
fix: bin/golangci-lint ## Fix lint violations fix: bin/golangci-lint ## Fix lint violations
bin/golangci-lint run --fix bin/golangci-lint run --fix
# Add custom targets here
-include custom.mk
.PHONY: list .PHONY: list
list: ## List all make targets list: ## List all make targets
@${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort @${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort