-
Notifications
You must be signed in to change notification settings - Fork 13
/
Taskfile.yml
75 lines (65 loc) · 2.07 KB
/
Taskfile.yml
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
# https://taskfile.dev/
version: '3'
tasks:
ci:
desc: Workflow to run in CI
deps: [setup]
cmds:
- task: lint
- task: test
generate:
desc: Generate code based on PUBLIC GraphQL Interface
aliases: [gen]
cmds:
- go generate
- gofumpt -w .
generate-internal:
desc: Generate code based on INTERNAL internal GraphQL Interface
aliases: [gen-internal]
env:
GRAPHQL_VISIBILITY: "internal"
cmds:
- go generate
- gofumpt -w .
lint:
desc: Formatting and linting
cmds:
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- golangci-lint run
- nilaway -test=false -include-pkgs='github.com/opslevel/opslevel-go' ./...
fix:
desc: Fix formatting and linting
cmds:
- gofumpt -w .
- go mod tidy
- golangci-lint run --fix
- nilaway -fix -test=false -include-pkgs='github.com/opslevel/opslevel-go' ./...
setup:
desc: Setup linter, formatter, etc. for local testing and CI
cmds:
- task: install-go-tool
vars: { GO_TOOL: "gofumpt", GO_TOOL_PATH: "mvdan.cc/gofumpt@latest" }
- task: install-go-tool
vars: { GO_TOOL: "golangci-lint", GO_TOOL_PATH: "github.com/golangci/golangci-lint/cmd/[email protected]" }
- task: install-go-tool
vars: { GO_TOOL: "nilaway", GO_TOOL_PATH: "go.uber.org/nilaway/cmd/nilaway@latest" }
test:
desc: Run tests
cmds:
- go test -race -coverprofile=coverage.out -covermode=atomic -v ./... {{ .CLI_ARGS }}
- grep -v "/enum.go" coverage.out > coverage.txt
silent: true
# internal (not directly called) tasks
install-go-tool:
internal: true
silent: true
vars:
IS_TOOL_INSTALLED:
sh: which {{.GO_TOOL}} > /dev/null || echo "1"
cmds:
- test -z "{{.IS_TOOL_INSTALLED}}" || echo "Installing {{.GO_TOOL}}..."
- test -z "{{.IS_TOOL_INSTALLED}}" || go install {{.GO_TOOL_PATH}}
- test -n $(go env GOBIN) || go env -w GOBIN=$(go env GOPATH)/bin
- echo " '{{.GO_TOOL}}' is installed."
requires:
vars: [GO_TOOL, GO_TOOL_PATH]