Skip to content

Add some workflows and other tooling things #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
# See: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
ignore-words-list = ,
builtin = clear,informal,en-GB_to_en-US
check-filenames =
check-hidden =
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
6 changes: 6 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Exclude": [
"LICENSE.txt",
"poetry.lock"
]
}
57 changes: 57 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/general/.editorconfig
# See: https://editorconfig.org/
# The formatting style defined in this file is the official standardized style to be used in all Arduino Tooling
# projects and should not be modified.
# Note: indent style for each file type is defined even when it matches the universal config in order to make it clear
# that this type has an official style.

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{adoc,asc,asciidoc}]
indent_size = 2
indent_style = space

[*.{bash,sh}]
indent_size = 2
indent_style = space

[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}]
indent_size = 2
indent_style = space

[*.{go,mod}]
indent_style = tab

[*.java]
indent_size = 2
indent_style = space

[*.{js,jsx,json,jsonc,json5,ts,tsx}]
indent_size = 2
indent_style = space

[*.{md,mdx,mkdn,mdown,markdown}]
indent_size = unset
indent_style = space

[*.proto]
indent_size = 2
indent_style = space

[*.py]
indent_size = 4
indent_style = space

[*.svg]
indent_size = 2
indent_style = space

[*.{yaml,yml}]
indent_size = 2
indent_style = space
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: Build dummy discovery

on:
push:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/check-general-formatting-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-general-formatting-task.md
name: Check General Formatting

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
pull_request:
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "EC_INSTALL_PATH=${{ runner.temp }}/editorconfig-checker" >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v2

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

- name: Download latest editorconfig-checker release binary package
id: download
uses: MrOctopus/[email protected]
with:
repository: editorconfig-checker/editorconfig-checker
excludes: prerelease, draft
asset: linux-amd64.tar.gz
target: ${{ env.EC_INSTALL_PATH }}

- name: Install editorconfig-checker
run: |
cd "${{ env.EC_INSTALL_PATH }}"
tar --extract --file="${{ steps.download.outputs.name }}"
# Give the binary a standard name
mv "${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" "${{ env.EC_INSTALL_PATH }}/bin/ec"
# Add installation to PATH:
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
echo "${{ env.EC_INSTALL_PATH }}/bin" >> "$GITHUB_PATH"

- name: Check formatting
run: task --silent general:check-formatting
59 changes: 59 additions & 0 deletions .github/workflows/check-taskfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
name: Check Taskfiles

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
- "**/Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
name: Validate ${{ matrix.file }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
file:
# TODO: add paths to any additional Taskfiles here
- ./**/Taskfile.yml

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download JSON schema for Taskfiles
id: download-schema
uses: carlosperate/[email protected]
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://json.schemastore.org/taskfile.json
location: ${{ runner.temp }}/taskfile-schema

- name: Install JSON schema validator
run: |
sudo npm install \
--global \
ajv-cli \
ajv-formats
- name: Validate ${{ matrix.file }}
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--all-errors \
--strict=false \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ matrix.file }}"
35 changes: 35 additions & 0 deletions .github/workflows/check-workflows-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
name: Check Workflows

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/*.ya?ml"
- "Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/*.ya?ml"
- "Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Validate workflows
run: task --silent ci:validate
37 changes: 37 additions & 0 deletions .github/workflows/spell-check-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
name: Spell Check

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
pull_request:
schedule:
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install Poetry
run: pip install poetry

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

- name: Spell check
run: task general:check-spelling
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# A golang library to handle the Arduino pluggable-discovery communication protocol.
# Pluggable Discovery Protocol Handler

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

## Security

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

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

See [LICENSE.txt](https://github.com/arduino/serial-discovery/blob/master/LICENSE.txt) for details.
See [LICENSE.txt](https://github.com/arduino/pluggable-discovery-protocol-handler/blob/master/LICENSE.txt) for details.
80 changes: 73 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,82 @@ version: "3"
tasks:
build-dummy-discovery:
desc: Build the dummy-discovery client example
vars:
EXECUTABLE: dummy-discovery{{if eq OS "windows"}}.exe{{end}}
cmds:
- go build -o dist/dummy-discovery -v -ldflags '{{.LDFLAGS}}' ./dummy-discovery
- go build -o dist/{{.EXECUTABLE}} -v -ldflags '{{.DUMMY_DISCOVERY_LDFLAGS}}' ./dummy-discovery

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
ci:validate:
desc: Validate GitHub Actions workflows against their JSON schema
vars:
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
WORKFLOW_SCHEMA_PATH:
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
cmds:
- |
wget \
--quiet \
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
{{.WORKFLOW_SCHEMA_URL}}
- |
npx \
--package=ajv-cli \
--package=ajv-formats \
ajv validate \
--all-errors \
--strict=false \
-c ajv-formats \
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
-d "{{.WORKFLOWS_DATA_PATH}}"

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
general:check-formatting:
desc: Check basic formatting style of all files
cmds:
- |
if ! which ec &>/dev/null; then
echo "ec not found or not in PATH. Please install: https://github.com/editorconfig-checker/editorconfig-checker#installation"
exit 1
fi
- ec

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
general:check-spelling:
desc: Check for commonly misspelled words
deps:
- task: poetry:install-deps
cmds:
- poetry run codespell

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
general:correct-spelling:
desc: Correct commonly misspelled words where possible
deps:
- task: poetry:install-deps
cmds:
- poetry run codespell --write-changes

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install-deps:
desc: Install dependencies managed by Poetry
cmds:
- poetry install --no-root

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:update-deps:
desc: Update all dependencies managed by Poetry to their newest versions
cmds:
- poetry update

vars:
PROJECT_NAME: "dummy-discovery"
DIST_DIR: "dist"
VERSION:
DUMMY_DISCOVERY_VERSION:
sh: echo "$(git describe --tags --dirty --broken)"
TIMESTAMP:
DUMMY_DISCOVERY_TIMESTAMP:
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
LDFLAGS: >
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Tag={{.VERSION}}
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Timestamp={{.TIMESTAMP}}
DUMMY_DISCOVERY_LDFLAGS: >
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Tag={{.DUMMY_DISCOVERY_VERSION}}
-X github.com/arduino/pluggable-discovery-protocol-handler/dummy-discovery/args.Timestamp={{.DUMMY_DISCOVERY_TIMESTAMP}}
Loading