diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ab77e2f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Default configuration for all files +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +# Use utf-8 charset for modern languages +[*.{go}] +charset = utf-8 + +# Use tab indentation for Go and Makefiles +[{*.go,go.*}] +indent_style = tab +indent_size = 4 + diff --git a/.github/workflows/go-checks.yaml b/.github/workflows/go-checks.yaml index 24ad092..9ff9acf 100644 --- a/.github/workflows/go-checks.yaml +++ b/.github/workflows/go-checks.yaml @@ -36,4 +36,3 @@ jobs: run: | go mod tidy git diff --color --exit-code - diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index e0b63a9..a339e91 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -6,9 +6,6 @@ on: pull_request: branches: [main] -env: - GO_VERSION: "1.25.1" - # In the same branch only 1 workflow per time can run. In case we're not in the # main branch we cancel previous running workflow concurrency: @@ -25,8 +22,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Run tests - run: go test -v --race ./... - + run: go tool task test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5101ba..731847d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,6 @@ on: - "*" # Trigger on all tags env: - GO_VERSION: "1.25.1" PROJECT_NAME: "remoteocd" GITHUB_TOKEN: ${{ secrets.ARDUINOBOT_TOKEN }} GITHUB_USERNAME: ArduinoBot @@ -47,7 +46,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Build Binary env: diff --git a/.gitignore b/.gitignore index 6bd2c2b..3a618ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +.bin/ # Mac system files .DS_Store diff --git a/README.md b/README.md index d0f89f1..ee1e6a0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Flexible firmware flashing for the Arduino UNO Q Microcontroller. `remoteocd` is a specialized utility designed to manage firmware deployment for the Arduino UNO Q board. This tool acts as a versatile wrapper for OpenOCD (Open On-Chip Debugger), allowing you to flash a binary onto the MCU using one of three transparently handled modes: + - Local, by flashing from the UNO Q's MPU (Linux) environment. - ADB over USB. - SSH over a remote pc. diff --git a/Taskfile.yml b/Taskfile.yml index 3b900f7..9d33c05 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,12 +1,58 @@ version: "3" +vars: + GOLANGCI_LINT_VERSION: v2.4.0 + GOIMPORTS_VERSION: v0.29.0 + DPRINT_VERSION: 0.48.0 + tasks: + init: + desc: Setup local env + deps: + - install:linter + - install:goimports + - install:dprint + + install:linter: + cmds: + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin/ {{ .GOLANGCI_LINT_VERSION }} + + install:goimports: + cmds: + - go install golang.org/x/tools/cmd/goimports@{{ .GOIMPORTS_VERSION }} + + install:dprint: + cmds: + - curl -fsSL https://dprint.dev/install.sh | sh -s {{ .DPRINT_VERSION }} + - mkdir -p .bin && cp $HOME/.dprint/bin/dprint .bin/dprint # workaround for local install + go:add-license-headers: desc: Add missing go license headers cmds: - go install github.com/google/addlicense@v1.2.0 - addlicense -c "ARDUINO SA (http://www.arduino.cc/)" -f ./license_header.tpl $(find . -name "*.go" -type f -print0 | xargs -0) + test: + desc: Run go tests + cmds: + - go test ./... -v -race {{ .CLI_ARGS }} + + lint: + desc: Run the linters + cmds: + - ${PWD}/.bin/golangci-lint run --fix -v --timeout 300s {{ .CLI_ARGS }} + + fmt: + desc: Run format + cmds: + - goimports -l -w . + - ${PWD}/.bin/dprint fmt + + fmt-check: + desc: Check format + cmds: + - ${PWD}/.bin/dprint check + # 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 diff --git a/dprint.json b/dprint.json new file mode 100644 index 0000000..55ef6de --- /dev/null +++ b/dprint.json @@ -0,0 +1,11 @@ +{ + "markdown": {}, + "yaml": {}, + "excludes": [ + ".licenses/**" + ], + "plugins": [ + "https://plugins.dprint.dev/markdown-0.17.8.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" + ] +}