-
Notifications
You must be signed in to change notification settings - Fork 3
/
Taskfile.yaml
148 lines (121 loc) · 3.6 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
version: "3"
vars:
OWNER: anchore
PROJECT: clio
# static file dirs
TOOL_DIR: .tool
TMP_DIR: .tmp
# tools
BOUNCER: "{{ .TOOL_DIR }}/bouncer"
GOIMPORTS: "{{ .TOOL_DIR }}/gosimports"
GOLANGCILINT: "{{ .TOOL_DIR }}/golangci-lint"
BINNY: "{{ .TOOL_DIR }}/binny"
# test details
# the quality gate lower threshold for unit test total % coverage (by function statements)
COVERAGE_THRESHOLD: 60
tasks:
## High-level tasks #################################
default:
desc: Run all validation tasks
cmds:
- task: static-analysis
- task: test
static-analysis:
desc: Run all static analysis tasks
cmds:
- task: lint
- task: check-licenses
test:
desc: Run all levels of test
cmds:
- task: unit
## Bootstrap tasks #################################
binny:
internal: true
# desc: Get the binny tool
generates:
- "{{ .BINNY }}"
status:
- "test -f {{ .BINNY }}"
cmd: "curl -sSfL https://raw.githubusercontent.com/anchore/binny/main/install.sh | sh -s -- -b .tool"
silent: true
tools:
desc: Install all tools needed for CI and local development
deps: [binny]
aliases:
- bootstrap
generates:
- ".binny.yaml"
- "{{ .TOOL_DIR }}/*"
status:
- "{{ .BINNY }} check -v"
cmd: "{{ .BINNY }} install -v"
silent: true
update-tools:
desc: Update pinned versions of all tools to their latest available versions
deps: [binny]
generates:
- ".binny.yaml"
- "{{ .TOOL_DIR }}/*"
cmd: "{{ .BINNY }} update -v"
silent: true
list-tools:
desc: List all tools needed for CI and local development
deps: [binny]
cmd: "{{ .BINNY }} list"
silent: true
list-tool-updates:
desc: List all tools that are not up to date relative to the binny config
deps: [binny]
cmd: "{{ .BINNY }} list --updates"
silent: true
tmpdir:
silent: true
internal: true
generates:
- "{{ .TMP_DIR }}"
cmd: "mkdir -p {{ .TMP_DIR }}"
## Static analysis tasks #################################
format:
desc: Auto-format all source code
deps: [tools]
cmds:
- gofmt -w -s .
- "{{ .GOIMPORTS }} -local github.com/anchore -w ."
- go mod tidy
lint-fix:
desc: Auto-format all source code + run golangci lint fixers
deps: [tools]
cmds:
- task: format
- "{{ .GOLANGCILINT }} run --tests=false --fix"
lint:
desc: Run code format + lint checks
vars:
BAD_FMT_FILES:
sh: gofmt -l -s .
BAD_FILE_NAMES:
sh: "find . | grep -e ':' || true"
deps: [tools]
cmds:
# ensure there are no go fmt differences
- cmd: 'test -z "{{ .BAD_FMT_FILES }}" || (echo "files with gofmt issues: [{{ .BAD_FMT_FILES }}]"; exit 1)'
silent: true
# ensure there are no files with ":" in it (a known back case in the go ecosystem)
- cmd: 'test -z "{{ .BAD_FILE_NAMES }}" || (echo "files with bad names: [{{ .BAD_FILE_NAMES }}]"; exit 1)'
silent: true
# run linting
- "{{ .GOLANGCILINT }} run --tests=false"
- go mod tidy --diff
check-licenses:
# desc: Ensure transitive dependencies are compliant with the current license policy
deps: [tools]
cmd: "{{ .BOUNCER }} check ./..."
## Testing tasks #################################
unit:
deps: [tmpdir]
desc: Run unit tests
# TODO: switch to canopy release invocation
cmds:
- "go test -coverprofile {{ .TMP_DIR }}/unit-coverage-details.txt ./..."
- .github/scripts/coverage.py {{ .COVERAGE_THRESHOLD }} {{ .TMP_DIR }}/unit-coverage-details.txt