-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (53 loc) · 1.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
BRANCH=$(subst /,-,$(B))
GITREV=$(shell git describe --abbrev=7 --always --tags)
REV=$(GITREV)-$(BRANCH)-$(shell date +%Y%m%d-%H:%M:%S)
DOCFILE=CLI.md
TARGET=alertmanager-telegram
.PHONY: all
all: lint test doc build
.PHONY: clean
clean:
rm -rf alertmanager-telegram cover.out alertmanager build
lint:
golangci-lint run --timeout=2m0s
.PHONY: test
test: lint
go test -coverprofile cover.out ./...
go tool cover -func cover.out
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags "-X main.revision=$(REV) -s -w" -o build/$(TARGET)
.PHONY: doc
doc:
echo "[//]: <> (DO NOT TOUCH! THIS FILE IS GENERATED BY make doc)" > $(DOCFILE)
echo "# $(TARGET) cli" >> $(DOCFILE)
echo "\`\`\`shell" >> $(DOCFILE)
echo "$$ $(TARGET) --help" >> $(DOCFILE)
sh -c "go run main.go --help || true" >> $(DOCFILE) 2>&1
echo "\`\`\`" >> $(DOCFILE)
echo "## Daemon" >> $(DOCFILE)
echo "\`\`\`shell" >> $(DOCFILE)
echo "$$ $(TARGET) daemon --help" >> $(DOCFILE)
sh -c "go run main.go daemon --help || true" >> $(DOCFILE) 2>&1
echo "\`\`\`" >> $(DOCFILE)
echo "## Health" >> $(DOCFILE)
echo "\`\`\`shell" >> $(DOCFILE)
echo "$$ $(TARGET) health --help" >> $(DOCFILE)
sh -c "go run main.go health --help || true" >> $(DOCFILE) 2>&1
echo "\`\`\`" >> $(DOCFILE)
.PHONY: dockerbuild
dockerbuild: build
GOOS=linux CGO_ENABLED=0 go build -ldflags "-X main.revision=$(REV) -s -w" -o alertmanager-telegram
docker build --rm -t ghcr.io/a1fred/alertmanager-telegram .
rm alertmanager-telegram
alertmanager:
wget https://github.com/prometheus/alertmanager/releases/download/v0.23.0/alertmanager-0.23.0.darwin-amd64.tar.gz
mkdir alertmanager
tar -xzvf alertmanager-0.23.0.darwin-amd64.tar.gz -C alertmanager/ --strip-components=1
rm alertmanager-0.23.0.darwin-amd64.tar.gz
.PHONY: alertmanager_run
alertmanager_run: alertmanager
alertmanager/alertmanager --config.file=alertmanager.yml --storage.path=alertmanager/data
.PHONY: alert
alert:
sh test-alert.sh