Repository navigation
Expand file tree
/
Copy pathtasks.toml
More file actions
107 lines (97 loc) · 2.84 KB
/
Copy pathtasks.toml
File metadata and controls
107 lines (97 loc) · 2.84 KB
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
['scripts:bump']
description = 'Upgrade Go version and Go dependencies'
hide = true
dir = 'scripts'
run = '''
go get "go@$(go env GOVERSION | cut -c 3-)" toolchain@none
go get -u -t ./...
go mod tidy
'''
['scripts:build']
description = 'Build Go scripts into $SCRIPTS_BIN'
hide = true
dir = 'scripts'
silent = 'stdout' # Hide "sources up-to-date, skipping", but keep build errors.
sources = ['**/*']
outputs = ['{{env.SCRIPTS_BIN}}/*']
run = '''
for f in "${SCRIPTS_BIN:?}"/*; do
[ -d "${f##*/}" ] || rm -f "$f"
done
go build -ldflags="-s -w" -o "${SCRIPTS_BIN:?}/" ./...
'''
run_windows = """
powershell -NoProfile -Command "if (Test-Path $env:SCRIPTS_BIN) { \
Get-ChildItem $env:SCRIPTS_BIN -File \
| Where-Object { -not (Test-Path -PathType Container $_.BaseName) } \
| Remove-Item }" \
&& go build -ldflags="-s -w" -o "%SCRIPTS_BIN%/" ./...\
"""
['scripts:generate']
description = 'Generate Go code of Go scripts'
hide = true
dir = 'scripts'
# mockery fails to load a package with an outdated output, so outputs are removed first.
run = '''
git grep --untracked -lz '^// Code generated by mockery; DO NOT EDIT\.$' -- '*.go' | xargs -0 -r rm --
mockery
go generate ./...
'''
['scripts:fix']
description = 'Apply automatic fixes to Go scripts'
dir = 'scripts'
run = '''
go fix ./...
golangci-lint run --fix --issues-exit-code=0
'''
['scripts:fmt']
description = 'Format Go scripts'
hide = true
dir = 'scripts'
run = 'golangci-lint fmt'
['scripts:lint']
description = 'Lint Go scripts and their usage specs'
hide = true
dir = 'scripts'
run = [
'golangci-lint run',
{ tasks = ['scripts:lint:*'] },
]
['scripts:lint:usage']
description = 'Lint usage specs of Go scripts'
hide = true
depends = 'scripts:build'
# usage lint prints both "No issues found." and findings to stdout,
# so findings are shown by a second run only when the first one fails.
run = '''
for f in "${SCRIPTS_BIN:?}"/*; do
spec=$("$f" --usage-spec)
printf '%s\n' "$spec" | usage lint -W - >/dev/null 2>&1 ||
printf '%s\n' "$spec" | usage lint -W -
done
'''
['scripts:test']
description = 'Test Go scripts'
dir = 'scripts'
run = 'gotestsum -- -race -timeout=60s ./...'
['scripts:cover']
description = 'Show test coverage of Go scripts'
depends = 'scripts:cover:generate'
dir = 'scripts'
run = 'go tool cover -func="{{config_root}}/{{vars.scripts_cover}}"'
['scripts:cover:browse']
description = 'Show test coverage of Go scripts in a browser'
depends = 'scripts:cover:generate'
env.TMPDIR = "{{ get_env(name='BROWSER_TMPDIR', default=get_env(name='TMPDIR', default='/tmp')) }}"
dir = 'scripts'
run = 'go tool cover -html="{{config_root}}/{{vars.scripts_cover}}"'
['scripts:cover:generate']
hide = true
depends = 'cachedir'
dir = 'scripts'
run = '''
gotestsum -- \
-coverpkg="$(go list ./... | paste -s -d,)" \
-coverprofile "{{config_root}}/{{vars.scripts_cover}}" \
./...
'''