github.com/release-engineering/exodus-rsync@v1.11.2/Makefile (about)

     1  default: exodus-rsync
     2  
     3  # Helper macros.
     4  
     5  # Wrap an autoformatter like gofmt with a failure message
     6  # since a bare failing "test -z" might be undecipherable to some
     7  fmt-cmd = if ! test -z $$($(1) | tee /dev/stderr); then echo $(2); exit 3; fi
     8  
     9  BUILDVERSION := $$(git describe HEAD)
    10  BUILDFLAGS := -ldflags "-X github.com/release-engineering/exodus-rsync/internal/cmd.version=$(BUILDVERSION)"
    11  
    12  # Build the main binary for this project.
    13  exodus-rsync: generate
    14  	go build $(BUILDFLAGS) ./cmd/exodus-rsync
    15  
    16  # Run automated tests while gathering coverage info.
    17  # Generated mocks are excluded from coverage report.
    18  check: generate
    19  	go test -coverprofile=coverage.out -coverpkg=./... ./...
    20  	sed -e '/[\/_]mock.go/ d' -i coverage.out
    21  
    22  # Run generate.
    23  generate:
    24  	go generate ./...
    25  
    26  # Run linter.
    27  lint:
    28  	go run -modfile=go.tools.mod golang.org/x/lint/golint -set_exit_status ./...
    29  
    30  # Reformat code, failing if any code was rewritten.
    31  fmt:
    32  	@$(call fmt-cmd, gofmt -s -l -w ., files were rewritten by gofmt)
    33  
    34  # Tidy imports, failing if any code was rewritten.
    35  imports:
    36  	@$(call fmt-cmd, go run -modfile=go.tools.mod golang.org/x/tools/cmd/goimports -l -w ., files were rewritten by goimports)
    37  
    38  # Check for glibc symbol versioning problems.
    39  symver-check: exodus-rsync
    40  	test/symver-check
    41  
    42  # Run tests and open coverage report in browser.
    43  htmlcov: check
    44  	go tool cover -html=coverage.out
    45  
    46  # Delete generated files.
    47  clean:
    48  	rm -f exodus-rsync coverage.out
    49  
    50  # Build exodus-rsync in a container image.
    51  # If you have a working 'podman', this can be used as an alternative
    52  # to installing the go toolchain on the host.
    53  podman-exodus-rsync:
    54  	podman build -t exodus-rsync-build -f build.Containerfile .
    55  	podman run --security-opt label=disable -v $$PWD:/src exodus-rsync-build make -C /src
    56  
    57  # Target for all checks applied in CI.
    58  all: exodus-rsync check lint fmt imports symver-check
    59  
    60  .PHONY: check default clean generate exodus-rsync lint fmt imports symver-check htmlcov all