-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
130 lines (111 loc) · 2.88 KB
/
Taskfile.yaml
File metadata and controls
130 lines (111 loc) · 2.88 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
version: '3'
vars:
IMG: '{{.IMG | default "ghcr.io/datum-cloud/galactic:latest"}}'
CONTAINER_TOOL: '{{.CONTAINER_TOOL | default "docker"}}'
LOCALBIN:
sh: echo "$(pwd)/bin"
GOBIN:
sh: |
gobin=$(go env GOBIN)
[ -n "$gobin" ] && echo "$gobin" || echo "$(go env GOPATH)/bin"
GOLANGCI_LINT: '{{.LOCALBIN}}/golangci-lint'
GO_LICENSES: '{{.LOCALBIN}}/go-licenses'
GOLANGCI_LINT_VERSION: v2.1.6
GO_LICENSES_VERSION: v1.6.0
tasks:
default:
silent: true
cmds:
- task --list
##
## Development
##
fmt:
desc: Run go fmt against code
run: once
cmds:
- go fmt ./...
vet:
desc: Run go vet against code
run: once
cmds:
- GOOS=linux go vet ./...
test:
desc: Run tests
deps: [fmt, vet]
cmds:
- GOOS=linux go test $(go list ./... | grep -v /e2e) -coverprofile cover.out
lint:
desc: Run golangci-lint linter
deps: [golangci-lint]
cmds:
- '{{.GOLANGCI_LINT}} run'
lint-fix:
desc: Run golangci-lint linter and perform fixes
deps: [golangci-lint]
cmds:
- '{{.GOLANGCI_LINT}} run --fix'
notice:
desc: Generate NOTICE file with third-party dependency license information
deps: [go-licenses]
cmds:
- '{{.GO_LICENSES}} report ./... --ignore go.datum.net/galactic --template scripts/licenses/notice.tmpl > NOTICE'
##
## Build
##
build:
desc: Build galactic binary
deps: [fmt, vet]
cmds:
- go build -o bin/galactic cmd/galactic/main.go
run-agent:
desc: Run agent from your host
deps: [fmt, vet]
cmds:
- go run ./cmd/galactic/main.go agent
docker-build:
desc: Build docker image with the unified binary
cmds:
- '{{.CONTAINER_TOOL}} build -t {{.IMG}} -f containers/galactic/Dockerfile .'
##
## Cleanup
##
clean:
desc: Remove build artifacts and temporary files
cmds:
- rm -rf bin/
- rm -rf dist/
- rm -f cover.out
##
## Dependencies
##
golangci-lint:
desc: Download golangci-lint locally if necessary
run: once
cmds:
- task: install-tool
vars:
TARGET: '{{.GOLANGCI_LINT}}'
PACKAGE: github.com/golangci/golangci-lint/v2/cmd/golangci-lint
VERSION: '{{.GOLANGCI_LINT_VERSION}}'
go-licenses:
internal: true
run: once
cmds:
- task: install-tool
vars:
TARGET: '{{.GO_LICENSES}}'
PACKAGE: github.com/google/go-licenses
VERSION: '{{.GO_LICENSES_VERSION}}'
install-tool:
internal: true
cmds:
- mkdir -p {{.LOCALBIN}}
- |
if [ ! -f "{{.TARGET}}-{{.VERSION}}" ]; then
echo "Downloading {{.PACKAGE}}@{{.VERSION}}"
rm -f "{{.TARGET}}" || true
GOBIN={{.LOCALBIN}} go install {{.PACKAGE}}@{{.VERSION}}
mv "{{.TARGET}}" "{{.TARGET}}-{{.VERSION}}"
fi
ln -sf "{{.TARGET}}-{{.VERSION}}" "{{.TARGET}}"