Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions .github/workflows/block-merge-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Block Merge if "do-not-merge" Label Exists

on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize # important for when new commits are pushed

jobs:
check-do-not-merge-label:
runs-on: ubuntu-latest
steps:
- name: Check for "do-not-merge" label
if: contains(github.event.pull_request.labels.*.name, 'do-not-merge')
run: |
echo "This Pull Request has the 'do-not-merge' label. Merging is blocked."
echo "Please remove the 'do-not-merge' label to enable merging."
exit 1 # This will cause the workflow to fail
155 changes: 155 additions & 0 deletions .github/workflows/check-go-dependencies-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md
name: Check Go Dependencies

# See: https://docs.github.com/actions/reference/workflows-and-actions/events-that-trigger-workflows
on:
create:
push:
paths:
- ".github/workflows/check-go-dependencies-task.ya?ml"
- ".licenses/**"
- ".licensed.json"
- ".licensed.ya?ml"
- "Taskfile.ya?ml"
- "**/.gitmodules"
- "**/go.mod"
- "**/go.sum"
pull_request:
paths:
- ".github/workflows/check-go-dependencies-task.ya?ml"
- ".licenses/**"
- ".licensed.json"
- ".licensed.ya?ml"
- "Taskfile.ya?ml"
- "**/.gitmodules"
- "**/go.mod"
- "**/go.sum"
schedule:
# Run periodically to catch breakage caused by external changes.
- cron: "0 8 * * WED"
workflow_dispatch:
repository_dispatch:

jobs:
run-determination:
runs-on: ubuntu-latest
permissions: {}
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
"${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi
echo "result=$RESULT" >>$GITHUB_OUTPUT
check-cache:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive

# This is required to allow licensee/setup-licensed to install Licensed via Ruby gem.
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby # Install latest version

- name: Install licensed
uses: licensee/setup-licensed@v1.3.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: 5.x

- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Update dependencies license metadata cache
run: |
go tool \
github.com/go-task/task/v3/cmd/task \
--silent \
general:cache-dep-licenses
- name: Check for outdated cache
id: diff
run: |
git add .
if
! git diff \
--cached \
--color \
--exit-code
then
echo
echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache"
exit 1
fi
# Some might find it convenient to have CI generate the cache rather than setting up for it locally
- name: Upload cache to workflow artifact
if: failure() && steps.diff.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
include-hidden-files: true
name: dep-licenses-cache
path: .licenses/

check-deps:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive

# This is required to allow licensee/setup-licensed to install Licensed via Ruby gem.
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby # Install latest version

- name: Install licensed
uses: licensee/setup-licensed@v1.3.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: 5.x

- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Check for dependencies with unapproved licenses
run: |
go tool \
github.com/go-task/task/v3/cmd/task \
--silent \
general:check-dep-licenses
44 changes: 44 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Checks

on:
push:
branches: [main]
pull_request:
branches: [main]

# 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:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions:
contents: read
# Used by the buf to create a comment with a brief summary of failing tets
pull-requests: write

jobs:
run-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dprint/check@v2.2
with:
dprint-version: 0.48.0

- uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0
args: --timeout 300s

- name: Check go mod
run: |
go mod tidy
git diff --color --exit-code

- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Go Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
GO_VERSION: "1.25.1"

jobs:
go-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Run tests
run: task test
env:
GH_TOKEN: ${{ secrets.ARDUINOBOT_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.exe~

build/

.bin/
57 changes: 57 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: "2"
linters:
enable:
- bodyclose
- dogsled
- goconst
- gocritic
- goprintffuncname
- gosec
- importas
- misspell
- nakedret
- prealloc
- revive
- staticcheck
- unconvert
- unparam
- gochecknoinits
settings:
misspell:
locale: US
revive:
rules:
- name: indent-error-flow
disabled: true
goconst:
ignore-string-values:
- ".exe"
- "windows"
- "linux"
- "darwin"

exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/arduino/arduino-flasher-cli
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
Loading
Loading