-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
152 lines (140 loc) · 4.97 KB
/
Copy pathtaskfile.yaml
File metadata and controls
152 lines (140 loc) · 4.97 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: 3
vars:
GO_MODULES:
sh: awk '/^[[:space:]]*[^)]/ && NR>3 {gsub(/^[[:space:]]+/,""); print}' go.work
GO_ROOT_PKG:
sh: cat go.mod | grep -oE '^module[^\S]+' | cut -d' ' -f2
GO_COMMAND: go
TINYGO_COMMAND: tinygo
WASM_OUT_DIRS:
- editors/vscode/out
env:
COMPOSE_BAKE: true
GOPROXY: 'https://proxy.golang.org'
GOSUMDB: sum.golang.org
GOPRIVATE: github.com/walteh
DOCKER_BUILDKIT: 1
tasks:
go:tidy:
run: once
aliases: [go-mod-tidy]
cmds:
- for: {var: GO_MODULES}
cmd: cd {{.ITEM}} && go mod tidy -e
go:upgrade:
aliases: [go-mod-upgrade]
run: once
cmds:
- |-
{{.GO_COMMAND}} tool go-mod-upgrade --force
- task: go-mod-tidy
go:update:
aliases: [go-mod-update]
requires: {vars: [CLI_ARGS]}
run: once
cmds:
- task: go:tidy
- for: {var: GO_MODULES}
cmd: cd {{.ITEM}} && go get -u {{.CLI_ARGS}}
- task: go:tidy
test:
cmd: |-
{{.GO_COMMAND}} test ./...
build:wasm:
requires:
vars:
- GO_COMMAND
- GO_WASM_EXEC
vars:
GO_COMMAND: "{{.GO_COMMAND}}"
GO_WASM_EXEC:
sh: echo "$(go env GOROOT)/lib/wasm/wasm_exec.js"
TMP_DIR:
sh: mktemp -d
cmds:
- cmd: |-
cp {{.GO_WASM_EXEC}} {{.TMP_DIR}}/
- cmd: |-
CGO_ENABLED=0 GOOS=js GOARCH=wasm "{{.GO_COMMAND}}" build -ldflags="-s -w" -trimpath -o {{.TMP_DIR}}/retab.wasm ./cmd/retab
- cmd: |-
bun install
- for: {var: WASM_OUT_DIRS}
cmd: |-
mkdir -p {{.ITEM}} && cp {{.TMP_DIR}}/* {{.ITEM}}
- cmd: |-
rm -rf {{.TMP_DIR}}
build:wasm:tinygo:
cmds:
- task: build:wasm
vars:
GO_COMMAND: "{{.TINYGO_COMMAND}}"
GO_WASM_EXEC:
sh: "$(tinygo env TINYGOROOT)/targets/wasm_exec.js"
vscode:package:
dir: editors/vscode
cmds:
- task: build:wasm
- cmd: |-
bun run package
- cmd: |-
mv ./retab-*.vsix ~/Downloads
- cmd: |-
open https://marketplace.visualstudio.com/manage/publishers/walteh
vscode:rebuild:
dir: editors/vscode
cmds:
- task: build:wasm
- cmd: |-
bun run build
mockery:
run: once
desc: generates mocks for interfaces with '//go:mock' comment
vars:
TMP_DIR: ./gen/config
MOCKERY_INTERFACE_DATA:
sh: |-
grep -rl "//go:mock" --include="*.go" . \
| xargs -I{} bash -c 'd=$(dirname {}); d=${d#./}; awk -v d="$d {}" '\''/\/\/go:mock/ {getline; if($1=="type") print d, $2}'\'' {}'
MOCKERY_SOURCE_FILES:
sh: |-
grep -rl "//go:mock" --include="*.go" .
sources:
- '{{.MOCKERY_SOURCE_FILES | join ","}}'
- .mockery.yaml
generates:
- ./gen/mocks/**/*_mock.gen.go
- ./gen/config/.mockery.yaml
cmds:
- cmd: |-
mkdir -p {{.TMP_DIR}}
- cmd: |-
cp .mockery.yaml {{.TMP_DIR}}/.mockery.yaml
- for: {var: "MOCKERY_INTERFACE_DATA", split: "\n", as: ITEM}
cmd: |-
yq -i ".packages.\"{{ .GO_ROOT_PKG }}/{{ splitList " " .ITEM | first }}\".interfaces.{{ splitList " " .ITEM | last }} = {}" {{.TMP_DIR}}/.mockery.yaml
- cmd: |-
{{.GO_COMMAND}} tool github.com/vektra/mockery/v2 --config={{.TMP_DIR}}/.mockery.yaml
options:
run: once
desc: generates options for structs with '//go:opts' comment
vars:
OPTION_GEN_DATA:
sh: |-
grep -rl "//go:opts" --include="*.go" . | xargs -I{} bash -c 'd=$(dirname {}); d=${d#./}; awk -v d="$d {}" '\''/\/\/go:opts/ {getline; if($1=="type") print d, $2}'\'' {}'
OPTION_GEN_SOURCE_FILES:
sh: |-
grep -rl "//go:opts" --include="*.go" .
generates:
- "**/*_opts.gen.go"
sources:
- '{{.OPTION_GEN_SOURCE_FILES | join ","}}'
cmds:
- for: {var: OPTION_GEN_DATA, split: "\n"}
cmd: |-
set -e
{{.GO_COMMAND}} tool github.com/kazhuravlev/options-gen/cmd/options-gen \
-out-filename={{splitList " " .ITEM | first}}/{{ splitList " " .ITEM | last | lower | trimSuffix "opts" }}_opts.gen.go \
-filename={{ splitList " " .ITEM | rest | first }} \
-from-struct={{ splitList " " .ITEM | last }} \
-pkg={{ splitList " " .ITEM | first | splitList "/" | last }}