-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
60 lines (54 loc) · 1.89 KB
/
Taskfile.yml
File metadata and controls
60 lines (54 loc) · 1.89 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
version: '3'
vars:
APP_NAME:
sh: pwd | grep -Po "[^/]+$"
SOURCE_DIR:
sh: find $(pwd) -mindepth 1 -maxdepth 2 -regex ".*\.go$" | head -n 1 | grep -Po ".*(?=\/)"
SUB_MODS:
sh: find src -mindepth 1 -maxdepth 1 -type d | grep -Po "(?<=src/).*" | tr '\n' ':'
tasks:
default:
cmds:
- task: test
- task: build
build:
desc: build binary using remote ghwfe script, requires curl
cmds:
- cmd: curl -sL https://raw.githubusercontent.com/triole/ghwfe/master/sh/go_build.sh | bash
test:
desc: run go tests
sources:
- src/*
method: timestamp
dir: src
cmds:
- cmd: >-
go test
-trace go.trace -race -cover -bench=.
{{.SOURCE_DIR}}/*.go
deploy:
desc: build and copy to my personal arch mybins folder
cmds:
- task: build
- cmd : cp -rpf build/* ${HOME}/tools/arch/mybins/
mod:
env:
SD: "{{.SOURCE_DIR}}"
AN: "{{.APP_NAME}}"
desc: update go modules, add submodules to go root
cmds:
- cmd: if [[ ! -f go.mod ]]; then go mod init {{.APP_NAME}}; fi
- cmd: go mod tidy
- cmd: mkdir -p "${GOROOT}/src/{{.APP_NAME}}"
- cmd: >-
{{range $i, $mod := split ":" .SUB_MODS }}
{{if $mod}}
if [[ ! -L "${GOROOT}/src/${AN}/{{$mod}}" ]]; then
if [[ ! -d "${GOROOT}/src/${AN}/{{$mod}}" ]]; then
if [[ ! -f "${GOROOT}/src/${AN}/{{$mod}}" ]]; then
ln -s ${SD}/{{$mod}} "${GOROOT}/src/${AN}/{{$mod}}"
fi
fi
fi
{{end}}
{{end}}