Skip to content

Commit

Permalink
sync with go module template
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Mar 22, 2020
1 parent b775d17 commit 169621e
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 82 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
.gitignore export-ignore
.travis.yml export-ignore

Makefile export-ignore
/.github/ export-ignore

Makefile export-ignore
*.md export-ignore

*_test.go export-ignore
testdata/ export-ignore
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# code coverage and quality reports
*.out

# binaries
cc-test-reporter
61 changes: 33 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
sudo: false
language: go
os: linux

cache:
directories:
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
- "$HOME/.cache/go-build"
- "$HOME/gopath/pkg/mod"

env:
global:
- CODECLIMATE=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
- GO111MODULE=on
- GOFLAGS=-mod=vendor
- CODECLIMATE=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64

go:
- master
- 1.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x

matrix:
- master
- 1.x
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x

go_import_path: github.com/kamilsk/tracer

jobs:
allow_failures:
- go: 1.7.x
- go: 1.8.x
- go: 1.9.x
- go: master

before_script:
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then curl -L $CODECLIMATE > ./cc-test-reporter; fi
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then chmod +x ./cc-test-reporter; fi
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then ./cc-test-reporter before-build; fi
- |
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then
curl -L $CODECLIMATE > /home/travis/gopath/bin/cc-test-reporter
chmod +x /home/travis/gopath/bin/cc-test-reporter
cc-test-reporter before-build
fi
script:
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then make test-with-coverage-profile; else make test; fi
- |
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then
make test-with-coverage-profile
else
make test
fi
after_script:
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then export EXIT_CODE=$TRAVIS_TEST_RESULT; fi
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then export PREFIX=$(basename $(go list -m)); fi
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then ./cc-test-reporter after-build -t gocov -p $PREFIX; fi
- |
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then
cc-test-reporter after-build -t gocov -p $(basename $(go list -m)) --exit-code $TRAVIS_TEST_RESULT
fi
notifications:
slack: octolab:1eMS7IqOArBipiu31jYVd0cN
slack:
secure: VHWCBgcxc9BejOM9pSTqAyXzZN6DEW/UzJKGkNX+lWL1wREIDmJ7iFKM1ZUfTwU6j5WtOE4ruJlfpUlmmlzicqTZUBIkGCJH6LoX9kwP+6IKBD/aCFuGwRuptKKU0I8pLV6Jvs2m2WQBlKQrfSX9IIM4zqb0M+ST067huwRscJP/4bJJ2aPg+dQiGeR3VHLit/izMRzk/IjnT093i3qGlXDhdRZrxnlqd5flmSlnU5sBTfRr9wHcMdrxIXK3smhay/w8M7XeuIgpv9mUjizmg5e+bQkm4e8AZZxYasvUQAdLWWylcwMk9xPHYy9QGKRFTSl1weon6rRrXWVXP1b9PpR8PYeg1qPvV0k+QNKokDdveqzd2N6ZAilRqAMNVYYYnI1fgLTySfBdIXKMwZAM8OnQk0BBBfyPp+FkoB/zewC6pFy54w7gM2pjefdV3RWjOsc6ux/W6Ro2msZufDW1OzJU4Yj4uzWCtZdsjjkGcA2fB9cDQWlhhmkYVpc7tDfhQ2GFgRmTvuvCvZP2jfUbHcMTgK1CW0+zbX5gsGorWCrMvHL6boV3iRydndOvCFKBUFdDDPvKBjbRIJRuoNprpSmhjWwRYZdUUD+HU/S64vm4mKiWoLhP3hUeDHKSg26F7GomvEGoVz2MCkaqXteRUi9tAhNJIjy88a/l354IMWg=
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 OctoLab, https://www.octolab.org/ <[email protected]>
Copyright (c) 2020 OctoLab, https://www.octolab.org/ <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
112 changes: 89 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,52 +1,118 @@
# sourced by https://github.com/octomation/makefiles

.DEFAULT_GOAL = test-with-coverage

SHELL = /bin/bash -euo pipefail

GO111MODULE = on
GOFLAGS = -mod=vendor
MODULE = $(shell go list -m)
PACKAGES = $(shell go list ./...)
PATHS = $(shell go list ./... | sed -e "s|\s+$(shell go list -m)/\{0,1\}||g")
SHELL = /bin/bash -euo pipefail
GOPRIVATE = go.octolab.net
GOPROXY = direct
LOCAL = $(MODULE)
MODULE = `go list -m`
PACKAGES = `go list ./... 2> /dev/null`
PATHS = $(shell echo $(PACKAGES) | sed -e "s|$(MODULE)/\{0,1\}||g")
TIMEOUT = 1s

.DEFAULT_GOAL = test-with-coverage
ifeq (, $(PACKAGES))
PACKAGES = $(MODULE)
endif

.PHONY: env
env:
@echo "GO111MODULE: $(GO111MODULE)"
@echo "GOFLAGS: $(GOFLAGS)"
ifeq (, $(PATHS))
PATHS = .
endif

export GO111MODULE := $(GO111MODULE)
export GOFLAGS := $(GOFLAGS)
export GOPRIVATE := $(GOPRIVATE)
export GOPROXY := $(GOPROXY)

.PHONY: go-env
go-env:
@echo "GO111MODULE: `go env GO111MODULE`"
@echo "GOFLAGS: $(strip `go env GOFLAGS`)"
@echo "GOPRIVATE: $(strip `go env GOPRIVATE`)"
@echo "GOPROXY: $(strip `go env GOPROXY`)"
@echo "LOCAL: $(LOCAL)"
@echo "MODULE: $(MODULE)"
@echo "PACKAGES: $(PACKAGES)"
@echo "PATHS: $(PATHS)"
@echo "SHELL: $(SHELL)"
@echo "PATHS: $(strip $(PATHS))"
@echo "TIMEOUT: $(TIMEOUT)"

.PHONY: deps-check
deps-check:
@go mod verify
@if command -v egg > /dev/null; then \
egg deps check license; \
egg deps check version; \
fi

.PHONY: deps
deps:
@go mod tidy && go mod vendor && go mod verify
.PHONY: deps-clean
deps-clean:
@go clean -modcache

.PHONY: format
format:
@goimports -local $(dir $(shell go list -m)) -ungroup -w $(PATHS)
.PHONY: deps-shake
deps-shake:
@go mod tidy

.PHONY: generate
generate:
@go generate $(PACKAGES)
.PHONY: module-deps
module-deps:
@go mod download
@if [[ "`go env GOFLAGS`" =~ -mod=vendor ]]; then go mod vendor; fi

.PHONY: update
update: selector = '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}'
update:
@go get -mod= -u
@if command -v egg > /dev/null; then \
packages="`egg deps list`"; \
else \
packages="`go list -f $(selector) -m all`"; \
fi; go get -d -mod= -u $$packages

.PHONY: refresh
refresh: update deps generate format test-with-coverage
.PHONY: update-all
update-all:
@go get -d -mod= -u ./...

.PHONY: format
format:
@goimports -local $(LOCAL) -ungroup -w $(PATHS)

.PHONY: go-generate
go-generate:
@go generate $(PACKAGES)

.PHONY: lint
lint:
@golangci-lint run ./...

.PHONY: test
test:
@go test -race -timeout $(TIMEOUT) $(PACKAGES)

.PHONY: test-clean
test-clean:
@go clean -testcache

.PHONY: test-with-coverage
test-with-coverage:
@go test -cover -timeout $(TIMEOUT) $(PACKAGES) | column -t | sort -r

.PHONY: test-with-coverage-profile
test-with-coverage-profile:
@go test -cover -covermode count -coverprofile c.out -timeout $(TIMEOUT) $(PACKAGES)


.PHONY: clean
clean: deps-clean test-clean

.PHONY: deps
deps: module-deps

.PHONY: env
env: go-env

.PHONY: generate
generate: go-generate format

.PHONY: refresh
refresh: deps-shake update deps generate format test
49 changes: 23 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
> # 🧶 tracer
>
> Simple, lightweight tracing.
> Dead simple, lightweight tracing.
[![Build][icon_build]][page_build]
[![Quality][icon_quality]][page_quality]
[![Documentation][icon_docs]][page_docs]
[![Coverage][icon_coverage]][page_coverage]
[![Awesome][icon_awesome]][page_awesome]
[![Build][build.icon]][build.page]
[![Documentation][docs.icon]][docs.page]
[![Quality][quality.icon]][quality.page]
[![Template][template.icon]][template.page]
[![Coverage][coverage.icon]][coverage.page]
[![Awesome][awesome.icon]][awesome.page]

## 💡 Idea

Expand Down Expand Up @@ -105,34 +106,30 @@ allocates at call stack: 0, detailed call stack:

The library uses [SemVer](https://semver.org) for versioning, and it is not
[BC](https://en.wikipedia.org/wiki/Backward_compatibility)-safe through major releases.
You can use [go modules](https://github.com/golang/go/wiki/Modules) or
[dep](https://golang.github.io/dep/) to manage its version.
You can use [go modules](https://github.com/golang/go/wiki/Modules) to manage its version.

```bash
$ go get -u github.com/kamilsk/tracer

$ dep ensure -add github.com/kamilsk/tracer
$ go get github.com/kamilsk/tracer@latest
```

---

made with ❤️ for everyone

[icon_awesome]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
[icon_build]: https://travis-ci.org/kamilsk/tracer.svg?branch=master
[icon_coverage]: https://api.codeclimate.com/v1/badges/fb66449d1f5c64542377/test_coverage
[icon_docs]: https://godoc.org/github.com/kamilsk/tracer?status.svg
[icon_quality]: https://goreportcard.com/badge/github.com/kamilsk/tracer

[page_awesome]: https://github.com/avelino/awesome-go#performance
[page_build]: https://travis-ci.org/kamilsk/tracer
[page_coverage]: https://codeclimate.com/github/kamilsk/tracer/test_coverage
[page_docs]: https://godoc.org/github.com/kamilsk/tracer
[page_quality]: https://goreportcard.com/report/github.com/kamilsk/tracer

[design]: https://www.notion.so/octolab/tracer-098c6f9fe97b41dcac4a30074463dc8f?r=0b753cbf767346f5a6fd51194829a2f3
[egg]: https://github.com/kamilsk/egg
[promo]: https://github.com/kamilsk/tracer
[awesome.page]: https://github.com/avelino/awesome-go#performance
[awesome.icon]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
[build.page]: https://travis-ci.org/kamilsk/tracer
[build.icon]: https://travis-ci.org/kamilsk/tracer.svg?branch=master
[coverage.page]: https://codeclimate.com/github/kamilsk/tracer/test_coverage
[coverage.icon]: https://api.codeclimate.com/v1/badges/fb66449d1f5c64542377/test_coverage
[design.page]: https://www.notion.so/octolab/tracer-098c6f9fe97b41dcac4a30074463dc8f?r=0b753cbf767346f5a6fd51194829a2f3
[docs.page]: https://pkg.go.dev/github.com/kamilsk/tracer
[docs.icon]: https://img.shields.io/badge/docs-pkg.go.dev-blue
[promo.page]: https://github.com/kamilsk/tracer
[quality.page]: https://goreportcard.com/report/github.com/kamilsk/tracer
[quality.icon]: https://goreportcard.com/badge/github.com/kamilsk/tracer
[template.page]: https://github.com/octomation/go-module
[template.icon]: https://img.shields.io/badge/template-go--module-blue

[tmp.docs]: https://nicedoc.io/kamilsk/tracer?theme=dark
[tmp.history]: https://github.githistory.xyz/kamilsk/tracer/blob/master/README.md

0 comments on commit 169621e

Please sign in to comment.