-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
186 lines (174 loc) · 4.8 KB
/
Taskfile.yaml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
version: 3
interval: 1000ms
output: group
vars:
bin_name: pull-requester
tasks:
default:
cmds:
- task: clean
- task: build
- task: codeql
dirs:
desc: Creaete the required directories for building/testing
summary: |-
Create any required directories needed as part of building and/or testing
the application.
run: once
internal: true
cmds:
- cmd: mkdir -p bin
- cmd: mkdir -p coverage/unit
- cmd: mkdir -p coverage/integration
status:
- test -d bin
- test -d coverage/unit
- test -d coverage/integration
modules:
desc: Prepare the Go modules
aliases:
- m
sources:
- go.mod
- go.sum
cmds:
- go mod download
healthcheck:
desc: Check that the GoReleaser environment is valid
run: once
internal: true
sources:
- .goreleaser.yaml
cmds:
- cmd: goreleaser healthcheck
- cmd: goreleaser check
build:
desc: Locally build the application binary
summary: |-
Locally build the application binary for the testing and local
development of the utility with a temporary version number based on the
local commit and file contents.
deps:
- task: test
- task: lint
aliases:
- b
sources:
- "go.mod"
- "go.sum"
- "main.go"
- "**/*.go"
- ".goreleaser.yaml"
env:
# Exclude the floating tags for major and major/minor versions beyond the
# standard semver versioning, otherwise they will appear first in the list
GORELEASER_CURRENT_TAG:
sh: |-
git describe --tags --abbrev=0 \
--exclude 'v[0-9]' --exclude 'v[0-9].[0-9]' \
--exclude 'v[0-9].[0-9][0-9]' --exclude 'v[0-9].[0-9][0-9][0-9]' \
--exclude 'v[0-9][0-9]' --exclude 'v[0-9][0-9].[0-9]' \
--exclude 'v[0-9][0-9].[0-9][0-9]' --exclude 'v[0-9][0-9].[0-9][0-9][0-9]'
cmds:
- cmd: |-
goreleaser build --clean --timeout 2m \
--snapshot --single-target --output bin/{{ .bin_name }}
test:
desc: Run the unit tests for the application
deps:
# Make sure that all the directories needed are created first and that all
# the files are properly formatted before testing
- task: dirs
aliases:
- t
sources:
- "main.go"
- "**/*.go"
cmds:
# If this taskfile is being run inside of tmux, tell tmux to send the
# Enter key to the same pane as it is running in so that it exits
# scrolling mode and starts refreshing the screen as new tests are run
- cmd: |-
test -n "$TMUX_PANE" && tmux send-keys -t $TMUX_PANE Enter
silent: true
- cmd: |-
go test -v ./... \
-covermode=count \
-coverprofile=coverage.out
- cmd: |-
go tool cover \
-func=coverage.out
- cmd: |-
go tool cover \
-html=coverage.out \
-o=coverage.html
silent: true
fmt:
desc: Properly format all the .go files
summary: |-
Properly fomrmat all of the .go files using go (this is a write-based
action which will make changes to all .go files, if required).
aliases:
- f
sources:
- "main.go"
- "**/*.go"
cmds:
- cmd: go fmt ./...
lint:
desc: Check linting via golangci-lint
aliases:
- l
deps:
- task: healthcheck
sources:
- "main.go"
- "**/*.go"
- ".golangci.yaml"
cmds:
- cmd: golangci-lint run
codeql-database:
desc: Build the CodeQL database for analysis
run: once
internal: true
env:
CODEQL_EXTRACTOR_GO_BUILD_TRACING: on
cmds:
- cmd: |-
codeql database create .codeql --language=go \
--command 'goreleaser build --clean --snapshot --single-target'
status:
- test -d .codeql
codeql:
desc: Run CodeQL static code analysis
summary: |-
Run the CodeQL application against the codebase looking for configuration
issues and vunlerabilitys in both the code and any dependencies upstream.
aliases:
- s
deps:
- task: build
- task: codeql-database
sources:
- "go.mod"
- "go.sum"
- "main.go"
- "**/*.go"
cmds:
- cmd: |-
codeql database analyze --quiet --threads=-2 \
--format=sarif-latest --output codeql.sarif \
--sarif-add-file-contents --no-print-metrics-summary \
-- .codeql codeql/go-queries
clean:
desc: Clean up temporary files and locations
aliases:
- c
run: once
cmds:
- cmd: rm -f bin/{{ .bin_name }}
- cmd: rm -rf dist
- cmd: rm -rf coverage/*/* coverage.out
- cmd: rm -rf .codeql codeql.sarif
- cmd: rm -rf .task