-
Notifications
You must be signed in to change notification settings - Fork 6
Host standardized ClangFormat configuration file #250
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a5031c8
Host standardized ClangFormat configuration file
per1234 6a7374b
Validate ClangFormat configuration file against its JSON schema
per1234 b4c7537
Add assets for JavaScript code linting
per1234 756bf57
Validate the ESLint configuration file asset against its JSON schema
per1234 da354df
Add script to convert ClangFormat configuration file for use in Ardui…
per1234 aa1f906
Add project infrastructure to lint JavaScript code
per1234 39d078c
Add Arduino sketch samples for ClangFormat configuration test data
per1234 e24af55
Format ClangFormat configuration goldens according to traditional Ard…
per1234 167cde2
Format ClangFormat configuration goldens using ClangFormat 11.0.1
per1234 f5f5076
Add targeted ClangFormat configuration test data
per1234 6cb140c
Compare results of ClangFormat configuration file against those expected
per1234 6f774b2
Move notes out of ClangFormat configuration to dedicated file
per1234 4613cfd
Standardize ClangFormat configuration file format
per1234 c5f256f
Add additional notes re: ClangFormat configuration
per1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-javascript/.eslintrc.yml | ||
# See: https://eslint.org/docs/user-guide/configuring/ | ||
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should | ||
# not be modified. | ||
|
||
extends: | ||
- airbnb-base | ||
- prettier | ||
rules: | ||
max-len: | ||
- error | ||
- code: 180 | ||
no-console: "off" | ||
no-underscore-dangle: "off" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
name: Check ClangFormat Configuration | ||
|
||
env: | ||
# See: https://github.com/actions/setup-node/#readme | ||
NODE_VERSION: 16.x | ||
|
||
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows | ||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/check-clang-format.yml" | ||
- "other/clang-format-configuration/scripts/convert-clang-format-configuration.js" | ||
- "other/clang-format-configuration/testdata/**" | ||
- "other/clang-format-configuration/.clang-format" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "Taskfile.ya?ml" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/check-clang-format.yml" | ||
- "other/clang-format-configuration/scripts/convert-clang-format-configuration.js" | ||
- "other/clang-format-configuration/testdata/**" | ||
- "other/clang-format-configuration/.clang-format" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "Taskfile.ya?ml" | ||
schedule: | ||
# Run periodically to catch breakage caused by external changes. | ||
- cron: "0 17 * * WED" | ||
workflow_dispatch: | ||
inputs: | ||
clang-format-version: | ||
description: ClangFormat version (leave empty for standard version) | ||
type: string | ||
default: "" | ||
required: false | ||
repository_dispatch: | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Validate ClangFormat configuration files | ||
run: task --silent clang-format:validate | ||
|
||
check-config: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Set environment variables | ||
run: | | ||
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | ||
if [[ "${{ github.event.inputs.clang-format-version }}" == "" ]]; then | ||
echo "CLANG_FORMAT_VERSION=$(task clang-format:get-version)" >> "$GITHUB_ENV" | ||
else | ||
echo "CLANG_FORMAT_VERSION=${{ github.event.inputs.clang-format-version }}" >> "$GITHUB_ENV" | ||
fi | ||
echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV" | ||
echo "WORKING_FOLDER=${{ runner.temp }}" >> "$GITHUB_ENV" | ||
|
||
- name: Download ClangFormat | ||
id: download | ||
uses: MrOctopus/[email protected] | ||
with: | ||
repository: arduino/clang-static-binaries | ||
tag: ${{ env.CLANG_FORMAT_VERSION }} | ||
asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2 | ||
target: ${{ env.CLANG_FORMAT_INSTALL_PATH }} | ||
|
||
- name: Install ClangFormat | ||
run: | | ||
cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}" | ||
tar --extract --file="${{ steps.download.outputs.name }}" | ||
# Add installation to PATH: | ||
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path | ||
echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH" | ||
|
||
- name: Check ClangFormat configuration file | ||
id: check | ||
run: | | ||
task \ | ||
--silent \ | ||
clang-format:check-config \ | ||
CLANG_FORMAT_VERSION="${{ env.CLANG_FORMAT_VERSION }}" | ||
|
||
- name: Save effective configuration file to a workflow artifact | ||
if: > | ||
always() && | ||
steps.check.outcome == 'failure' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ${{ env.WORKING_FOLDER }}/expected/.clang-format | ||
if-no-files-found: error | ||
name: config-output | ||
|
||
check-output: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Set environment variables | ||
run: | | ||
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | ||
if [[ "${{ github.event.inputs.clang-format-version }}" == "" ]]; then | ||
echo "CLANG_FORMAT_VERSION=$(task clang-format:get-version)" >> "$GITHUB_ENV" | ||
else | ||
echo "CLANG_FORMAT_VERSION=${{ github.event.inputs.clang-format-version }}" >> "$GITHUB_ENV" | ||
fi | ||
echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV" | ||
echo "WORKING_FOLDER=${{ runner.temp }}" >> "$GITHUB_ENV" | ||
|
||
- name: Download ClangFormat | ||
id: download | ||
uses: MrOctopus/[email protected] | ||
with: | ||
repository: arduino/clang-static-binaries | ||
tag: ${{ env.CLANG_FORMAT_VERSION }} | ||
asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2 | ||
target: ${{ env.CLANG_FORMAT_INSTALL_PATH }} | ||
|
||
- name: Install ClangFormat | ||
run: | | ||
cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}" | ||
tar --extract --file="${{ steps.download.outputs.name }}" | ||
# Add installation to PATH: | ||
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path | ||
echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH" | ||
|
||
- name: Check ClangFormat output | ||
id: check | ||
run: | | ||
task \ | ||
clang-format:check-output \ | ||
CLANG_FORMAT_VERSION="${{ env.CLANG_FORMAT_VERSION }}" \ | ||
WORKING_FOLDER="${{ env.WORKING_FOLDER }}" | ||
|
||
- name: Save formatted test data to a workflow artifact | ||
if: > | ||
always() && | ||
steps.check.outcome == 'failure' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ${{ env.WORKING_FOLDER }}/output | ||
if-no-files-found: error | ||
name: testdata-output | ||
|
||
check-testdata: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Check ClangFormat test data | ||
run: task --silent clang-format:check-testdata | ||
|
||
convert: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set environment variables | ||
run: | | ||
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | ||
echo "CONVERSION_OUTPUT_PATH=${{ runner.temp }}/clang-format-js-object.txt" >> "$GITHUB_ENV" | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Convert the ClangFormat configuration | ||
run: | | ||
task \ | ||
--silent \ | ||
clang-format:convert \ | ||
OUTPUT_PATH="${{ env.CONVERSION_OUTPUT_PATH }}" | ||
|
||
- name: Save conversion to a workflow artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ${{ env.CONVERSION_OUTPUT_PATH }} | ||
if-no-files-found: error | ||
name: javascript-configuration-object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Check ESLint Configuration | ||
|
||
env: | ||
# See: https://github.com/actions/setup-node/#readme | ||
NODE_VERSION: 16.x | ||
|
||
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows | ||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/check-eslint.yml" | ||
- "workflow-templates/assets/check-javascript/.eslintrc.yml" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "Taskfile.ya?ml" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/check-eslint.yml" | ||
- "workflow-templates/assets/check-javascript/.eslintrc.yml" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "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@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Validate workflows | ||
run: task --silent eslint:validate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-javascript-task.md | ||
name: Check JavaScript | ||
|
||
env: | ||
# See: https://github.com/actions/setup-node/#readme | ||
NODE_VERSION: 16.x | ||
|
||
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows | ||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/check-javascript-task.ya?ml" | ||
- ".eslintignore" | ||
- "**/.eslintrc*" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "Taskfile.ya?ml" | ||
- "**.jsx?" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/check-javascript-task.ya?ml" | ||
- ".eslintignore" | ||
- "**/.eslintrc*" | ||
- "package.json" | ||
- "package-lock.json" | ||
- "Taskfile.ya?ml" | ||
- "**.jsx?" | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Install Task | ||
uses: arduino/setup-task@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
version: 3.x | ||
|
||
- name: Lint | ||
run: task js:lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.licenses/ | ||
__pycache__/ | ||
node_modules/ | ||
/other/clang-format-configuration/testdata/golden/samples/ | ||
/other/clang-format-configuration/testdata/input/samples/ | ||
/other/clang-format-configuration/.clang-format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,5 +72,6 @@ yaml-files: | |
|
||
ignore: | | ||
/.git/ | ||
/other/clang-format-configuration/.clang-format | ||
__pycache__/ | ||
node_modules/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.