| 1 |
version: "3" |
| 2 |
|
| 3 |
vars: |
| 4 |
DIST_DIR: "dist" |
| 5 |
DUMMY_MONITOR_VERSION: |
| 6 |
sh: echo "$(git describe --tags --dirty --broken)" |
| 7 |
DUMMY_MONITOR_TIMESTAMP: |
| 8 |
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" |
| 9 |
DUMMY_MONITOR_LDFLAGS: > |
| 10 |
-X github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor/args.Tag={{.DUMMY_MONITOR_VERSION}} |
| 11 |
-X github.com/arduino/pluggable-monitor-protocol-handler/dummy-monitor/args.Timestamp={{.DUMMY_MONITOR_TIMESTAMP}} |
| 12 |
DEFAULT_GO_PACKAGES: |
| 13 |
sh: echo $(go list ./... | tr '\n' ' ') |
| 14 |
|
| 15 |
tasks: |
| 16 |
build-dummy-monitor: |
| 17 |
desc: Build the dummy-monitor client example |
| 18 |
vars: |
| 19 |
EXECUTABLE: dummy-monitor{{if eq OS "windows"}}.exe{{end}} |
| 20 |
cmds: |
| 21 |
- go build -o dist/{{.EXECUTABLE}} -v -ldflags '{{.DUMMY_MONITOR_LDFLAGS}}' ./dummy-monitor |
| 22 |
|
| 23 |
|
| 24 |
ci:validate: |
| 25 |
desc: Validate GitHub Actions workflows against their JSON schema |
| 26 |
vars: |
| 27 |
|
| 28 |
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow |
| 29 |
WORKFLOW_SCHEMA_PATH: |
| 30 |
sh: mktemp -t workflow-schema-XXXXXXXXXX.json |
| 31 |
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}" |
| 32 |
cmds: |
| 33 |
- | |
| 34 |
wget \ |
| 35 |
--quiet \ |
| 36 |
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \ |
| 37 |
{{.WORKFLOW_SCHEMA_URL}} |
| 38 |
- | |
| 39 |
npx \ |
| 40 |
--package=ajv-cli \ |
| 41 |
--package=ajv-formats \ |
| 42 |
ajv validate \ |
| 43 |
--all-errors \ |
| 44 |
--strict=false \ |
| 45 |
-c ajv-formats \ |
| 46 |
-s "{{.WORKFLOW_SCHEMA_PATH}}" \ |
| 47 |
-d "{{.WORKFLOWS_DATA_PATH}}" |
| 48 |
|
| 49 |
|
| 50 |
general:cache-dep-licenses: |
| 51 |
desc: Cache dependency license metadata |
| 52 |
cmds: |
| 53 |
- | |
| 54 |
if ! which licensed &>/dev/null; then |
| 55 |
if [[ "{{OS}}" == "windows" ]]; then |
| 56 |
echo "Licensed does not have Windows support." |
| 57 |
echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact." |
| 58 |
else |
| 59 |
echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable" |
| 60 |
fi |
| 61 |
exit 1 |
| 62 |
fi |
| 63 |
- licensed cache |
| 64 |
|
| 65 |
|
| 66 |
general:check-dep-licenses: |
| 67 |
desc: Check for unapproved dependency licenses |
| 68 |
deps: |
| 69 |
- task: general:cache-dep-licenses |
| 70 |
cmds: |
| 71 |
- licensed status |
| 72 |
|
| 73 |
|
| 74 |
general:check-formatting: |
| 75 |
desc: Check basic formatting style of all files |
| 76 |
cmds: |
| 77 |
- | |
| 78 |
if ! which ec &>/dev/null; then |
| 79 |
echo "ec not found or not in PATH. Please install: https://github.com/editorconfig-checker/editorconfig-checker#installation" |
| 80 |
exit 1 |
| 81 |
fi |
| 82 |
- ec |
| 83 |
|
| 84 |
|
| 85 |
general:check-spelling: |
| 86 |
desc: Check for commonly misspelled words |
| 87 |
deps: |
| 88 |
- task: poetry:install-deps |
| 89 |
cmds: |
| 90 |
- poetry run codespell |
| 91 |
|
| 92 |
|
| 93 |
general:correct-spelling: |
| 94 |
desc: Correct commonly misspelled words where possible |
| 95 |
deps: |
| 96 |
- task: poetry:install-deps |
| 97 |
cmds: |
| 98 |
- poetry run codespell --write-changes |
| 99 |
|
| 100 |
|
| 101 |
poetry:install-deps: |
| 102 |
desc: Install dependencies managed by Poetry |
| 103 |
cmds: |
| 104 |
- poetry install --no-root |
| 105 |
|
| 106 |
|
| 107 |
poetry:update-deps: |
| 108 |
desc: Update all dependencies managed by Poetry to their newest versions |
| 109 |
cmds: |
| 110 |
- poetry update |
| 111 |
|
| 112 |
|
| 113 |
go:check: |
| 114 |
desc: Check for problems with Go code |
| 115 |
deps: |
| 116 |
- task: go:vet |
| 117 |
- task: go:lint |
| 118 |
|
| 119 |
|
| 120 |
go:vet: |
| 121 |
desc: Check for errors in Go code |
| 122 |
cmds: |
| 123 |
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 124 |
|
| 125 |
|
| 126 |
go:fix: |
| 127 |
desc: Modernize usages of outdated APIs |
| 128 |
cmds: |
| 129 |
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 130 |
|
| 131 |
|
| 132 |
go:lint: |
| 133 |
desc: Lint Go code |
| 134 |
cmds: |
| 135 |
- | |
| 136 |
if ! which golint &>/dev/null; then |
| 137 |
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation" |
| 138 |
exit 1 |
| 139 |
fi |
| 140 |
- | |
| 141 |
golint \ |
| 142 |
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \ |
| 143 |
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 144 |
|
| 145 |
|
| 146 |
go:format: |
| 147 |
desc: Format Go code |
| 148 |
cmds: |
| 149 |
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |