-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from akamai/release/1.4.0
Release/1.4.0
- Loading branch information
Showing
75 changed files
with
2,047 additions
and
570 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,42 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
- revive | ||
|
||
output: | ||
sort-results: true | ||
|
||
issues: | ||
exclude-use-default: false | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
linters-settings: | ||
revive: | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: exported | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id |
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
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,41 +1,102 @@ | ||
BIN = $(CURDIR)/bin | ||
GOCMD = go | ||
GOTEST = $(GOCMD) test | ||
GOBUILD = $(GOCMD) build | ||
M = $(shell echo ">") | ||
|
||
$(BIN): | ||
@mkdir -p $@ | ||
$(BIN)/%: | $(BIN) ; $(info $(M) Installing $(PACKAGE)...) | ||
@tmp=$$(mktemp -d); \ | ||
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GOCMD) get $(PACKAGE) \ | ||
|| ret=$$?; \ | ||
rm -rf $$tmp ; exit $$ret | ||
|
||
GOIMPORTS = $(BIN)/goimports | ||
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports | ||
|
||
GOCOV = $(BIN)/gocov | ||
$(BIN)/gocov: PACKAGE=github.com/axw/gocov/... | ||
|
||
GOCOVXML = $(BIN)/gocov-xml | ||
$(BIN)/gocov-xml: PACKAGE=github.com/AlekSi/gocov-xml | ||
|
||
GOJUNITREPORT = $(BIN)/go-junit-report | ||
$(BIN)/go-junit-report: PACKAGE=github.com/jstemmer/go-junit-report | ||
|
||
GOLANGCILINT = $(BIN)/golangci-lint | ||
GOLANGCI_LINT_VERSION = v1.41.1 | ||
$(BIN)/golangci-lint: ; $(info $(M) Installing golangci-lint...) | ||
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN) $(GOLANGCI_LINT_VERSION) | ||
|
||
COVERAGE_MODE = atomic | ||
COVERAGE_DIR = $(CURDIR)/test/coverage | ||
COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out | ||
COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml | ||
COVERAGE_HTML = $(COVERAGE_DIR)/index.html | ||
|
||
.PHONY: all | ||
all: fmt lint vet coverage | ||
all: clean fmt-check lint coverage create-junit-report create-coverage-files clean-tools | ||
|
||
.PHONY: build | ||
build: | ||
go build -o akamai cli/main.go | ||
build: ; $(info $(M) Building 'akamai' binary...) @ ## Build the binary from source | ||
$(GOBUILD) -o $(CURDIR)/akamai cli/main.go | ||
|
||
.PHONY: test | ||
test: | ||
go test -count=1 ./... | ||
|
||
.PHONY: coverage-ui | ||
coverage-ui: | ||
go test -covermode=count -coverprofile=coverage.out ./... | ||
go tool cover -html=coverage.out | ||
test: ; $(info $(M) Running tests...) ## Run all unit tests | ||
$(GOTEST) -count=1 ./... | ||
|
||
.PHONY: coverage | ||
coverage: | ||
go test -coverprofile coverage.out ./... | ||
go tool cover -func coverage.out | grep total | ||
coverage: ; $(info $(M) Running tests with coverage...) @ ## Run tests and generate coverage profile | ||
@mkdir -p $(COVERAGE_DIR) | ||
@$(GOTEST) -v -covermode=$(COVERAGE_MODE) \ | ||
-coverprofile="$(COVERAGE_PROFILE)" ./... | tee test/tests.output | ||
|
||
.PHONY: lint | ||
lint: | ||
golint -set_exit_status ./... | ||
.PHONY: create-junit-report | ||
create-junit-report: | $(GOJUNITREPORT) ; $(info $(M) Creating juint xml report) @ ## Generate junit-style coverage report | ||
@cat $(CURDIR)/test/tests.output | $(GOJUNITREPORT) > $(CURDIR)/test/tests.xml | ||
@sed -i -e 's/skip=/skipped=/g;s/ failures=/ errors="0" failures=/g' $(CURDIR)/test/tests.xml | ||
|
||
.PHONY: create-coverage-files | ||
create-coverage-files: | $(GOCOV) $(GOCOVXML); $(info $(M) Creating coverage files...) @ ## Generate coverage report files | ||
@$(GOCMD) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML) | ||
@$(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML) | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
.PHONY: lint | ||
lint: | $(GOLANGCILINT); $(info $(M) Running linter...) @ ## Run golangci-lint on all source files | ||
@$(BIN)/golangci-lint run | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
fmt: | $(GOIMPORTS); $(info $(M) Running goimports...) @ ## Run goimports on all source files | ||
@$(GOIMPORTS) -w . | ||
|
||
.PHONY: release | ||
release: | ||
./build.sh | ||
.PHONY: fmt-check | ||
fmt-check: | $(GOIMPORTS); $(info $(M) Running format and imports check...) @ ## Run goimports on all source files (do not modify files) | ||
$(eval OUTPUT = $(shell $(GOIMPORTS) -l .)) | ||
@if [ "$(OUTPUT)" != "" ]; then\ | ||
echo "Found following files with incorrect format and/or imports:";\ | ||
echo "$(OUTPUT)";\ | ||
false;\ | ||
fi | ||
|
||
.PHONY: release | ||
release: ; $(info $(M) Generating release binaries and signatures...) @ ## Generate release binaries | ||
@./build.sh | ||
|
||
.PHONY: pack | ||
pack: | ||
tar -zcvf cli.tar.gz . | ||
pack: ; $(info $(M) Generating tarball...) @ ## Create cli tarball | ||
@tar -zcf cli.tar.gz * | ||
|
||
.PHONY: ; clean | ||
clean: ; $(info $(M) Removing 'bin' directory and test results...) @ ## Cleanup installed packages and test reports | ||
@rm -rf $(BIN) | ||
@rm -rf $(BIN)/test/tests.* $(BIN)/test/coverage | ||
|
||
clean-tools: ## Cleanup installed packages | ||
@rm -rf $(BIN)/go* | ||
|
||
.PHONY: help | ||
help: ## List all make targets | ||
echo $(MAKEFILE_LIST) | ||
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ | ||
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' |
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
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
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,3 +1,4 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
// Copyright 2018. Akamai Technologies, Inc | ||
|
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
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
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
Oops, something went wrong.