diff --git a/.cirrus.yml b/.cirrus.yml index 33b4a08592..60b7c0d22e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -129,7 +129,10 @@ lint_task: build_script: | apt-get update apt-get install -y libbtrfs-dev libdevmapper-dev - test_script: make TAGS=regex_precompile local-validate && make lint && make clean + test_script: | + make TAGS=regex_precompile local-validate + make lint + make clean # Update metadata on VM images referenced by this repository state diff --git a/.golangci.yml b/.golangci.yml index 755aa35c0f..441363886c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,68 +4,8 @@ run: deadline: 5m skip-dirs-use-default: true linters: - enable-all: true disable: - - cyclop - - deadcode - - dogsled - - dupl - errcheck - - errname - - errorlint - - exhaustive - - exhaustivestruct - - exhaustruct - - forbidigo - - forcetypeassert - - funlen - - gci - - gochecknoglobals - - gochecknoinits - - gocognit - - gocritic - - gocyclo - - godot - - godox - - goerr113 - - gofumpt - - golint - - gomnd - - gosec - gosimple - govet - - ifshort - - ineffassign - - interfacer - - interfacebloat - - ireturn - - lll - - maintidx - - maligned - - misspell - - musttag - - nakedret - - nestif - - nlreturn - - nolintlint - - nonamedreturns - - nosnakecase - - paralleltest - - prealloc - - predeclared - - rowserrcheck - - scopelint - staticcheck - - structcheck - - stylecheck - - tagliatelle - - testpackage - - thelper - - unconvert - - unparam - - varcheck - - varnamelen - - wastedassign - - whitespace - - wrapcheck - - wsl diff --git a/Makefile b/Makefile index 42b3aceb4f..0569792312 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,18 @@ -export GO111MODULE=off -export GOPROXY=https://proxy.golang.org - .PHONY: \ all \ + binary \ clean \ + codespell \ + containers-storage \ + cross \ default \ docs \ + gccgo \ help \ + install \ + install.docs \ install.tools \ + lint \ local-binary \ local-cross \ local-gccgo \ @@ -15,33 +20,25 @@ export GOPROXY=https://proxy.golang.org local-test-integration \ local-test-unit \ local-validate \ - lint \ - vendor + test-integration \ + test-unit \ + validate \ + vendor \ + vendor-in-container -PACKAGE := github.com/containers/storage -GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) -GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") -EPOCH_TEST_COMMIT := 0418ebf59f9e1f564831c0ba9378b7f8e40a1c73 NATIVETAGS := AUTOTAGS := $(shell ./hack/btrfs_tag.sh) $(shell ./hack/libdm_tag.sh) $(shell ./hack/libsubid_tag.sh) BUILDFLAGS := -tags "$(AUTOTAGS) $(TAGS)" $(FLAGS) GO ?= go TESTFLAGS := $(shell $(GO) test -race $(BUILDFLAGS) ./pkg/stringutils 2>&1 > /dev/null && echo -race) -# Go module support: set `-mod=vendor` to use the vendored sources -ifeq ($(shell $(GO) help mod >/dev/null 2>&1 && echo true), true) - GO:=GO111MODULE=on $(GO) - MOD_VENDOR=-mod=vendor -endif - default all: local-binary docs local-validate local-cross ## validate all checks, build and cross-build\nbinaries and docs clean: ## remove all built files $(RM) -f containers-storage containers-storage.* docs/*.1 docs/*.5 -sources := $(wildcard *.go cmd/containers-storage/*.go drivers/*.go drivers/*/*.go internal/*/*.go pkg/*/*.go pkg/*/*/*.go types/*.go) -containers-storage: $(sources) ## build using gc on the host - $(GO) build $(MOD_VENDOR) -compiler gc $(BUILDFLAGS) ./cmd/containers-storage +containers-storage: ## build using gc on the host + $(GO) build -compiler gc $(BUILDFLAGS) ./cmd/containers-storage codespell: codespell -S Makefile,build,buildah,buildah.spec,imgtype,copy,AUTHORS,bin,vendor,.git,go.sum,CHANGELOG.md,changelog.txt,seccomp.json,.cirrus.yml,"*.xz,*.gz,*.tar,*.tgz,*ico,*.png,*.1,*.5,*.orig,*.rej" -L worl,flate,uint,iff,od,ERRO -w @@ -49,15 +46,15 @@ codespell: binary local-binary: containers-storage local-gccgo gccgo: ## build using gccgo on the host - GCCGO=$(PWD)/hack/gccgo-wrapper.sh $(GO) build $(MOD_VENDOR) -compiler gccgo $(BUILDFLAGS) -o containers-storage.gccgo ./cmd/containers-storage + GCCGO=$(PWD)/hack/gccgo-wrapper.sh $(GO) build -compiler gccgo $(BUILDFLAGS) -o containers-storage.gccgo ./cmd/containers-storage local-cross cross: ## cross build the binaries for arm, darwin, and freebsd @for target in linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64 linux/ppc64le linux/s390x linux/mips linux/mipsle linux/mips64 linux/mips64le darwin/amd64 windows/amd64 freebsd/amd64 freebsd/arm64 ; do \ os=`echo $${target} | cut -f1 -d/` ; \ arch=`echo $${target} | cut -f2 -d/` ; \ suffix=$${os}.$${arch} ; \ - echo env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO) build $(MOD_VENDOR) -compiler gc -tags \"$(NATIVETAGS) $(TAGS)\" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage ; \ - env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO) build $(MOD_VENDOR) -compiler gc -tags "$(NATIVETAGS) $(TAGS)" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage || exit 1 ; \ + echo env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO) build -compiler gc -tags \"$(NATIVETAGS) $(TAGS)\" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage ; \ + env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $(GO) build -compiler gc -tags "$(NATIVETAGS) $(TAGS)" $(FLAGS) -o containers-storage.$${suffix} ./cmd/containers-storage || exit 1 ; \ done docs: install.tools ## build the docs on the host @@ -66,7 +63,7 @@ docs: install.tools ## build the docs on the host local-test: local-binary local-test-unit local-test-integration ## build the binaries and run the tests local-test-unit test-unit: local-binary ## run the unit tests on the host (requires\nsuperuser privileges) - @$(GO) test -count 1 $(MOD_VENDOR) $(BUILDFLAGS) $(TESTFLAGS) $(shell $(GO) list ./... | grep -v ^$(PACKAGE)/vendor) + @$(GO) test -count 1 $(BUILDFLAGS) $(TESTFLAGS) ./... local-test-integration test-integration: local-binary ## run the integration tests on the host (requires\nsuperuser privileges) @cd tests; ./test_runner.bash @@ -78,9 +75,6 @@ local-validate validate: install.tools ## validate DCO and gofmt on the host install.tools: $(MAKE) -C tests/tools -$(FFJSON): - $(MAKE) -C tests/tools - install.docs: docs $(MAKE) -C docs install diff --git a/docs/Makefile b/docs/Makefile index 663ce44373..ff4c7fff9b 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,6 +4,7 @@ MANINSTALLDIR=${PREFIX}/share/man MANPAGES_MD = $(wildcard docs/*.5.md) MANPAGES ?= $(MANPAGES_MD:%.md=%) +.PHONY: docs docs: $(patsubst %.md,%.1,$(filter-out %.5.md,$(wildcard *.md))) containers-storage.conf.5 %.1: %.md @@ -12,6 +13,7 @@ docs: $(patsubst %.md,%.1,$(filter-out %.5.md,$(wildcard *.md))) containers-stor containers-storage.conf.5: containers-storage.conf.5.md $(GOMD2MAN) -in $^ -out $@ +.PHONY: install install: install -d -m 755 ${MANINSTALLDIR}/man5 install -m 644 *.5 ${MANINSTALLDIR}/man5/ diff --git a/tests/tools/Makefile b/tests/tools/Makefile index 35eb2d8df9..9cc9eedfcc 100644 --- a/tests/tools/Makefile +++ b/tests/tools/Makefile @@ -1,20 +1,16 @@ -export GO111MODULE=off - GO := go - BUILDDIR := build all: $(BUILDDIR) .PHONY: vendor vendor: - export GO111MODULE=on \ - $(GO) mod tidy && \ - $(GO) mod vendor && \ - $(GO) mod verify + $(GO) mod tidy + $(GO) mod vendor + $(GO) mod verify define go-build - $(shell cd `pwd` && $(GO) build -o $(BUILDDIR)/$(shell basename $(1)) $(1)) + $(shell cd `pwd` && $(GO) build -mod=vendor -o $(BUILDDIR)/$(shell basename $(1)) $(1)) @echo > /dev/null endef @@ -33,9 +29,6 @@ $(BUILDDIR)/git-validation: $(BUILDDIR)/go-md2man: $(call go-build,./vendor/github.com/cpuguy83/go-md2man) +$(BUILDDIR)/golangci-lint: VERSION=v1.51.2 $(BUILDDIR)/golangci-lint: - export \ - VERSION=v1.51.2 \ - URL=https://raw.githubusercontent.com/golangci/golangci-lint \ - BINDIR=$(BUILDDIR) && \ - curl -sfL $$URL/$$VERSION/install.sh | sh -s $$VERSION + curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/$(VERSION)/install.sh | sh -s -- -b ./$(BUILDDIR) $(VERSION) diff --git a/tests/tools/go.mod b/tests/tools/go.mod index d0f1571353..6a5d78aa54 100644 --- a/tests/tools/go.mod +++ b/tests/tools/go.mod @@ -1,9 +1,16 @@ module github.com/containers/storage/tests/tools -go 1.13 +go 1.18 require ( github.com/cpuguy83/go-md2man v1.0.10 github.com/vbatts/git-validation v1.0.0 +) + +require ( + github.com/hashicorp/go-version v1.2.0 // indirect + github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect + github.com/russross/blackfriday v1.5.2 // indirect + github.com/sirupsen/logrus v1.4.1 // indirect golang.org/x/sys v0.5.0 // indirect ) diff --git a/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.mod b/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.mod deleted file mode 100644 index 052bd20ea2..0000000000 --- a/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/cpuguy83/go-md2man - -go 1.12 - -require github.com/russross/blackfriday v1.5.2 diff --git a/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.sum b/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.sum deleted file mode 100644 index f4c80c7278..0000000000 --- a/tests/tools/vendor/github.com/cpuguy83/go-md2man/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= diff --git a/tests/tools/vendor/github.com/hashicorp/go-version/go.mod b/tests/tools/vendor/github.com/hashicorp/go-version/go.mod deleted file mode 100644 index f5285555fa..0000000000 --- a/tests/tools/vendor/github.com/hashicorp/go-version/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/hashicorp/go-version diff --git a/tests/tools/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/tests/tools/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod deleted file mode 100644 index 716c613125..0000000000 --- a/tests/tools/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/konsorten/go-windows-terminal-sequences diff --git a/tests/tools/vendor/github.com/russross/blackfriday/go.mod b/tests/tools/vendor/github.com/russross/blackfriday/go.mod deleted file mode 100644 index b05561a066..0000000000 --- a/tests/tools/vendor/github.com/russross/blackfriday/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/russross/blackfriday diff --git a/tests/tools/vendor/github.com/sirupsen/logrus/go.mod b/tests/tools/vendor/github.com/sirupsen/logrus/go.mod deleted file mode 100644 index 8261a2b3a2..0000000000 --- a/tests/tools/vendor/github.com/sirupsen/logrus/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module github.com/sirupsen/logrus - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.1 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.1.1 // indirect - github.com/stretchr/testify v1.2.2 - golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 -) diff --git a/tests/tools/vendor/github.com/sirupsen/logrus/go.sum b/tests/tools/vendor/github.com/sirupsen/logrus/go.sum deleted file mode 100644 index 2d787be60d..0000000000 --- a/tests/tools/vendor/github.com/sirupsen/logrus/go.sum +++ /dev/null @@ -1,13 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs= -github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/tests/tools/vendor/github.com/vbatts/git-validation/go.mod b/tests/tools/vendor/github.com/vbatts/git-validation/go.mod deleted file mode 100644 index 14b7069e79..0000000000 --- a/tests/tools/vendor/github.com/vbatts/git-validation/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/vbatts/git-validation - -go 1.12 - -require ( - github.com/hashicorp/go-version v1.2.0 - github.com/sirupsen/logrus v1.4.1 -) diff --git a/tests/tools/vendor/github.com/vbatts/git-validation/go.sum b/tests/tools/vendor/github.com/vbatts/git-validation/go.sum deleted file mode 100644 index 265941fe3f..0000000000 --- a/tests/tools/vendor/github.com/vbatts/git-validation/go.sum +++ /dev/null @@ -1,15 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/tests/tools/vendor/modules.txt b/tests/tools/vendor/modules.txt index bd6dc90a67..7621cb74d5 100644 --- a/tests/tools/vendor/modules.txt +++ b/tests/tools/vendor/modules.txt @@ -1,15 +1,21 @@ # github.com/cpuguy83/go-md2man v1.0.10 +## explicit; go 1.12 github.com/cpuguy83/go-md2man github.com/cpuguy83/go-md2man/md2man # github.com/hashicorp/go-version v1.2.0 +## explicit github.com/hashicorp/go-version # github.com/konsorten/go-windows-terminal-sequences v1.0.1 +## explicit github.com/konsorten/go-windows-terminal-sequences # github.com/russross/blackfriday v1.5.2 +## explicit github.com/russross/blackfriday # github.com/sirupsen/logrus v1.4.1 +## explicit github.com/sirupsen/logrus # github.com/vbatts/git-validation v1.0.0 +## explicit; go 1.12 github.com/vbatts/git-validation github.com/vbatts/git-validation/git github.com/vbatts/git-validation/rules/danglingwhitespace @@ -18,4 +24,5 @@ github.com/vbatts/git-validation/rules/messageregexp github.com/vbatts/git-validation/rules/shortsubject github.com/vbatts/git-validation/validate # golang.org/x/sys v0.5.0 +## explicit; go 1.17 golang.org/x/sys/unix