Skip to content

Commit d5bde8e

Browse files
committed
update dependencies
1 parent 5ada433 commit d5bde8e

12 files changed

Lines changed: 1124 additions & 66 deletions

File tree

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "04:00"
8+
pull-request-branch-name:
9+
separator: "-"
10+
open-pull-requests-limit: 10
11+
12+
- package-ecosystem: gomod
13+
directory: "/"
14+
schedule:
15+
interval: weekly
16+
time: '10:00'
17+
open-pull-requests-limit: 10

.github/workflows/citest.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Builds
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
- name: Install Go
12+
uses: actions/setup-go@v6
13+
with:
14+
go-version-file: './go.mod'
15+
- run: make clean
16+
- run: make citest
17+
- run: make
18+
- name: extract built binary
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: check_prometheus_linux_amd64
22+
path: check_prometheus
23+
- run: make clean
24+

.gitignore

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
1-
# Compiled Object files, Static and Dynamic libs (Shared Objects)
2-
*.o
3-
*.a
4-
*.so
5-
6-
# Folders
7-
_obj
8-
_test
9-
vendor
10-
11-
# Architecture specific extensions/prefixes
12-
*.[568vq]
13-
[568vq].out
14-
15-
*.cgo1.go
16-
*.cgo2.c
17-
_cgo_defun.c
18-
_cgo_gotypes.go
19-
_cgo_export.*
20-
21-
_testmain.go
22-
23-
*.exe
24-
*.test
25-
*.prof
26-
27-
#IDE Files
28-
*.iml
29-
*.idea
30-
31-
#Testfiles
321
check_prometheus
2+
check_prometheus.*.amd64
3+
check_prometheus.*.aarch64
4+
check_prometheus.*.i386
5+
*.exe
6+
*.swp
7+
.vscode
8+
.vstags
9+
coverage.txt
10+
vendor/
11+
tools/
12+
go.work
13+
go.work.sum

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# next
2+
- update dependencies
3+
14
# 0.0.2 - 09.01.2020
25
## Changes:
36
- change to ConSol repos

Makefile

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
#!/usr/bin/make -f
2+
3+
PROJECT=check_prometheus
4+
MAKE:=make
5+
SHELL:=bash
6+
GOVERSION:=$(shell \
7+
go version | \
8+
awk -F'go| ' '{ split($$5, a, /\./); printf ("%04d%04d", a[1], a[2]); exit; }' \
9+
)
10+
# also update .github/workflows/citest.yml when changing minumum version
11+
# find . -name go.mod
12+
MINGOVERSION:=00010023
13+
MINGOVERSIONSTR:=1.23
14+
BUILD:=$(shell git rev-parse --short HEAD)
15+
REVISION:=$(shell printf "%04d" $$( git rev-list --all --count))
16+
# see https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md
17+
# and https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
18+
TOOLSFOLDER=$(shell pwd)/tools
19+
export GOBIN := $(TOOLSFOLDER)
20+
export PATH := $(GOBIN):$(PATH)
21+
22+
BUILD_FLAGS=-ldflags "-s -w -X main.Build=$(BUILD) -X main.Revision=$(REVISION)"
23+
TEST_FLAGS=-timeout=5m $(BUILD_FLAGS)
24+
GO=go
25+
26+
all: build
27+
28+
CMDS = $(shell cd ./cmd && ls -1)
29+
30+
tools: | versioncheck
31+
set -e; for DEP in $(shell grep "_ " buildtools/tools.go | awk '{ print $$2 }'); do \
32+
( cd buildtools && $(GO) install $$DEP@latest ) ; \
33+
done
34+
( cd buildtools && $(GO) mod tidy )
35+
36+
updatedeps: versioncheck
37+
$(MAKE) clean
38+
$(MAKE) tools
39+
$(GO) mod download
40+
GOPROXY=direct $(GO) get -t -u ./pkg/* ./cmd/*
41+
$(GO) mod download
42+
$(MAKE) cleandeps
43+
44+
cleandeps:
45+
set -e; for dir in $(shell ls -d1 pkg/* cmd/*); do \
46+
( cd ./$$dir && $(GO) mod tidy ); \
47+
done
48+
$(GO) mod tidy
49+
( cd buildtools && $(GO) mod tidy )
50+
51+
vendor: go.work
52+
GOWORK=off $(GO) mod vendor
53+
54+
go.work:
55+
echo "go $(MINGOVERSIONSTR)" > go.work
56+
$(GO) work use \
57+
. \
58+
buildtools/. \
59+
60+
build: vendor
61+
set -e; for CMD in $(CMDS); do \
62+
( cd ./cmd/$$CMD && $(GO) build $(BUILD_FLAGS) -o ../../$$CMD ) ; \
63+
done
64+
65+
# run build watch, ex. with tracing: make build-watch -- -vv
66+
build-watch: vendor tools
67+
set -x ; ls pkg/*/*.go cmd/*/*.go | entr -sr "$(MAKE) build && ./check_prometheus $(filter-out $@,$(MAKECMDGOALS)) $(shell echo $(filter-out --,$(MAKEFLAGS)) | tac -s " ")"
68+
69+
build-linux-amd64: vendor
70+
set -e; for CMD in $(CMDS); do \
71+
( cd ./cmd/$$CMD && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build $(BUILD_FLAGS) -o ../../$$CMD.linux.amd64 ) ; \
72+
done
73+
74+
build-windows-i386: vendor
75+
set -e; for CMD in $(CMDS); do \
76+
( cd ./cmd/$$CMD && GOOS=windows GOARCH=386 CGO_ENABLED=0 $(GO) build $(BUILD_FLAGS) -o ../../$$CMD.windows.i386.exe ) ; \
77+
done
78+
79+
build-windows-amd64: vendor
80+
set -e; for CMD in $(CMDS); do \
81+
( cd ./cmd/$$CMD && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GO) build $(BUILD_FLAGS) -o ../../$$CMD.windows.amd64.exe ) ; \
82+
done
83+
84+
build-freebsd-i386: vendor
85+
set -e; for CMD in $(CMDS); do \
86+
( cd ./cmd/$$CMD && GOOS=freebsd GOARCH=386 CGO_ENABLED=0 $(GO) build $(BUILD_FLAGS) -o ../../$$CMD.freebsd.i386 ) ; \
87+
done
88+
89+
build-darwin-aarch64: vendor
90+
set -e; for CMD in $(CMDS); do \
91+
( cd ./cmd/$$CMD && GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 $(GO) build $(BUILD_FLAGS) -o ../../$$CMD.darwin.aarch64 ) ; \
92+
done
93+
94+
test: vendor
95+
$(GO) test -short -v $(TEST_FLAGS) ./pkg/* ./cmd/*
96+
if grep -Irn TODO: ./cmd/ ./pkg/; then exit 1; fi
97+
98+
# test with filter
99+
testf: vendor
100+
$(GO) test -short -v $(TEST_FLAGS) ./pkg/* ./cmd/* -run "$(filter-out $@,$(MAKECMDGOALS))" 2>&1 | grep -v "no test files" | grep -v "no tests to run" | grep -v "^PASS"
101+
102+
longtest: vendor
103+
$(GO) test -v $(TEST_FLAGS) ./pkg/* ./cmd/*
104+
105+
citest: tools vendor
106+
#
107+
# Checking gofmt errors
108+
#
109+
if [ $$(gofmt -s -l ./cmd/ ./pkg/ | wc -l) -gt 0 ]; then \
110+
echo "found format errors in these files:"; \
111+
gofmt -s -l ./cmd/ ./pkg/ ; \
112+
exit 1; \
113+
fi
114+
#
115+
# Checking TODO items
116+
#
117+
if grep -Irn TODO: ./cmd/ ./pkg/ ; then exit 1; fi
118+
#
119+
# Run other subtests
120+
#
121+
$(MAKE) golangci
122+
-$(MAKE) govulncheck
123+
$(MAKE) fmt
124+
#
125+
# Normal test cases
126+
#
127+
$(MAKE) test
128+
#
129+
# Benchmark tests
130+
#
131+
$(MAKE) benchmark
132+
#
133+
# Race rondition tests
134+
#
135+
$(MAKE) racetest
136+
#
137+
# Test cross compilation
138+
#
139+
$(MAKE) build-linux-amd64
140+
$(MAKE) build-windows-amd64
141+
$(MAKE) build-windows-i386
142+
$(MAKE) build-freebsd-i386
143+
$(MAKE) build-darwin-aarch64
144+
#
145+
# All CI tests successful
146+
#
147+
148+
benchmark:
149+
$(GO) test $(TEST_FLAGS) -v -bench=B\* -run=^$$ -benchmem ./pkg/*
150+
151+
racetest:
152+
$(GO) test -race -short $(TEST_FLAGS) -coverprofile=coverage.txt -covermode=atomic -gcflags "-d=checkptr=0" ./pkg/*
153+
154+
covertest:
155+
$(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/*
156+
$(GO) tool cover -func=cover.out
157+
$(GO) tool cover -html=cover.out -o coverage.html
158+
159+
coverweb:
160+
$(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/*
161+
$(GO) tool cover -html=cover.out
162+
163+
clean:
164+
set -e; for CMD in $(CMDS); do \
165+
rm -f ./cmd/$$CMD/$$CMD; \
166+
done
167+
rm -f $(CMDS)
168+
rm -f *.windows.*.exe
169+
rm -f *.linux.*
170+
rm -f *.darwin.*
171+
rm -f *.freebsd.*
172+
rm -f go.work
173+
rm -f go.work.sum
174+
rm -f cover.out
175+
rm -f coverage.html
176+
rm -f coverage.txt
177+
rm -rf vendor/
178+
rm -rf $(TOOLSFOLDER)
179+
180+
GOVET=$(GO) vet -all
181+
SRCFOLDER=./cmd/. ./pkg/. ./buildtools/.
182+
fmt: tools
183+
set -e; for CMD in $(CMDS); do \
184+
$(GOVET) ./cmd/$$CMD; \
185+
done
186+
set -e; for dir in $(shell ls -d1 pkg/*); do \
187+
$(GOVET) ./$$dir; \
188+
done
189+
gofmt -w -s $(SRCFOLDER)
190+
./tools/gofumpt -w $(SRCFOLDER)
191+
./tools/gci write --skip-generated $(SRCFOLDER)
192+
./tools/goimports -w $(SRCFOLDER)
193+
194+
versioncheck:
195+
@[ $$( printf '%s\n' $(GOVERSION) $(MINGOVERSION) | sort | head -n 1 ) = $(MINGOVERSION) ] || { \
196+
echo "**** ERROR:"; \
197+
echo "**** $(PROJECT) requires at least golang version $(MINGOVERSIONSTR) or higher"; \
198+
echo "**** this is: $$(go version)"; \
199+
exit 1; \
200+
}
201+
202+
golangci: tools
203+
#
204+
# golangci combines a few static code analyzer
205+
# See https://github.com/golangci/golangci-lint
206+
#
207+
@set -e; for dir in $$(ls -1d pkg/* cmd); do \
208+
echo $$dir; \
209+
echo " - GOOS=linux"; \
210+
( cd $$dir && GOOS=linux golangci-lint run --timeout=5m ./... ); \
211+
done
212+
213+
govulncheck: tools
214+
govulncheck ./...
215+
216+
version:
217+
OLDVERSION="$(shell grep "VERSION =" ./pkg/$(PROJECT)/check.go | awk '{print $$4}' | tr -d '"')"; \
218+
NEWVERSION=$$(dialog --stdout --inputbox "New Version:" 0 0 "v$$OLDVERSION") && \
219+
NEWVERSION=$$(echo $$NEWVERSION | sed "s/^v//g"); \
220+
if [ "v$$OLDVERSION" = "v$$NEWVERSION" -o "x$$NEWVERSION" = "x" ]; then echo "no changes"; exit 1; fi; \
221+
sed -i -e 's/VERSION =.*/VERSION = "'$$NEWVERSION'"/g' pkg/$(PROJECT)/check.go
222+
223+
check_prometheus: build
224+
225+
# just skip unknown make targets
226+
.DEFAULT:
227+
@if [[ "$(MAKECMDGOALS)" =~ ^testf ]]; then \
228+
: ; \
229+
else \
230+
echo "unknown make target(s): $(MAKECMDGOALS)"; \
231+
exit 1; \
232+
fi

0 commit comments

Comments
 (0)