-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTaskfile.yml
78 lines (72 loc) · 2.86 KB
/
Taskfile.yml
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
# See: https://taskfile.dev/#/usage
version: "3"
includes:
dist: ./DistTasks.yml
vars:
# Path of the project's primary Go module:
DEFAULT_GO_MODULE_PATH: ./
DEFAULT_GO_PACKAGES:
sh: |
echo $(cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
# `-ldflags` flag to use for `go test` command
# TODO: define flag if required by the project, or leave empty if not needed.
TEST_LDFLAGS:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
PROJECT_NAME: "arduino-cloud-cli"
DIST_DIR: "dist"
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
TIMESTAMP:
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
TIMESTAMP_SHORT:
sh: echo "{{now | date "20060102"}}"
TAG:
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
CONFIGURATION_PACKAGE: github.com/arduino/arduino-cloud-cli/version
LDFLAGS: >-
-ldflags
'
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}}
-X {{.CONFIGURATION_PACKAGE}}.commit={{ .COMMIT }}
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
'
tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
cmds:
- go build -v {{.LDFLAGS}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
go:test:
desc: Run unit tests
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
go test \
-v \
-short \
-run '{{default ".*" .GO_TEST_REGEX}}' \
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
-coverprofile=coverage_unit.txt \
{{.TEST_LDFLAGS}} \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
general:cache-dep-licenses:
desc: Cache dependency license metadata
cmds:
- |
if ! which licensed &>/dev/null; then
echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable"
exit 1
fi
- licensed cache
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
general:check-dep-licenses:
desc: Check for unapproved dependency licenses
deps:
- task: general:cache-dep-licenses
cmds:
- licensed status