forked from CLIP-HPC/goslmailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (74 loc) · 3.02 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
.PHONY: clean build test test_new list all
.ONESHELL:
#SHELL =
#.SHELLFLAGS =
# endly version
# https://github.com/viant/endly
endly_version=0.52.0
# Inject into binary via linker:
# ...in github actions comes from make -e version=git_ref
version=$(shell cat VERSION)
commit=$(shell git show --no-patch --format=format:%H HEAD)
buildVersionVar=github.com/CLIP-HPC/goslmailer/internal/version.buildVersion
buildCommitVar=github.com/CLIP-HPC/goslmailer/internal/version.buildCommit
# various directories
bindirs=$(wildcard ./cmd/*)
installdir=build/goslmailer-$(version)
installconfdir=$(installdir)/config
installtempldir=$(installdir)/templates
# list of files to include in build
bins=$(notdir $(bindirs))
readme=README.md
templates=templates/adaptive_card_template.json templates/telegramTemplate.html templates/matrix_template.md
config=cmd/goslmailer/goslmailer.conf.annotated_example cmd/gobler/gobler.conf cmd/goslmailer/goslmailer.toml.annotated_example cmd/gobler/gobler.toml
# can be replaced with go test ./... construct
testdirs=$(sort $(dir $(shell find ./ -name *_test.go)))
all: list test build get_endly test_endly install
list:
@echo "================================================================================"
@echo "bindirs found: $(bindirs)"
@echo "bins found: $(bins)"
@echo "testdirs found: $(testdirs)"
@echo "================================================================================"
build:
@echo "********************************************************************************"
@echo Building $(bindirs)
@echo Variables:
@echo buildVersionVar: $(buildVersionVar)
@echo version: $(version)
@echo buildCommitVar: $(buildCommitVar)
@echo commit: $(commit)
@echo "********************************************************************************"
for i in $(bindirs);
do
echo "................................................................................"
echo "--> Now building: $$i"
echo "................................................................................"
go build -v -ldflags '-X $(buildVersionVar)=$(version) -X $(buildCommitVar)=$(commit)' $$i;
done;
install:
mkdir -p $(installdir) $(installconfdir) $(installtempldir)
cp $(bins) $(readme) $(installdir)
cp $(config) $(installconfdir)
cp $(templates) $(installtempldir)
test_new:
$(foreach dir, $(testdirs), go test -v -count=1 $(dir) || exit $$?;)
test:
@echo "********************************************************************************"
@echo Testing
@echo "********************************************************************************"
go test -v -cover -count=1 ./...
endly_linux_$(endly_version).tar.gz:
curl -L -O https://github.com/viant/endly/releases/download/v$(endly_version)/endly_linux_$(endly_version).tar.gz
test_e2e/endly:
tar -C test_e2e/ -xzf endly_linux_$(endly_version).tar.gz
get_endly: endly_linux_$(endly_version).tar.gz test_e2e/endly
test_endly:
cd test_e2e
./endly
clean:
rm $(bins)
rm -rf $(installdir)
rm test_e2e/rendered-*
#rm endly_linux_$(endly_version).tar.gz
rm test_e2e/endly