From b6cec83503a099a4d30a14158a52263a5cda9ce8 Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 22 Jun 2023 18:24:15 +0000 Subject: [PATCH] ci: add go vet to test stage (!99) * Add `go vet` to the test stage of the Gitlab CI/CD pipeline * Fix issues raised by `go vet` https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/merge_requests/99 --- .gitlab-ci.yml | 7 +++++++ Makefile | 5 +++++ exporter.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 668d3fb..a7e3c55 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,6 +19,13 @@ format: script: - make check/fmt +vet: + extends: .go_template + stage: test + allow_failure: true + script: + - make vet + test: extends: .go_template stage: test diff --git a/Makefile b/Makefile index e1854b8..4421341 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,11 @@ update: test: download go test ./... -v -race +# Look for "suspicious constructs" in source code +.PHONY: vet +vet: download + go vet ./... + # Format code .PHONY: fmt fmt: download diff --git a/exporter.go b/exporter.go index 6e7ae25..5dc6e0d 100644 --- a/exporter.go +++ b/exporter.go @@ -53,7 +53,7 @@ func main() { } func handleGracefulShutdown() { - var signals = make(chan os.Signal) + var signals = make(chan os.Signal, 1) signal.Notify(signals, syscall.SIGTERM) signal.Notify(signals, syscall.SIGINT)