-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathTaskfile.yml
More file actions
132 lines (114 loc) · 3.57 KB
/
Taskfile.yml
File metadata and controls
132 lines (114 loc) · 3.57 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
131
132
---
version: "3.40"
vars:
SOURCES:
sh: find . -name "*.go" -type f -not -iname mock.go -not -path "./.devenv/*" -not -path "./.direnv/*" | xargs echo
PACKAGES:
sh: go list ./... | xargs echo
tasks:
clean:
desc: Remove all temporary build artifacts
cmds:
- go clean -i ./...
- rm -rf bin/ dist/
generate:
desc: Generate code for server
cmds:
- go generate {{ .PACKAGES }}
fmt:
desc: Run standard formatter for server
cmds:
- gofmt -s -w {{ .SOURCES }}
vet:
desc: Run vet linting for server
cmds:
- go vet {{ .PACKAGES }}
lint:
desc: Run revive linting for server
cmds:
- for PKG in {{ .PACKAGES }}; do go tool github.com/mgechev/revive -config revive.toml -set_exit_status $PKG || exit 1; done;
golangci:
desc: Run golangci linter for server
cmds:
- go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint run ./...
test:
desc: Run tests for server
cmds:
- go test -coverprofile coverage.out {{ .PACKAGES }}
build:
desc: Build all required binary artifacts
deps:
- build:server
build:release:
desc: Generate a release with goreleaser
cmds:
- goreleaser release --clean
build:snapshot:
desc: Generate a snapshot with goreleaser
cmds:
- goreleaser release --clean --snapshot --skip=announce,publish,validate,sign
build:server:
desc: Build server component
cmds:
- go build -v
-tags '{{ .TAGS }}'
-ldflags '-s -w -extldflags "-static" -X "{{ .IMPORT }}/pkg/version.String={{ .VERSION }}" -X "{{ .IMPORT }}/pkg/version.Revision={{ .REVISION }}" -X "{{ .IMPORT }}/pkg/version.Date={{ now | date "20060102" }}"'
-o bin/github_exporter{{if eq OS "windows"}}.exe{{end}}
./cmd/github_exporter
env:
CGO_ENABLED: "0"
GOOS: "{{ .GOOS }}"
GOARCH: "{{ .GOARCH }}"
vars:
IMPORT: github.com/promhippie/github_exporter
VERSION:
sh: if [[ -z "${CI_COMMIT_TAG}" ]]; then git rev-parse --short HEAD; else echo "${CI_COMMIT_TAG#v}"; fi
REVISION:
sh: git rev-parse --short HEAD
GOOS:
sh: go env GOOS
GOARCH:
sh: go env GOARCH
TAGS: |-
{{- if eq .GOOS "linux" -}}
{{- if eq .GOARCH "amd64" }}netgo sqlite chai{{ end }}
{{- if eq .GOARCH "386" }}netgo sqlite{{ end }}
{{- if eq .GOARCH "arm64" }}netgo sqlite chai{{ end }}
{{- if eq .GOARCH "arm" }}netgo sqlite{{ end }}
{{- if eq .GOARCH "mips64" }}netgo chai{{ end }}
{{- if eq .GOARCH "mips" }}netgo{{ end }}
{{- if eq .GOARCH "mips64le" }}netgo chai{{ end }}
{{- if eq .GOARCH "mipsle" }}netgo{{ end }}
{{- else if eq .GOOS "windows" -}}
{{- if eq .GOARCH "amd64" }}netgo sqlite chai{{ end }}
{{- if eq .GOARCH "386" }}netgo{{ end }}
{{- else -}}
netgo sqlite chai
{{- end -}}
watch:
desc: Run reloading development server
cmds:
- task: build:server
- bin/github_exporter --log.level=debug --log.pretty
watch: true
method: none
sources:
- 'cmd/**/*.go'
- 'pkg/**/*.go'
docs:
desc: Generate documentation with hugo
cmds:
- hugo -s docs/
envvars:
desc: Generate envvar partial for docs
cmds:
- go run hack/generate-envvars-docs.go
metrics:
desc: Generate metrics partial for docs
cmds:
- go run hack/generate-metrics-docs.go
labels:
desc: Generate labels partial for docs
cmds:
- go run hack/generate-labels-docs.go
...