From 286b948ab24d497978ee21b2554f1ee31523c5b1 Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Mon, 26 Oct 2020 14:32:00 +0400 Subject: [PATCH] ci config --- Makefile | 33 +++------------------------------ cmd/dnsupdater/main.go | 5 ++--- go.mod | 2 +- tools/coverage.sh | 29 ----------------------------- 4 files changed, 6 insertions(+), 63 deletions(-) delete mode 100644 tools/coverage.sh diff --git a/Makefile b/Makefile index 4f6c609..f2bf764 100644 --- a/Makefile +++ b/Makefile @@ -3,36 +3,9 @@ PKG := "gitlab.lehouerou.net/laurent/$(PROJECT_NAME)" PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go) -.PHONY: all dep build clean test coverage coverhtml lint +.PHONY: all dep build all: build -lint: ## Lint the files - @golint -set_exit_status ${PKG_LIST} - -test: ## Run unittests - @go test -short ${PKG_LIST} - -race: dep ## Run data race detector - @go test -race -short ${PKG_LIST} - -msan: dep ## Run memory sanitizer - @go test -msan -short ${PKG_LIST} - -coverage: ## Generate global code coverage report - ./tools/coverage.sh; - -coverhtml: ## Generate global code coverage report in HTML - ./tools/coverage.sh html; - -dep: ## Get the dependencies - @go get -v -d ./... - -build: dep ## Build the binary file - @go build -i -v $(PKG)/cmd/dnsupdater - -clean: ## Remove previous build - @rm -f $(PROJECT_NAME) - -help: ## Display this help screen - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' \ No newline at end of file +build: ## Build the binary file + @go build -i -v $(PKG)/cmd/dnsupdater \ No newline at end of file diff --git a/cmd/dnsupdater/main.go b/cmd/dnsupdater/main.go index e6b3135..1325445 100644 --- a/cmd/dnsupdater/main.go +++ b/cmd/dnsupdater/main.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "gopkg.in/gomail.v2" "net/http" "os" "path" @@ -14,14 +15,12 @@ import ( "gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip" "gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip/ddwrt" - "golang.org/x/xerrors" - "cdr.dev/slog" - "cdr.dev/slog/sloggers/sloghuman" "github.com/dghubble/sling" "github.com/matryer/try" "github.com/urfave/cli" + "golang.org/x/xerrors" ) var ( diff --git a/go.mod b/go.mod index f398e52..622de3c 100644 --- a/go.mod +++ b/go.mod @@ -11,5 +11,5 @@ require ( github.com/urfave/cli v1.20.0 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect - gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df + gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect ) diff --git a/tools/coverage.sh b/tools/coverage.sh deleted file mode 100644 index 529bf73..0000000 --- a/tools/coverage.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# Code coverage generation - -COVERAGE_DIR="${COVERAGE_DIR:-coverage}" -PKG_LIST=$(go list ./... | grep -v /vendor/) - -# Create the coverage files directory -mkdir -p "$COVERAGE_DIR"; - -# Create a coverage file for each package -for package in ${PKG_LIST}; do - go test -covermode=count -coverprofile "${COVERAGE_DIR}/${package##*/}.cov" "$package" ; -done ; - -# Merge the coverage profile files -echo 'mode: count' > "${COVERAGE_DIR}"/coverage.cov ; -tail -q -n +2 "${COVERAGE_DIR}"/*.cov >> "${COVERAGE_DIR}"/coverage.cov ; - -# Display the global code coverage -go tool cover -func="${COVERAGE_DIR}"/coverage.cov ; - -# If needed, generate HTML report -if [ "$1" == "html" ]; then - go tool cover -html="${COVERAGE_DIR}"/coverage.cov -o coverage.html ; -fi - -# Remove the coverage files directory -rm -rf "$COVERAGE_DIR"; \ No newline at end of file