forked from k1LoW/trivy-db-to
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (52 loc) · 1.92 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
PKG = github.com/k1LoW/trivy-db-to
COMMIT = $$(git describe --tags --always)
OSNAME=${shell uname -s}
ifeq ($(OSNAME),Darwin)
DATE = $$(gdate --utc '+%Y-%m-%d_%H:%M:%S')
else
DATE = $$(date --utc '+%Y-%m-%d_%H:%M:%S')
endif
export GO111MODULE=on
BUILD_LDFLAGS = -X $(PKG).commit=$(COMMIT) -X $(PKG).date=$(DATE)
TEST_MYSQL_DSN = mysql://root:[email protected]:33357/trivydb
TEST_POSTGRES_DSN = pg://postgres:[email protected]:35432/trivydb?sslmode=disable
default: test
ci: depsdev test integration
test:
go test ./... -coverprofile=coverage.out -covermode=count
sec:
gosec ./...
lint:
golangci-lint run ./...
doc:
tbls doc -f -c docs/tbls-mysql.yml
tbls doc -f -c docs/tbls-postgres.yml
integration: build
./trivy-db-to $(TEST_MYSQL_DSN)
usql $(TEST_MYSQL_DSN) -c "SELECT COUNT(*) FROM vulnerabilities;"
usql $(TEST_MYSQL_DSN) -c "SELECT COUNT(*) FROM vulnerabilities;" | grep '[0-9]\{5\}'
usql $(TEST_MYSQL_DSN) -c "SELECT COUNT(*) FROM vulnerability_advisories;"
usql $(TEST_MYSQL_DSN) -c "SELECT COUNT(*) FROM vulnerability_advisories;" | grep '[0-9]\{6\}'
./trivy-db-to $(TEST_POSTGRES_DSN)
usql $(TEST_POSTGRES_DSN) -c "SELECT COUNT(*) FROM vulnerabilities;"
usql $(TEST_POSTGRES_DSN) -c "SELECT COUNT(*) FROM vulnerabilities;" | grep '[0-9]\{5\}'
usql $(TEST_POSTGRES_DSN) -c "SELECT COUNT(*) FROM vulnerability_advisories;"
usql $(TEST_POSTGRES_DSN) -c "SELECT COUNT(*) FROM vulnerability_advisories;" | grep '[0-9]\{6\}'
build:
go build -ldflags="$(BUILD_LDFLAGS)"
depsdev:
go install github.com/Songmu/ghch/cmd/[email protected]
go install github.com/xo/[email protected]
go install github.com/Songmu/gocredits/cmd/[email protected]
go install github.com/securego/gosec/cmd/gosec@master
prerelease:
git pull origin --tag
ghch -w -N ${VER}
gocredits . > CREDITS
git add CHANGELOG.md CREDITS
git commit -m'Bump up version number'
git tag ${VER}
release:
git push origin main --tag
goreleaser --rm-dist
.PHONY: default test