Skip to content

Commit 1691cf7

Browse files
committed
Add some workflows and other tooling things
1 parent 340a2ff commit 1691cf7

14 files changed

+376
-16
lines changed

.codespellrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
2+
# See: https://github.com/codespell-project/codespell#using-a-config-file
3+
[codespell]
4+
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
5+
ignore-words-list = ,
6+
builtin = clear,informal,en-GB_to_en-US
7+
check-filenames =
8+
check-hidden =
9+
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock

.ecrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Exclude": [
3+
"LICENSE.txt",
4+
"poetry.lock"
5+
]
6+
}

.editorconfig

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/.editorconfig
2+
# See: https://editorconfig.org/
3+
# The formatting style defined in this file is the official standardized style to be used in all Arduino Tooling
4+
# projects and should not be modified.
5+
# Note: indent style for each file type is defined even when it matches the universal config in order to make it clear
6+
# that this type has an official style.
7+
8+
[*]
9+
charset = utf-8
10+
end_of_line = lf
11+
indent_size = 2
12+
indent_style = space
13+
insert_final_newline = true
14+
trim_trailing_whitespace = true
15+
16+
[*.{adoc,asc,asciidoc}]
17+
indent_size = 2
18+
indent_style = space
19+
20+
[*.{bash,sh}]
21+
indent_size = 2
22+
indent_style = space
23+
24+
[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}]
25+
indent_size = 2
26+
indent_style = space
27+
28+
[*.{go,mod}]
29+
indent_style = tab
30+
31+
[*.java]
32+
indent_size = 2
33+
indent_style = space
34+
35+
[*.{js,jsx,json,jsonc,json5,ts,tsx}]
36+
indent_size = 2
37+
indent_style = space
38+
39+
[*.{md,mdx,mkdn,mdown,markdown}]
40+
indent_size = unset
41+
indent_style = space
42+
43+
[*.proto]
44+
indent_size = 2
45+
indent_style = space
46+
47+
[*.py]
48+
indent_size = 4
49+
indent_style = space
50+
51+
[*.svg]
52+
indent_size = 2
53+
indent_style = space
54+
55+
[*.{yaml,yml}]
56+
indent_size = 2
57+
indent_style = space

.github/workflows/test.yaml renamed to .github/workflows/build-dummy-discovery.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: Build dummy discovery
22

33
on:
44
push:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-general-formatting-task.md
2+
name: Check General Formatting
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
check:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Set environment variables
20+
run: |
21+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
22+
echo "EC_INSTALL_PATH=${{ runner.temp }}/editorconfig-checker" >> "$GITHUB_ENV"
23+
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
27+
- name: Install Task
28+
uses: arduino/setup-task@v1
29+
with:
30+
repo-token: ${{ secrets.GITHUB_TOKEN }}
31+
version: 3.x
32+
33+
- name: Download latest editorconfig-checker release binary package
34+
id: download
35+
uses: MrOctopus/[email protected]
36+
with:
37+
repository: editorconfig-checker/editorconfig-checker
38+
excludes: prerelease, draft
39+
asset: linux-amd64.tar.gz
40+
target: ${{ env.EC_INSTALL_PATH }}
41+
42+
- name: Install editorconfig-checker
43+
run: |
44+
cd "${{ env.EC_INSTALL_PATH }}"
45+
tar --extract --file="${{ steps.download.outputs.name }}"
46+
# Give the binary a standard name
47+
mv "${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" "${{ env.EC_INSTALL_PATH }}/bin/ec"
48+
# Add installation to PATH:
49+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
50+
echo "${{ env.EC_INSTALL_PATH }}/bin" >> "$GITHUB_PATH"
51+
52+
- name: Check formatting
53+
run: task --silent general:check-formatting

.github/workflows/check-taskfiles.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
2+
name: Check Taskfiles
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/check-taskfiles.ya?ml"
9+
- "**/Taskfile.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/check-taskfiles.ya?ml"
13+
- "**/Taskfile.ya?ml"
14+
schedule:
15+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
16+
- cron: "0 8 * * TUE"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
jobs:
21+
validate:
22+
name: Validate ${{ matrix.file }}
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
fail-fast: false
27+
28+
matrix:
29+
file:
30+
# TODO: add paths to any additional Taskfiles here
31+
- ./**/Taskfile.yml
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v2
36+
37+
- name: Download JSON schema for Taskfiles
38+
id: download-schema
39+
uses: carlosperate/[email protected]
40+
with:
41+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
42+
file-url: https://json.schemastore.org/taskfile.json
43+
location: ${{ runner.temp }}/taskfile-schema
44+
45+
- name: Install JSON schema validator
46+
run: |
47+
sudo npm install \
48+
--global \
49+
ajv-cli \
50+
ajv-formats
51+
- name: Validate ${{ matrix.file }}
52+
run: |
53+
# See: https://github.com/ajv-validator/ajv-cli#readme
54+
ajv validate \
55+
--all-errors \
56+
--strict=false \
57+
-c ajv-formats \
58+
-s "${{ steps.download-schema.outputs.file-path }}" \
59+
-d "${{ matrix.file }}"
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
2+
name: Check Workflows
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/*.ya?ml"
9+
- "Taskfile.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/*.ya?ml"
13+
- "Taskfile.ya?ml"
14+
schedule:
15+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
16+
- cron: "0 8 * * TUE"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
jobs:
21+
validate:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
- name: Install Task
29+
uses: arduino/setup-task@v1
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
version: 3.x
33+
34+
- name: Validate workflows
35+
run: task --silent ci:validate
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
2+
name: Spell Check
3+
4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
spellcheck:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Install Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: "3.9"
26+
27+
- name: Install Poetry
28+
run: pip install poetry
29+
30+
- name: Install Task
31+
uses: arduino/setup-task@v1
32+
with:
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
version: 3.x
35+
36+
- name: Spell check
37+
run: task general:check-spelling

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# A golang library to handle the Arduino pluggable-discovery communication protocol.
1+
# Pluggable Discovery Protocol Handler
22

3-
## How to build
3+
This project is a library to ease implementation of pluggable discoveries for the [Arduino CLI](https://github.com/arduino/arduino-cli)
4+
following the [official specification](https://arduino.github.io/arduino-cli/latest/platform-specification/#pluggable-discovery).
45

56
## Security
67

78
If you think you found a vulnerability or other security-related bug in this project, please read our
8-
[security policy](https://github.com/arduino/serial-discovery/security/policy) and report the bug to our Security Team 🛡️
9+
[security policy](https://github.com/arduino/pluggable-discovery-protocol-handler/security/policy) and report the bug to our Security Team 🛡️
910
Thank you!
1011

1112
e-mail contact: [email protected]
@@ -18,4 +19,4 @@ The software is released under the GNU General Public License, which covers the
1819
of the serial-discovery code. The terms of this license can be found at:
1920
https://www.gnu.org/licenses/gpl-3.0.en.html
2021

21-
See [LICENSE.txt](https://github.com/arduino/serial-discovery/blob/master/LICENSE.txt) for details.
22+
See [LICENSE.txt](https://github.com/arduino/pluggable-discovery-protocol-handler/blob/master/LICENSE.txt) for details.

Taskfile.yml

+73-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,82 @@ version: "3"
33
tasks:
44
build-dummy-discovery:
55
desc: Build the dummy-discovery client example
6+
vars:
7+
EXECUTABLE: dummy-discovery{{if eq OS "windows"}}.exe{{end}}
68
cmds:
7-
- go build -o dist/dummy-discovery -v -ldflags '{{.LDFLAGS}}' ./dummy-discovery
9+
- go build -o dist/{{.EXECUTABLE}} -v -ldflags '{{.DUMMY_DISCOVERY_LDFLAGS}}' ./dummy-discovery
10+
11+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
12+
ci:validate:
13+
desc: Validate GitHub Actions workflows against their JSON schema
14+
vars:
15+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
16+
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
17+
WORKFLOW_SCHEMA_PATH:
18+
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
19+
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
20+
cmds:
21+
- |
22+
wget \
23+
--quiet \
24+
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
25+
{{.WORKFLOW_SCHEMA_URL}}
26+
- |
27+
npx \
28+
--package=ajv-cli \
29+
--package=ajv-formats \
30+
ajv validate \
31+
--all-errors \
32+
--strict=false \
33+
-c ajv-formats \
34+
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
35+
-d "{{.WORKFLOWS_DATA_PATH}}"
36+
37+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
38+
general:check-formatting:
39+
desc: Check basic formatting style of all files
40+
cmds:
41+
- |
42+
if ! which ec &>/dev/null; then
43+
echo "ec not found or not in PATH. Please install: https://github.com/editorconfig-checker/editorconfig-checker#installation"
44+
exit 1
45+
fi
46+
- ec
47+
48+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
49+
general:check-spelling:
50+
desc: Check for commonly misspelled words
51+
deps:
52+
- task: poetry:install-deps
53+
cmds:
54+
- poetry run codespell
55+
56+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
57+
general:correct-spelling:
58+
desc: Correct commonly misspelled words where possible
59+
deps:
60+
- task: poetry:install-deps
61+
cmds:
62+
- poetry run codespell --write-changes
63+
64+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
65+
poetry:install-deps:
66+
desc: Install dependencies managed by Poetry
67+
cmds:
68+
- poetry install --no-root
69+
70+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
71+
poetry:update-deps:
72+
desc: Update all dependencies managed by Poetry to their newest versions
73+
cmds:
74+
- poetry update
875

976
vars:
10-
PROJECT_NAME: "dummy-discovery"
1177
DIST_DIR: "dist"
12-
VERSION:
78+
DUMMY_DISCOVERY_VERSION:
1379
sh: echo "$(git describe --tags --dirty --broken)"
14-
TIMESTAMP:
80+
DUMMY_DISCOVERY_TIMESTAMP:
1581
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
16-
LDFLAGS: >
17-
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Tag={{.VERSION}}
18-
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Timestamp={{.TIMESTAMP}}
82+
DUMMY_DISCOVERY_LDFLAGS: >
83+
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Tag={{.DUMMY_DISCOVERY_VERSION}}
84+
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Timestamp={{.DUMMY_DISCOVERY_TIMESTAMP}}

0 commit comments

Comments
 (0)