From b2faa8b743e7baf01bd8de1521972082ae327962 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 16 Feb 2018 20:38:45 -0200 Subject: [PATCH] chore: build, makefile, etc --- .goreleaser.yml | 51 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 21 +++++++++++++++++ Makefile | 63 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 .goreleaser.yml create mode 100644 .travis.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..adfb4327 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,51 @@ +builds: +- main: ./cmd/nfpm/... + hooks: + pre: packr + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 +dockers: + - image: goreleaser/nfpm + tag_templates: + - '{{ .Tag }}' + - 'v{{ .Major }}.{{ .Minor }}' + - 'latest' +archive: + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +brew: + github: + owner: goreleaser + name: homebrew-tap + folder: Formula + homepage: https://github.com/goreleaser/nfpm + description: NFPM is not FPM + test: | + system "#{bin}/nfpm -v" +scoop: + bucket: + owner: goreleaser + name: scoop-bucket + homepage: https://github.com/goreleaser/nfpm + description: NFPM is not FPM + license: MIT +fpm: # TODO: change to nfpm when released + name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + homepage: https://github.com/goreleaser/nfpm + description: NFPM is not FPM + maintainer: Carlos Alexandro Becker + license: MIT + vendor: GoReleaser + formats: + - deb + - rpm + # TODO: should be able to do that "suggested packages" thing diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..34109a2a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +dist: trusty +sudo: required +language: go +go: 1.9 +services: + - docker +install: + - make setup +script: + - make ci +after_success: + - bash <(curl -s https://codecov.io/bash) + - test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" +notifications: + email: false +deploy: + - provider: script + skip_cleanup: true + script: curl -sL http://git.io/goreleaser | bash + on: + tags: true diff --git a/Makefile b/Makefile index 047f220a..c55dd376 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,64 @@ +SOURCE_FILES?=./... +TEST_PATTERN?=. +TEST_OPTIONS?= + +# Install all the build and lint dependencies +setup: + go get -u github.com/alecthomas/gometalinter + go get -u github.com/golang/dep/cmd/dep + go get -u github.com/pierrre/gotestcover + go get -u golang.org/x/tools/cmd/cover + go get -u github.com/caarlos0/bandep + dep ensure + gometalinter --install + echo "make check" > .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit +.PHONY: setup + check: - bandep --ban github.com/tj/assert,github.com/alecthomas/template + bandep --ban github.com/tj/assert +.PHONY: check +# Run all the tests test: - go test -v ./... + gotestcover $(TEST_OPTIONS) -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m +.PHONY: cover + +# Run all the tests and opens the coverage report +cover: test + go tool cover -html=coverage.txt +.PHONY: cover + +# gofmt and goimports all go files +fmt: + find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done +.PHONY: fmt + +# Run all the linters +lint: + gometalinter --vendor ./... +.PHONY: lint + +# Run all the tests and code checks +ci: build test lint +.PHONY: ci + +# Build a beta version of goreleaser +build: + go generate ./... + go build +.PHONY: build + +# Show to-do items per file. +todo: + @grep \ + --exclude-dir=vendor \ + --exclude-dir=node_modules \ + --exclude=Makefile \ + --text \ + --color \ + -nRo -E ' TODO:.*|SkipNow|nolint:.*' . +.PHONY: todo + + +.DEFAULT_GOAL := build