2017-04-25 19:57:06 +03:00
#
2017-05-09 19:38:23 +03:00
# github.com/docker/cli
2017-04-25 19:57:06 +03:00
#
2021-10-11 17:54:09 +03:00
# Sets the name of the company that produced the windows binary.
2022-03-27 11:09:50 +03:00
PACKAGER_NAME ?=
2021-10-11 17:54:09 +03:00
Use gofumpt if available, and enable gofumpt linter
gofumpt provides a supserset of gofmt / go fmt, but not every developer may have
it installed, so for situations where it's not available, fall back to gofmt.
As our code has been formatted with gofumpt already, in most cases contributions
will follow those formatting rules, but in some cases there may be a difference,
which would already be flagged by manual code review, but let's also enable the
gofumpt linter.
With this change, `make fmt` will use gofumpt is available; gofumpt has been
added to the dev-container, so `make -f docker.Makefile fmt` will always use it.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 14:10:53 +03:00
# The repository doesn't have a go.mod, but "go list", and "gotestsum"
# expect to be run from a module.
GO111MODULE = auto
export GO111MODULE
2017-05-14 20:24:10 +03:00
all : binary
2017-06-23 07:52:34 +03:00
_ := $( shell ./scripts/warn-outside-container $( MAKECMDGOALS) )
2022-04-06 20:10:53 +03:00
.PHONY : dev
dev : ## start a build container in interactive mode for in-container development
@if [ -n " ${ DISABLE_WARN_OUTSIDE_CONTAINER } " ] ; then \
echo "you are already in the dev container" ; \
else \
$( MAKE) -f docker.Makefile dev; \
fi
.PHONY : shell
shell : dev ## alias for dev
2017-05-10 00:29:14 +03:00
.PHONY : clean
2017-07-19 18:44:39 +03:00
clean : ## remove build artifacts
2022-02-25 19:05:35 +03:00
rm -rf ./build/* man/man[ 1-9] docs/yaml
2017-04-25 19:57:06 +03:00
2017-08-31 01:06:22 +03:00
.PHONY : test
test : test -unit ## run tests
2021-12-07 16:50:16 +03:00
.PHONY : test -unit
test-unit : ## run unit tests, to change the output format use: GOTESTSUM_FORMAT=(dots|short|standard-quiet|short-verbose|standard-verbose) make test-unit
gotestsum -- $$ { TESTDIRS:-$( shell go list ./... | grep -vE '/vendor/|/e2e/' ) } $( TESTFLAGS)
2017-05-18 11:48:24 +03:00
.PHONY : test -coverage
2017-07-19 18:44:39 +03:00
test-coverage : ## run test coverage
2021-12-07 16:50:16 +03:00
mkdir -p $( CURDIR) /build/coverage
gotestsum -- $( shell go list ./... | grep -vE '/vendor/|/e2e/' ) -coverprofile= $( CURDIR) /build/coverage/coverage.txt
2017-05-18 11:48:24 +03:00
2021-09-26 19:01:38 +03:00
.PHONY : lint
lint : ## run all the lint tools
golangci-lint run
.PHONY : shellcheck
shellcheck : ## run shellcheck validation
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
2018-12-10 16:17:14 +03:00
.PHONY : fmt
Use gofumpt if available, and enable gofumpt linter
gofumpt provides a supserset of gofmt / go fmt, but not every developer may have
it installed, so for situations where it's not available, fall back to gofmt.
As our code has been formatted with gofumpt already, in most cases contributions
will follow those formatting rules, but in some cases there may be a difference,
which would already be flagged by manual code review, but let's also enable the
gofumpt linter.
With this change, `make fmt` will use gofumpt is available; gofumpt has been
added to the dev-container, so `make -f docker.Makefile fmt` will always use it.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 14:10:53 +03:00
fmt : ## run gofumpt (if present) or gofmt
@if command -v gofumpt > /dev/null; then \
2024-03-17 15:48:13 +03:00
gofumpt -w -d -lang= 1.21 . ; \
Use gofumpt if available, and enable gofumpt linter
gofumpt provides a supserset of gofmt / go fmt, but not every developer may have
it installed, so for situations where it's not available, fall back to gofmt.
As our code has been formatted with gofumpt already, in most cases contributions
will follow those formatting rules, but in some cases there may be a difference,
which would already be flagged by manual code review, but let's also enable the
gofumpt linter.
With this change, `make fmt` will use gofumpt is available; gofumpt has been
added to the dev-container, so `make -f docker.Makefile fmt` will always use it.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 14:10:53 +03:00
else \
go list -f { { .Dir} } ./... | xargs gofmt -w -s -d ; \
fi
2018-12-10 16:17:14 +03:00
2017-05-12 01:52:17 +03:00
.PHONY : binary
2021-09-26 19:01:38 +03:00
binary : ## build executable for Linux
./scripts/build/binary
.PHONY : dynbinary
dynbinary : ## build dynamically linked binary
GO_LINKMODE = dynamic ./scripts/build/binary
2017-05-12 01:52:17 +03:00
2018-12-10 18:30:19 +03:00
.PHONY : plugins
plugins : ## build example CLI plugins
./scripts/build/plugins
2021-12-16 23:15:53 +03:00
.PHONY : vendor
vendor : ## update vendor with go modules
2018-02-02 21:56:00 +03:00
rm -rf vendor
2021-12-16 23:15:53 +03:00
./scripts/vendor update
.PHONY : validate -vendor
validate-vendor : ## validate vendor
./scripts/vendor validate
.PHONY : mod -outdated
mod-outdated : ## check outdated dependencies
./scripts/vendor outdated
2017-05-09 22:37:22 +03:00
2018-01-02 17:47:31 +03:00
.PHONY : authors
authors : ## generate AUTHORS file from git history
scripts/docs/generate-authors.sh
2017-05-11 04:24:32 +03:00
.PHONY : manpages
2017-07-19 18:44:39 +03:00
manpages : ## generate man pages from go source and markdown
2017-06-06 07:59:50 +03:00
scripts/docs/generate-man.sh
2017-05-11 04:24:32 +03:00
2023-01-06 21:04:05 +03:00
.PHONY : mddocs
mddocs : ## generate markdown files from go source
scripts/docs/generate-md.sh
2017-05-11 04:24:32 +03:00
.PHONY : yamldocs
2017-07-19 18:44:39 +03:00
yamldocs : ## generate documentation YAML files consumed by docs repo
2017-05-11 04:24:32 +03:00
scripts/docs/generate-yaml.sh
2017-07-19 18:44:39 +03:00
.PHONY : help
help : ## print this help
2019-01-10 15:30:03 +03:00
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $( MAKEFILE_LIST)