-
Notifications
You must be signed in to change notification settings - Fork 13
/
ABTaskFile
126 lines (108 loc) · 3.43 KB
/
ABTaskFile
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
# Install https://choria-io.github.io/appbuilder/ and run `abt` to use this file
name: build_tasks
description: NATS Developer Commands
commands:
- name: dependencies
type: parent
description: Manage dependencies
aliases: [d]
commands:
- name: update
description: Update dependencies
type: exec
aliases: [up]
flags:
- name: verbose
description: Log verbosely
bool: true
script: |
. "{{ BashHelperPath }}"
ab_announce Updating all dependencies
go get -u -n -a -t {{- if .Flags.verbose }} -d -x {{ end }} ./...
go mod tidy
- name: test
type: parent
aliases: [t]
description: Perform various tests
commands:
- name: unit
type: exec
description: Run unit tests
aliases: [u]
dir: "{{ AppDir }}"
environment:
- "TF_ACC=1"
script: go test -v --failfast -p=1 ./...
- name: lint
type: exec
dir: "{{ AppDir }}"
flags:
- name: vet
description: Perform go vet
bool: true
default: true
- name: staticcheck
description: Perform staticcheck
bool: true
default: true
- name: update
description: Updates lint dependencies
bool: true
script: |
set -e
. "{{ BashHelperPath }}"
{{ if .Flags.update }}
ab_say Updating linting tools
go install github.com/client9/misspell/cmd/misspell@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
{{ else }}
echo ">>> Run with --update to install required commands"
echo
{{ end }}
ab_say Formatting source files
go fmt ./...
ab_say Tidying go mod
go mod tidy
ab_say Checking spelling
find . -type f -name "*.go" | xargs misspell -error -locale US
{{ if .Flags.vet }}
ab_say Performing go vet
go vet ./...
{{ end }}
{{ if .Flags.staticcheck }}
ab_say Running staticcheck
staticcheck ./...
{{ end }}
- name: build
type: parent
aliases: [b]
description: Code build steps
commands:
- name: binary
aliases: [bin]
description: Build a basic test binary
type: exec
dir: "{{ TaskDir }}/nats"
banner: |
>>>
>>> Building 'nats' locally {{ if .Flags.target }}for target '{{ .Flags.target }}'{{ end }}
>>>
flags:
- name: target
description: Target platform to build for
enum: ["linux/amd64"]
short: T
script: |
{{ if eq .Flags.target "linux/amd64" }}
export GOOS=linux
export GOARCH=amd64
{{ end }}
go build -o nats
ls -l nats
- name: snapshot
description: Goreleaser snapshot
aliases: [snap]
type: exec
dir: "{{ TaskDir }}"
script: |
goreleaser release --snapshot --clean