Skip to content

Add CI workflow to check general file formatting #215

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
Jul 29, 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
8 changes: 8 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Exclude": [
"LICENSE.txt",
"poetry.lock",
"^internal/rule/schema/schemadata/bindata.go$",
"^internal/rule/schema/testdata/bindata.go$"
]
}
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Check Markdown status](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml)
[![Docs Status](https://github.com/arduino/arduino-lint/workflows/Publish%20documentation/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Publish+documentation)
[![Codecov](https://codecov.io/gh/arduino/arduino-lint/branch/main/graph/badge.svg?token=nprqPQMbdh)](https://codecov.io/gh/arduino/arduino-lint)
[![Check General Formatting status](https://github.com/arduino/arduino-lint/actions/workflows/check-general-formatting-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-general-formatting-task.yml)
[![Check Certificates status](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml)

**Arduino Lint** is a command line tool that checks for common problems in [Arduino](https://www.arduino.cc/) projects:
Expand Down
13 changes: 13 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ tasks:
- task: python:check
- task: docs:check
- task: config:check
- task: general:check-formatting
- task: check-spelling

lint:
Expand All @@ -60,6 +61,7 @@ tasks:
cmds:
- task: docs:check-formatting
- task: config:check-formatting
- task: general:check-formatting

format:
desc: Format all files
Expand Down Expand Up @@ -312,6 +314,17 @@ tasks:
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"
- npx {{ .PRETTIER }} --write "**/*.json"

# 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

check-spelling:
desc: Check for commonly misspelled words
cmds:
Expand Down