|
| 1 | +version: "3" |
| 2 | + |
| 3 | +# `.env.local` takes precedence. Only new keys found in the `.env` will be |
| 4 | +# appended to the current set. |
| 5 | +dotenv: [".env.local", ".env"] |
| 6 | + |
| 7 | +vars: |
| 8 | + GOLANGCI_LINT_VERSION: v2.4.0 |
| 9 | + GOIMPORTS_VERSION: v0.29.0 |
| 10 | + DPRINT_VERSION: 0.48.0 |
| 11 | + EXAMPLE_VERSION: "0.4.8" |
| 12 | + RUNNER_VERSION: "0.4.8" |
| 13 | + VERSION: # if version is not passed we hack the semver by encoding the commit as pre-release |
| 14 | + sh: echo "${VERSION:-0.0.0-$(git rev-parse --short HEAD)}" |
| 15 | + |
| 16 | +tasks: |
| 17 | + init: |
| 18 | + desc: Setup local env |
| 19 | + deps: |
| 20 | + - install:linter |
| 21 | + - install:goimports |
| 22 | + - install:watcher |
| 23 | + - install:dprint |
| 24 | + - install:oapi-codegen |
| 25 | + |
| 26 | + install:linter: |
| 27 | + cmds: |
| 28 | + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin/ {{ .GOLANGCI_LINT_VERSION }} |
| 29 | + |
| 30 | + install:goimports: |
| 31 | + cmds: |
| 32 | + - go install golang.org/x/tools/cmd/goimports@{{ .GOIMPORTS_VERSION }} |
| 33 | + |
| 34 | + install:watcher: |
| 35 | + cmds: |
| 36 | + - go install github.com/githubnemo/CompileDaemon@v1.4.0 |
| 37 | + |
| 38 | + install:dprint: |
| 39 | + cmds: |
| 40 | + - curl -fsSL https://dprint.dev/install.sh | sh -s {{ .DPRINT_VERSION }} |
| 41 | + - mkdir -p .bin && cp $HOME/.dprint/bin/dprint .bin/dprint # workaround for local install |
| 42 | + |
| 43 | + install:oapi-codegen: |
| 44 | + cmds: |
| 45 | + - go get -tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest |
| 46 | + |
| 47 | + test: |
| 48 | + desc: Run all tests |
| 49 | + deps: [test:internal, test:pkg] |
| 50 | + |
| 51 | + test:internal: |
| 52 | + cmds: |
| 53 | + - go build ./cmd/arduino-app-cli # needed for e2e tests |
| 54 | + - task: generate |
| 55 | + - go test ./internal/... ./cmd/... -v -race {{ .CLI_ARGS }} |
| 56 | + |
| 57 | + test:pkg: |
| 58 | + desc: Run only tests in the pkg directory |
| 59 | + cmds: |
| 60 | + - go test ./pkg/... -v -race {{ .CLI_ARGS }} |
| 61 | + |
| 62 | + test:cover: |
| 63 | + desc: Run all tests and open cover html report |
| 64 | + cmds: |
| 65 | + - task test -- -coverprofile=coverage.out |
| 66 | + - go tool cover -func=coverage.out |
| 67 | + - go tool cover -html=coverage.out |
| 68 | + |
| 69 | + lint: |
| 70 | + desc: Run the linters |
| 71 | + cmds: |
| 72 | + - ${PWD}/.bin/golangci-lint run --fix -v --timeout 300s {{ .CLI_ARGS }} |
| 73 | + |
| 74 | + fmt: |
| 75 | + desc: Run format |
| 76 | + cmds: |
| 77 | + - goimports -l -w . |
| 78 | + - ${PWD}/.bin/dprint fmt |
| 79 | + |
| 80 | + generate: |
| 81 | + desc: Run go generate |
| 82 | + cmds: |
| 83 | + - go generate ./... |
| 84 | + |
| 85 | + fmt-check: |
| 86 | + desc: Check format |
| 87 | + cmds: |
| 88 | + - ${PWD}/.bin/dprint check |
| 89 | + |
| 90 | + doc: |
| 91 | + desc: Doc generation |
| 92 | + cmds: |
| 93 | + - go run ./cmd/gendoc |
| 94 | + |
| 95 | + api:docs: |
| 96 | + desc: Open api docs |
| 97 | + cmds: |
| 98 | + - python3 -m http.server 8000 -d docs |
| 99 | + |
| 100 | + clone-examples-repo: |
| 101 | + desc: "Clones the examples repo directly into the debian structure" |
| 102 | + cmds: |
| 103 | + - | |
| 104 | + set -e |
| 105 | + echo "Runner version set as: {{ .EXAMPLE_VERSION }}" |
| 106 | + TMP_PATH="$(mktemp -d)" |
| 107 | + DEST_PATH="debian/arduino-app-cli/home/arduino/.local/share/arduino-app-cli/" |
| 108 | + echo "Cloning bcmi-labs/app-bricks-example into temporary directory ${TMP_PATH}..." |
| 109 | + git clone --depth 1 --branch "{{ .EXAMPLE_VERSION }}" https://github.com/bcmi-labs/app-bricks-example "${TMP_PATH}" |
| 110 | + rm -rf "${DEST_PATH}/examples" |
| 111 | + mkdir -p "${DEST_PATH}" |
| 112 | + mv "${TMP_PATH}/examples" "${DEST_PATH}" |
| 113 | + rm -rf "${TMP_PATH}/examples" |
| 114 | + echo "Examples successfully cloned." |
| 115 | + silent: false |
| 116 | + |
| 117 | + build-deb:arduino-app-cli: |
| 118 | + desc: Build debian package |
| 119 | + deps: |
| 120 | + - clone-examples-repo |
| 121 | + cmds: |
| 122 | + - docker build --build-arg BINARY_NAME=arduino-app-cli --build-arg DEB_NAME=arduino-app-cli --build-arg VERSION={{ .VERSION }} --build-arg ARCH={{ .ARCH }} --build-arg RELEASE={{ .RELEASE }} --output=./build -f debian/Dockerfile . |
| 123 | + vars: |
| 124 | + ARCH: '{{.ARCH | default "arm64"}}' |
| 125 | + |
| 126 | + arduino-app-cli:build:local: |
| 127 | + desc: "Build the arduino-app-cli locally" |
| 128 | + cmds: |
| 129 | + - go build -v -o ./build/arduino-app-cli ./cmd/arduino-app-cli |
| 130 | + |
| 131 | + arduino-app-cli:release: |
| 132 | + desc: Create a tag on the current commit and push it to the remote to create the release |
| 133 | + cmds: |
| 134 | + - | |
| 135 | + if [ -z "{{.CLI_ARGS}}" ]; then |
| 136 | + echo "Error: Version argument is required. Usage: task orchestrator:trigger:release -- <version>" |
| 137 | + exit 1 |
| 138 | + fi |
| 139 | + - git tag -a "{{.CLI_ARGS}}" -m "Release {{.CLI_ARGS}}" |
| 140 | + - git push origin "{{.CLI_ARGS}}" |
| 141 | + |
| 142 | + arduino-app-cli:start: |
| 143 | + desc: "build and launch the arduino-app-cli in daemon mode" |
| 144 | + cmds: |
| 145 | + - task arduino-app-cli:build:local |
| 146 | + - ./build/arduino-app-cli daemon --port 6060 |
| 147 | + |
| 148 | + # To to forward a port, using ssh, you can use this command: |
| 149 | + # ssh -L 8800:localhost:8800 arduino@<BOARD_IP> |
| 150 | + arduino-app-cli:pprof: |
| 151 | + desc: Open pprof UI |
| 152 | + cmds: |
| 153 | + - go tool pprof -http=:8084 {{ .URL }}/debug/pprof/{{ .TYPE }} |
| 154 | + vars: |
| 155 | + TYPE: '{{.TYPE | default "heap"}}' # goroutine, heap, mutex |
| 156 | + URL: '{{ .URL| default "http://localhost:8800" }}' |
| 157 | + |
| 158 | + adbd:start: |
| 159 | + desc: interact with adbd |
| 160 | + cmds: |
| 161 | + - docker build -t adbd -f adbd.Dockerfile . |
| 162 | + - docker rm -f adbd || true |
| 163 | + - docker run --rm --name adbd -d -p 5555:5555 -p 2222:22 -v $HOME/.arduino-app-cli/examples:/apps adbd |
| 164 | + |
| 165 | + adbd:stop: |
| 166 | + desc: stop adbd |
| 167 | + cmds: |
| 168 | + - docker rm -f adbd |
| 169 | + |
| 170 | + board:install-arduino-app-cli: |
| 171 | + desc: Install arduino-app-cli on the board |
| 172 | + interactive: true |
| 173 | + cmds: |
| 174 | + - rm ./build/*.deb || true |
| 175 | + - task: build-deb:arduino-app-cli |
| 176 | + - adb shell rm /tmp/*.deb || true |
| 177 | + - adb push ./build/arduino-app-cli_*_arm64.deb /tmp/ |
| 178 | + - ./scripts/run-remote-sudo.sh "dpkg -i /tmp/arduino-app-cli*_arm64.deb && needrestart -r a" |
| 179 | + |
| 180 | + setup:examples:local: |
| 181 | + desc: Download and locally install the official examples |
| 182 | + cmds: |
| 183 | + - | |
| 184 | + set -e |
| 185 | + DEST_PATH=$(case "$(uname)" in |
| 186 | + Darwin) echo "$HOME/Library/Application Support/arduino-app-cli/" ;; |
| 187 | + Linux) echo "$HOME/.config/arduino-app-cli/" ;; |
| 188 | + *) echo "$AppData/arduino-app-cli/" ;; |
| 189 | + esac) |
| 190 | + TMP_PATH="$(mktemp -d)" |
| 191 | +
|
| 192 | + echo "Cloning examples into temporary directory ${TMP_PATH}..." |
| 193 | + git clone --depth 1 https://github.com/bcmi-labs/app-bricks-example.git "${TMP_PATH}" |
| 194 | +
|
| 195 | + echo "Installing examples to ${DEST_PATH}examples" |
| 196 | + rm -rf "${DEST_PATH}examples" |
| 197 | + mkdir -p "${DEST_PATH}" |
| 198 | +
|
| 199 | + mv "${TMP_PATH}/examples" "${DEST_PATH}" |
| 200 | +
|
| 201 | + rm -rf "${TMP_PATH}" |
| 202 | + echo "Examples installed successfully." |
| 203 | +
|
| 204 | + generate:assets: |
| 205 | + desc: This generates the models and bricks index. Also updates the corresponding testdata. |
| 206 | + vars: |
| 207 | + sed_replacement: s#runnerVersion = \".*#runnerVersion = \"{{.RUNNER_VERSION}}\"# |
| 208 | + TMPDIR: '{{trimSuffix "/" .TMPDIR| default "/tmp"}}/generate-assets' |
| 209 | + SEMVER_TAG: "{{.RUNNER_VERSION}}" |
| 210 | + OUTPUT_DIR: "{{.TMPDIR}}/{{.SEMVER_TAG}}" |
| 211 | + ASSETS_DIR: debian/arduino-app-cli/home/arduino/.local/share/arduino-app-cli/assets |
| 212 | + TESTDATA_DIR: internal/e2e/daemon/testdata/assets |
| 213 | + preconditions: |
| 214 | + - sh: '[ ! -d "{{.ASSETS_DIR}}/{{.SEMVER_TAG}}" ] || [ ! -d "{{.TESTDATA_DIR}}/{{.SEMVER_TAG}}" ]' |
| 215 | + msg: "Both assets folder are already at version '{{.RUNNER_VERSION}}'. Nothing to do." |
| 216 | + cmds: |
| 217 | + - | |
| 218 | + # Get the corresponding models and bricks release, and unzip it. |
| 219 | + gh release download -R bcmi-labs/app-bricks-py "release/{{.SEMVER_TAG}}" -p '*.whl' -D "{{.TMPDIR}}" --clobber |
| 220 | + unzip -o "{{.TMPDIR}}/arduino_app_bricks-{{.SEMVER_TAG}}-py3-none-any.whl" -d "{{.OUTPUT_DIR}}" |
| 221 | + - | |
| 222 | + # Copy the assets to the assets dir and testdata dir, replacing the previous version. |
| 223 | + rm -rf "{{.ASSETS_DIR}}" && mkdir -p "{{.ASSETS_DIR}}" |
| 224 | + cp -r "{{.OUTPUT_DIR}}/arduino/app_bricks/static" "{{.ASSETS_DIR}}/{{.SEMVER_TAG}}" |
| 225 | + rm -rf "{{.TESTDATA_DIR}}" && mkdir -p "{{.TESTDATA_DIR}}" |
| 226 | + cp -r "{{.OUTPUT_DIR}}/arduino/app_bricks/static" "{{.TESTDATA_DIR}}/{{.SEMVER_TAG}}" |
| 227 | + - cmd: rm -rf {{.TMPDIR}} |
| 228 | + - cmd: echo "Updating the runnerVersion in config.go to '{{.RUNNER_VERSION}}'" |
| 229 | + - cmd: sed -i "{{.sed_replacement}}" internal/orchestrator/config/config.go |
| 230 | + platforms: [linux] |
| 231 | + - cmd: sed -i '' "{{.sed_replacement}}" internal/orchestrator/config/config.go |
| 232 | + platforms: [darwin] |
| 233 | + |
| 234 | + update-deb-copyright: |
| 235 | + desc: Extract project and dependency licenses into asd copyright |
| 236 | + cmds: |
| 237 | + - | |
| 238 | + gem install licensed --version "{{.LICENSED_VERSION}}" |
| 239 | +
|
| 240 | + licensed cache |
| 241 | + licensed notices |
| 242 | + cat > debian/arduino-app-cli/usr/share/doc/arduino-app-cli/copyright <<EOF |
| 243 | + Copyright 2025 ARDUINO SA (http://www.arduino.cc/) |
| 244 | +
|
| 245 | + This software is released under the GNU General Public License version 3, |
| 246 | + which covers the main part of arduino-app-cli. |
| 247 | + The terms of this license can be found at: |
| 248 | + https://www.gnu.org/licenses/gpl-3.0.en.html |
| 249 | +
|
| 250 | + You can be released from the requirements of the above licenses by purchasing |
| 251 | + a commercial license. Buying such a license is mandatory if you want to |
| 252 | + modify or otherwise use the software for commercial activities involving the |
| 253 | + Arduino software without disclosing the source code of your own applications. |
| 254 | + To purchase a commercial license, send an email to license@arduino.cc. |
| 255 | +
|
| 256 | + --- |
| 257 | +
|
| 258 | + EOF |
| 259 | + cat .licenses/arduino-app-cli/NOTICE >> debian/arduino-app-cli/usr/share/doc/arduino-app-cli/copyright |
| 260 | +
|
| 261 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 262 | + general:cache-dep-licenses: |
| 263 | + desc: Cache dependency license metadata |
| 264 | + deps: |
| 265 | + - task: general:prepare-deps |
| 266 | + cmds: |
| 267 | + - | |
| 268 | + if |
| 269 | + ! which licensed \ |
| 270 | + &>/dev/null |
| 271 | + then |
| 272 | + if [[ {{OS}} == "windows" ]]; then |
| 273 | + echo "Licensed does not have Windows support." |
| 274 | + echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact." |
| 275 | + else |
| 276 | + echo "licensed not found or not in PATH." |
| 277 | + echo "Please install: https://github.com/licensee/licensed#installation" |
| 278 | + fi |
| 279 | + exit 1 |
| 280 | + fi |
| 281 | + - licensed cache |
| 282 | + |
| 283 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 284 | + general:check-dep-licenses: |
| 285 | + desc: Check for unapproved dependency licenses |
| 286 | + deps: |
| 287 | + - task: general:cache-dep-licenses |
| 288 | + cmds: |
| 289 | + - licensed status |
| 290 | + |
| 291 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-dependencies-task/Taskfile.yml |
| 292 | + general:prepare-deps: |
| 293 | + desc: Prepare project dependencies for license check |
| 294 | + # No preparation is needed for Go module-based projects. |
0 commit comments