ci config

This commit is contained in:
Laurent Le Houerou 2020-10-26 14:32:00 +04:00
parent 334ef340ae
commit 286b948ab2
4 changed files with 6 additions and 63 deletions

View File

@ -3,36 +3,9 @@ PKG := "gitlab.lehouerou.net/laurent/$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go) 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 all: build
lint: ## Lint the files build: ## Build the binary file
@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 @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}'

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"gopkg.in/gomail.v2"
"net/http" "net/http"
"os" "os"
"path" "path"
@ -14,14 +15,12 @@ import (
"gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip" "gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip"
"gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip/ddwrt" "gitlab.lehouerou.net/laurent/dnsupdater/internal/outboundip/ddwrt"
"golang.org/x/xerrors"
"cdr.dev/slog" "cdr.dev/slog"
"cdr.dev/slog/sloggers/sloghuman" "cdr.dev/slog/sloggers/sloghuman"
"github.com/dghubble/sling" "github.com/dghubble/sling"
"github.com/matryer/try" "github.com/matryer/try"
"github.com/urfave/cli" "github.com/urfave/cli"
"golang.org/x/xerrors"
) )
var ( var (

2
go.mod
View File

@ -11,5 +11,5 @@ require (
github.com/urfave/cli v1.20.0 github.com/urfave/cli v1.20.0
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect 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
) )

View File

@ -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";