mirror of
https://github.com/spf13/viper
synced 2025-05-06 04:07:17 +00:00
Merge pull request #17 from DataDog/dustin.mitchell/add-ci
Copy CI workflows from `spf13/viper` repo
This commit is contained in:
commit
8e7459bcf3
3 changed files with 112 additions and 31 deletions
36
.github/workflows/ci.yml
vendored
Normal file
36
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
go: ['1.14', '1.15', '1.16']
|
||||
env:
|
||||
VERBOSE: 1
|
||||
GOFLAGS: -mod=readonly
|
||||
GOPROXY: https://proxy.golang.org
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# the DataDog fork of this repository has many lint failures
|
||||
# - name: Lint
|
||||
# run: make lint
|
||||
|
||||
- name: Test
|
||||
run: make test
|
31
.travis.yml
31
.travis.yml
|
@ -1,31 +0,0 @@
|
|||
language: go
|
||||
|
||||
env:
|
||||
global:
|
||||
- GO111MODULE="on"
|
||||
|
||||
go:
|
||||
- 1.14.x
|
||||
- tip
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip
|
||||
fast_finish: true
|
||||
|
||||
install: true
|
||||
|
||||
script:
|
||||
- diff -u <(echo -n) <(gofmt -d .)
|
||||
- go mod vendor
|
||||
- go test -v -mod=readonly ./...
|
||||
|
||||
after_success:
|
||||
- go get -u -d github.com/spf13/hugo
|
||||
- cd $GOPATH/src/github.com/spf13/hugo && make && ./hugo -s docs && cd -
|
||||
|
||||
sudo: false
|
76
Makefile
Normal file
76
Makefile
Normal file
|
@ -0,0 +1,76 @@
|
|||
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
|
||||
|
||||
OS = $(shell uname | tr A-Z a-z)
|
||||
export PATH := $(abspath bin/):${PATH}
|
||||
|
||||
# Build variables
|
||||
BUILD_DIR ?= build
|
||||
export CGO_ENABLED ?= 0
|
||||
export GOOS = $(shell go env GOOS)
|
||||
ifeq (${VERBOSE}, 1)
|
||||
ifeq ($(filter -v,${GOARGS}),)
|
||||
GOARGS += -v
|
||||
endif
|
||||
TEST_FORMAT = short-verbose
|
||||
endif
|
||||
|
||||
# Dependency versions
|
||||
GOTESTSUM_VERSION = 1.6.4
|
||||
GOLANGCI_VERSION = 1.40.1
|
||||
|
||||
# Add the ability to override some variables
|
||||
# Use with care
|
||||
-include override.mk
|
||||
|
||||
.PHONY: clear
|
||||
clear: ## Clear the working area and the project
|
||||
rm -rf bin/
|
||||
|
||||
.PHONY: check
|
||||
check: test lint ## Run tests and linters
|
||||
|
||||
bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION}
|
||||
@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum
|
||||
bin/gotestsum-${GOTESTSUM_VERSION}:
|
||||
@mkdir -p bin
|
||||
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 ?= ./...
|
||||
.PHONY: test
|
||||
test: TEST_FORMAT ?= short
|
||||
test: SHELL = /bin/bash
|
||||
test: export CGO_ENABLED=1
|
||||
test: bin/gotestsum ## Run tests
|
||||
@mkdir -p ${BUILD_DIR}
|
||||
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}
|
||||
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
|
||||
bin/golangci-lint-${GOLANGCI_VERSION}:
|
||||
@mkdir -p bin
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
|
||||
@mv bin/golangci-lint "$@"
|
||||
|
||||
.PHONY: lint
|
||||
lint: bin/golangci-lint ## Run linter
|
||||
bin/golangci-lint run
|
||||
|
||||
.PHONY: fix
|
||||
fix: bin/golangci-lint ## Fix lint violations
|
||||
bin/golangci-lint run --fix
|
||||
|
||||
# Add custom targets here
|
||||
-include custom.mk
|
||||
|
||||
.PHONY: list
|
||||
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
|
||||
|
||||
.PHONY: help
|
||||
.DEFAULT_GOAL := help
|
||||
help:
|
||||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
# Variable outputting/exporting rules
|
||||
var-%: ; @echo $($*)
|
||||
varexport-%: ; @echo $*=$($*)
|
Loading…
Add table
Reference in a new issue