-
Notifications
You must be signed in to change notification settings - Fork 34
/
Taskfile.yml
132 lines (125 loc) · 4.09 KB
/
Taskfile.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
version: "3"
vars:
BIN_NAME: gdg
VERSION: { sh: grep "const Version " internal/version/version.go | sed -E 's/.*"(.+)"$$/\1/' }
GIT_COMMIT: { sh: git rev-parse HEAD }
GIT_DIRTY: { sh: test -n "`git status --porcelain`" && echo "+CHANGES" || true }
BUILD_DATE: { sh: date '+%Y-%m-%d-%H:%M:%S' }
IMAGE_NAME: "esnet/gdg"
LD_FLAGS: "-s -w -X github.com/esnet/gdg/internal/version.GitCommit={{ .GIT_COMMIT}}{{ .GIT_DIRTY}} -X github.com/esnet/gdg/internal/version.BuildDate={{ .BUILD_DATE }} "
LEFTHOOK_VERSION: "v1.7.13"
MOCKERY_VERSION: "v2.42.0"
RELEASER_VERSION: "v2.2.0"
dotenv: [ '.env' ]
tasks:
default:
cmds:
- task: build_all
install_tools:
desc: "Install required Dev tools by GDG"
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/client9/misspell/cmd/misspell@latest
- go install github.com/securego/gosec/v2/cmd/gosec@latest
- go install golang.org/x/vuln/cmd/govulncheck@latest
- go install github.com/vektra/mockery/v2@{{ .MOCKERY_VERSION}}
- go install github.com/goreleaser/goreleaser/v2@{{ .RELEASER_VERSION }}
- go install github.com/evilmartians/lefthook@{{ .LEFTHOOK_VERSION }}
- go install mvdan.cc/[email protected]
- lefthook install
security:
desc: "Run security scan"
cmds:
- gosec --exclude=G402,G304 ./...
format:
desc: reformat the code to match stricter conventions
cmds:
- gofumpt -l -w .
lint:
desc: "Lint project, skipping test files."
cmds:
- golangci-lint run --timeout=30m ./...
spellcheck:
desc: "Check Spelling across code"
cmds:
- misspell . | grep -v "website"
lint_tests:
desc: "Lint project, including test files."
cmds:
- golangci-lint run ./...
authors:
desc: "Building GDG"
cmds:
- echo "Authors\n=======\n" > AUTHORS.md
- "git log --raw | grep \"^Author: \" | sort | uniq | cut -d ' ' -f2 | sed 's/^/- /' >> AUTHORS.md"
silent: false
mocks:
desc: "Re-generate Mocks"
cmds:
- rm -fr internal/service/mocks
- mockery
linux:
desc: "Build linux binary"
cmds:
- env GOOS='linux' GOARCH='amd64' go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }}_linux cmd/gdg/main.go
build_all:
desc: "Buiding All binaries"
cmds:
- task: build
- task: build_generate
build:
desc: "Buiding {{ .BIN_NAME }} {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }} cmd/gdg/main.go
build_generate:
desc: "Buiding {{ .BIN_NAME }}-generate {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go build -ldflags "{{ .LD_FLAGS }}" -o bin/{{ .BIN_NAME }}-generate cmd/gdg-generate/main.go
install:
desc: "installing {{ .BIN_NAME }} {{ .VERSION }}"
cmds:
- echo "GOPATH=${GOPATH}"
- go install -ldflags "{{ .LD_FLAGS}}" cmd/gdg/main.go
silent: false
push:
desc: "Pushing docker image to registry: latest {{ .VERSION }} {{ .GIT_COMMIT }}"
deps: [ tag ]
cmds:
- docker push $(IMAGE_NAME):{{ .GIT_COMMIT }}
- docker push $(IMAGE_NAME):{{ .VERSION }}
- docker push $(IMAGE_NAME):latest
clean:
desc: "clean up data"
cmds:
- "test ! -e bin/{{ .BIN_NAME }} || rm bin/{{ .BIN_NAME }}"
- "rm -fr dist/"
release-snapshot:
deps: [ clean ]
desc: "Release Snapshot"
cmds:
- goreleaser build --snapshot
release:
deps: [ clean ]
desc: "TEST Release of GDG, no validation, no publish"
cmds:
- goreleaser release --skip=publish,validate
test:
desc: "test check"
cmds:
- go test -v -coverpkg=./... -covermode=atomic -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out
env:
TEST_TOKEN_CONFIG: "0"
test_tokens:
desc: "test Token Based Only"
cmds:
- go test -v -coverpkg=./... -covermode=atomic -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out
env:
TEST_TOKEN_CONFIG: "1"
vuln_check:
desc: "Vulnerability check"
cmds:
- govulncheck ./...