...

Text file src/github.com/joshdk/go-junit/Makefile

Documentation: github.com/joshdk/go-junit

     1#### Environment ####
     2
     3# Enforce usage of the Go modules system.
     4export GO111MODULE := on
     5
     6# Determine where `go get` will install binaries to.
     7GOBIN := $(HOME)/go/bin
     8ifdef GOPATH
     9	GOBIN := $(GOPATH)/bin
    10endif
    11
    12# All target for when make is run on its own.
    13.PHONY: all
    14all: test lint
    15
    16#### Binary Dependencies ####
    17
    18# Install binary for go-junit-report.
    19go-junit-report := $(GOBIN)/go-junit-report
    20$(go-junit-report):
    21	cd /tmp && go get -u github.com/jstemmer/go-junit-report
    22
    23# Install binary for golangci-lint.
    24golangci-lint := $(GOBIN)/golangci-lint
    25$(golangci-lint):
    26	@./scripts/install-golangci-lint $(golangci-lint)
    27
    28# Install binary for goimports.
    29goimports := $(GOBIN)/goimports
    30$(goimports):
    31	cd /tmp && go get -u golang.org/x/tools/cmd/goimports
    32
    33#### Linting ####
    34
    35# Run code linters.
    36.PHONY: lint
    37lint: $(golangci-lint) style
    38	golangci-lint run
    39
    40# Run code formatters. Unformatted code will fail in CircleCI.
    41.PHONY: style
    42style: $(goimports)
    43ifdef CI
    44	goimports -l .
    45else
    46	goimports -l -w .
    47endif
    48
    49#### Testing ####
    50
    51# Run Go tests and generate a JUnit XML style test report for ingestion by CircleCI.
    52.PHONY: test
    53test: $(go-junit-report)
    54	@mkdir -p test-results
    55	@go test -race -v 2>&1 | tee test-results/report.log
    56	@cat test-results/report.log | go-junit-report -set-exit-code > test-results/report.xml
    57
    58# Clean up test reports.
    59.PHONY: clean
    60clean:
    61	@rm -rf test-results

View as plain text