-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskfile_library.yaml
More file actions
131 lines (114 loc) · 4.57 KB
/
Taskfile_library.yaml
File metadata and controls
131 lines (114 loc) · 4.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
version: 3
# This Taskfile is meant to be included for library repos.
# It contains tasks for code generation, validation, and release management.
run: once
method: checksum
includes:
generate:
taskfile: tasks_gen.yaml
aliases:
- gen
- g
tools:
taskfile: tasks_tools.yaml
validate:
taskfile: tasks_val.yaml
aliases:
- val
- v
release:
taskfile: tasks_rls.yaml
aliases:
- rls
- r
vars:
# whacky workarounds for incorrect paths in the special variables
# see https://github.com/go-task/task/issues/2056 and https://github.com/go-task/task/issues/2057
ROOT_DIR2: '{{.ROOT_DIR | trimSuffix "/common" | trimSuffix "/hack"}}'
TASKFILE_DIR2:
sh: 'if [[ "{{.TASKFILE_DIR}}" == "{{.ROOT_DIR2}}" ]] || [[ "{{.TASKFILE_DIR}}" == "" ]]; then echo -n "{{.ROOT_DIR2}}/hack/common"; else echo -n "{{.TASKFILE_DIR}}"; fi'
VERSION:
sh: 'PROJECT_ROOT="{{.ROOT_DIR2}}" {{.TASKFILE_DIR2}}/get-version.sh'
GIT_TREE_STATE:
sh: 'git diff --quiet && echo "clean" || echo "dirty"'
GIT_COMMIT:
sh: 'git rev-parse --verify HEAD || echo "unknown"'
BUILD_DATE:
sh: 'date -u +%Y-%m-%dT%H:%M:%SZ || echo "unknown"'
OS:
sh: echo ${OS:-$(go env GOOS)}
IMAGE_OS:
sh: echo ${IMAGE_OS:-linux}
ARCH:
sh: echo ${ARCH:-$(go env GOARCH)}
MODULE_NAME:
sh: 'cat "{{.ROOT_DIR2}}/go.mod" | grep "module " | sed "s/module //" | sed -E "s/[[:blank:]].*//"'
NESTED_MODULES: '{{.NESTED_MODULES | default "" }}'
DOCKERFILE: '{{.DOCKERFILE | default (print .TASKFILE_DIR2 "/Dockerfile") }}'
ALL_OS: [linux, darwin]
ALL_ARCH: [amd64, arm64]
REFERENCE_GENERATOR: '{{ .REFERENCE_GENERATOR | default (print .ROOT_DIR2 "/hack/cmdref/main.go") }}'
LOCALBIN: '{{ env "LOCALBIN" | default ( .LOCALBIN | default (print .ROOT_DIR2 "/bin") ) }}'
LOCALTMP: '{{ env "LOCALTMP" | default ( .LOCALTMP | default (print .ROOT_DIR2 "/tmp") ) }}'
CONTROLLER_GEN: '{{ .CONTROLLER_GEN | default (print .LOCALBIN "/controller-gen") }}'
FORMATTER: '{{ .FORMATTER | default (print .LOCALBIN "/goimports") }}'
LINTER: '{{ .LINTER | default (print .LOCALBIN "/golangci-lint") }}'
JQ: '{{ .JQ | default (print .LOCALBIN "/jq") }}'
HELM: '{{ .HELM | default (print .LOCALBIN "/helm") }}'
YAML2JSON: '{{ .YAML2JSON | default (print .LOCALBIN "/yaml2json") }}'
OCM: '{{ .OCM | default (print .LOCALBIN "/ocm") }}'
ENVTEST: '{{ .ENVTEST | default (print .LOCALBIN "/setup-envtest") }}'
# separator strings
SEP_MSG: "This is just a separator, what did you expect to happen?"
MAIN_SEP: "MAIN ###########################################################################"
GEN_SEP: "CODE AND DOCS GENERATION ### generate / gen / g ################################"
VAL_SEP: "CODE VALIDATION ### validate / val / v #########################################"
BLD_SEP: "BUILD ARTIFACTS ### build / bld / b ############################################"
BIN_SEP: "BINARY BUILDING ### bin / b ####################################################"
BLD_BIN_SEP: "BINARY BUILD --- bin -----------------------------------------------------------"
BLD_IMG_SEP: "IMAGE BUILD --- img ------------------------------------------------------------"
BLD_HLM_SEP: "HELM CHART BUILD --- helm ------------------------------------------------------"
BLD_OCM_SEP: "OCM COMPONENT BUILD --- ocm ----------------------------------------------------"
RLS_SEP: "RELEASE MANAGEMENT ### release / rls / r #######################################"
tasks:
# This is a dummy task that serves as a separator between task namespaces in the 'task -l' output.
"---":
desc: "{{.MAIN_SEP}}"
cmds:
- cmd: echo "{{.SEP_MSG}}"
silent: true
default: # This is executed if 'task' is called without any arguments.
silent: true
deps:
- help
help:
silent: true
cmds:
- cmd: task -l
silent: true # for some reason, this is not needed here, but let's keep it for consistency
generate:
desc: " Combines all code generation tasks, including formatting."
run: once
deps:
- generate:all
test:
desc: " Run all tests."
summary: This is an alias for 'validate:test'.
run: once
deps:
- validate:test
validate:
desc: " Combines all validation tasks except for tests."
summary: This is an alias for 'validate:all'.
run: once
aliases:
- verify
- check
deps:
- validate:validate
version:
desc: " Print the version of the project. Use VERSION_OVERRIDE to make this task print a specific version."
run: once
cmds:
- cmd: 'echo "{{.VERSION}}"'
silent: true