forked from taskctl/taskctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.yaml
200 lines (178 loc) · 5.95 KB
/
tasks.yaml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# yaml-language-server: $schema=schemas/schema_v1.json
debug: false
output: prefixed
# TODO: top level variables are not being munged int
# variables:
# foo: 1
pipelines:
fixcs:
- task: goimports
dir: "{{.Root}}"
- task: gofmt
dir: "{{.Root}}"
depends_on: goimports
prepare:
- task: tidy
- task: test
- task: goimports
depends_on: test
- task: gofmt
depends_on: goimports
- pipeline: lints
lints:
- task: golint
- task: govet
depends_on: golint
test:unit:
- task: clean
- task: test_prereqs
- task: test
depends_on:
- clean
- test_prereqs
show:coverage:
- pipeline: test:unit
- task: show_coverage
depends_on:
- test:unit
build:binary:
- task: clean
- task: build
depends_on:
- clean
variables:
RepoOwner: Ensono
BinName: taskctl
tasks:
clean:
command:
- echo "running clean"
- |
rm -rf bin/*
rm -rf dist/*
rm -rf vendor/*
test_prereqs:
command:
- echo "running test pre-requisites"
- |
mkdir -p .coverage
go install github.com/jstemmer/go-junit-report@v0.9.1 && \
go install github.com/axw/gocov/gocov@v1.0.0 && \
go install github.com/AlekSi/gocov-xml@v1.0.0
test:
command:
- echo "running tests..."
- go test $(go list ./... | grep -v /local/) -v -race -mod=readonly -shuffle=on -coverprofile=.coverage/out > .coverage/test.out
- cat .coverage/test.out | go-junit-report > .coverage/report-junit.xml
- gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml
after:
- cat .coverage/test.out
allow_failure: true
build:
description: Builds the binary
command:
- |
ldflags="-s -w -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd/taskctl.Version={{.Version}}\" -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd/taskctl.Revision={{.Revision}}\" -extldflags -static"
GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -mod=readonly -buildvcs=false -ldflags="$ldflags" -o bin/{{.BinName}}-${GOOS}-${GOARCH}${BINARY_SUFFIX} cmd/main.go
variations:
- GOOS: windows
GOARCH: amd64
BINARY_SUFFIX: .exe
- GOOS: windows
GOARCH: "386"
BINARY_SUFFIX: .exe
- GOOS: windows
GOARCH: arm64
BINARY_SUFFIX: .exe
- GOOS: darwin
GOARCH: amd64
BINARY_SUFFIX: ""
- GOOS: darwin
GOARCH: arm64
BINARY_SUFFIX: ""
- GOOS: linux
GOARCH: arm64
BINARY_SUFFIX: ""
- GOOS: linux
GOARCH: amd64
BINARY_SUFFIX: ""
reset_context: true
variables:
RepoOwner: Ensono
BinName: taskctl
golint:
# in CI it is run
command:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint run
govet:
command:
- go vet ./...
goimports:
command:
- goimports -v -local github.com/Ensono/taskctl -w -format-only $(ls -d internal/**/*.go)
- goimports -v -local github.com/Ensono/taskctl -w -format-only $(ls -d pkg/**/*.go)
- goimports -v -local github.com/Ensono/taskctl -w -format-only $(ls -d cmd/**/*.go)
goreleaser:
command:
- goreleaser --debug --rm-dist
gofmt:
command:
- go fmt -x ./...
- gofmt -s -w cmd/**/*.go
- gofmt -s -w internal/**/*.go
- gofmt -s -w pkg/**/*.go
schema_gen_deps:
description: |
Installing dependencies for the struct type generation
command:
- pnpm install -g quicktype
generate_own_schema:
description: |
Generates the schema for a taskctl itself as well as generating types for a given CI implementation.
command:
- go run tools/schemagenerator/main.go
- |
if [ ! -z "$(git status --porcelain --untracked-files=no)" ]; then
if [ ! -z ${CI+x} ] ; then
echo "In CI with an unclean tree - exiting"
echo "Info: make sure you have generatedschema and committed"
exit 1
fi
fi
generate_ci_structs_from_schema:
description: |
Type generation for target CI definitions used by the generate command
CI Definitions will be used by generate-def command.
```
config.GitHubCITarget: "https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json",
config.GitlabCITarget: "https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json",
// TODO: add more here - every time you add another implementation
```
command:
- mkdir -p ./internal/z_generated/github
- quicktype --lang go --src-lang schema --src ./internal/z_generated/schema/sources/github.json -o internal/z_generated/github/schema.go --field-tags yaml \
--just-types-and-package --omit-empty --package githubworkflow &2>1
- go fmt ./internal/z_generated/github
- mkdir -p ./internal/z_generated/gitlab
- quicktype --lang go --src-lang schema --src ./internal/z_generated/schema/sources/gitlab.json -o internal/z_generated/gitlab/schema.go --field-tags yaml \
--just-types-and-package --omit-empty --package gitlab &2>1
- go fmt ./internal/z_generated/gitlab
# variations:
# # - CI_TARGET: github
# # SCHEMA: ./internal/z_generated/schema/sources/github.json
# - CI_TARGET: gitlab
# SCHEMA: ./internal/z_generated/schema/sources/gitlab.json # https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json
show_coverage:
command:
- echo "Opening coverage html page"
- go tool cover -html=.coverage/out
show_docs:
command:
- go install golang.org/x/tools/cmd/godoc@latest
- open http://localhost:6060/pkg/github.com/Ensono/taskctl/?m=all
- godoc -notes "BUG|TODO" -play -http=:6060
tidy:
name: "tidy me up"
command:
- go mod tidy