This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic move to gomodules and linter setup
- Loading branch information
Edward Muller
committed
Sep 9, 2019
1 parent
47ecf50
commit 6153d4d
Showing
9 changed files
with
370 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# See https://github.com/golangci/golangci-lint#config-file | ||
run: | ||
deadline: 1m #Default | ||
issues-exit-code: 1 #Default | ||
tests: true #Default | ||
|
||
linters: | ||
enable: | ||
- misspell | ||
- goimports | ||
- golint | ||
- stylecheck | ||
- unconvert | ||
- dupl | ||
- gosec | ||
- scopelint | ||
- nakedret | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- lll | ||
- maligned | ||
- prealloc | ||
- unparam | ||
- errcheck | ||
|
||
issues: | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- goconst # Don't run on test files because they may often repeate the same string | ||
- scopelint # Otherwise you need tc := tc. This isn't actually a problem unless tests are being run in parallel. | ||
- lll # Don't do line length checks in test code. | ||
- dupl # Sometimes we duplicate a bunch in tests for the sake of clarity. | ||
- path: nacl/secretbox | ||
linters: | ||
- gosec # Don't run gosec on nacl/secretbox* because we know it uses crypto/md5. TODO: Evaluate if this makes sense. | ||
- path: hmetrics/onload/init.go | ||
linters: | ||
- gochecknoinits # The whole point of this package is to use init | ||
- path: cmd/s3env/main.go | ||
linters: | ||
- gochecknoinits # TODO: FixMe | ||
- path: go-kit/metrics/provider/librato/librato_test.go | ||
linters: | ||
- gocyclo # TODO: Refactor TestLibratoHistogramJSONMarshalers | ||
- path: grpc/ | ||
linters: | ||
- lll # GRPC code has notoriously long function signatures. | ||
- path: go-kit/metrics/provider/librato/librato.go | ||
linters: | ||
- maligned # TODO: evaluate if this makes sense | ||
|
||
linters-settings: | ||
misspell: | ||
locale: US | ||
#ignore-words: | ||
# - someword | ||
goimports: | ||
local-prefixes: github.com/heroku/x | ||
gocyclo: | ||
# minimal code complexity to report, 30 by default (but we recommend 10-20) | ||
min-complexity: 14 | ||
lll: | ||
# max line length, lines longer will be reported. Default is 120. | ||
line-length: 130 | ||
maligned: | ||
suggest-new: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
language: go | ||
go: 1.7.1 | ||
go: | ||
- 1.13.X | ||
- 1.12.X | ||
- 1.11.X | ||
sudo: false | ||
script: make travis | ||
env: | ||
global: | ||
- GO111MODULE=on | ||
- GOTEST_OPT="-v -race" | ||
- LINT_RUN_OPTS="" | ||
script: make test | ||
notifications: | ||
email: false |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*") | ||
GO_PACKAGES := $(shell go list ./... | sed "s/github.com\/heroku\/docker-registry-client/./" | grep -v "^./vendor/") | ||
|
||
build: | ||
go build -v $(GO_PACKAGES) | ||
|
||
travis: tidy test | ||
|
||
test: build | ||
go fmt $(GO_PACKAGES) | ||
go test -race -i $(GO_PACKAGES) | ||
go test -race -v $(GO_PACKAGES) | ||
|
||
# Setup & Code Cleanliness | ||
setup: hooks tidy | ||
|
||
hooks: | ||
ln -fs ../../bin/git-pre-commit.sh .git/hooks/pre-commit | ||
|
||
tidy: goimports | ||
test -z "$$(goimports -l -d $(GO_FILES) | tee /dev/stderr)" | ||
go vet $(GO_PACKAGES) | ||
|
||
precommit: tidy test | ||
|
||
goimports: | ||
go get golang.org/x/tools/cmd/goimports | ||
PKG_SPEC = ./registry/... | ||
MOD = -mod=readonly | ||
GOTEST = go test $(MOD) | ||
GOTEST_COVERAGE_OPT = -coverprofile=coverage.txt -covermode=atomic | ||
TOOLS_DIR = $(shell git rev-parse --show-toplevel)/.tools | ||
GOBUILD = go build $(MOD) | ||
|
||
ENV ?= development | ||
LINT_RUN_OPTS ?= --fix | ||
override GOTEST_OPT += -timeout 30s | ||
|
||
.DEFAULT_GOAL := precommit | ||
|
||
$(TOOLS_DIR)/golangci-lint: go.mod go.sum tools.go | ||
$(GOBUILD) -o $(TOOLS_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
.PHONY: vars | ||
vars: | ||
@echo "PKG_SPEC=$(PKG_SPEC)" | ||
@echo "MOD=$(MOD)" | ||
@echo "GOTEST=$(GOTEST)" | ||
@echo "COVERAGE_OPT=$(COVERAGE_OPT)" | ||
@echo "TOOLS_DIR=$(TOOLS_DIR)" | ||
@echo "GOBUILD=$(GOBUILD)" | ||
@echo "ENV=$(ENV)" | ||
|
||
.PHONY: precommit | ||
precommit: lint test coverage | ||
|
||
.PHONY: lint | ||
lint: $(TOOLS_DIR)/golangci-lint | ||
$(TOOLS_DIR)/golangci-lint run $(LINT_RUN_OPTS) | ||
|
||
.PHONY: coverage | ||
coverage: | ||
$(GOTEST) $(GOTEST_OPT) $(GOTEST_COVERAGE_OPT) $(PKG_SPEC) | ||
go tool cover -html=coverage.txt -o coverage.html | ||
|
||
.PHONY: test | ||
test: | ||
$(GOTEST) $(GOTEST_OPT) $(PKG_SPEC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/heroku/docker-registry-client | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/docker/distribution v0.0.0-20171011171712-7484e51bf6af | ||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect | ||
github.com/golangci/golangci-lint v1.17.1 | ||
github.com/gorilla/mux v1.7.3 // indirect | ||
github.com/opencontainers/go-digest v1.0.0-rc1 | ||
github.com/stretchr/testify v1.4.0 // indirect | ||
) |
Oops, something went wrong.