From b861675f905fac7069714dc8df81eb95a73d2f4e Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 15 Aug 2021 02:04:39 -0700 Subject: [PATCH] Sync Prettier formatting assets with templates We have assembled a collection of reusable project assets: https://github.com/arduino/tooling-project-assets These assets will be used in the repositories of all Arduino tooling projects. Some improvements and standardizations have been made in the upstream "template" assets for formatting to and checking compliance with the Prettier formatting style. Those are introduced to this repository here. Notable: - Expand Prettier coverage to all supported files Some task names have changed: - `docs:format` -> `general:format-prettier` - `config:format` -> `general:format-prettier` - `docs:check` -> removed (use `general:format-prettier` instead) - `config:check` -> removed (use `general:format-prettier` instead) --- .../check-prettier-formatting-task.yml | 219 ++++++++++++++++++ .github/workflows/verify-formatting.yml | 34 --- .prettierignore | 5 + Taskfile.yml | 12 - generator/boards.json | 49 ++-- 5 files changed, 242 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/check-prettier-formatting-task.yml delete mode 100644 .github/workflows/verify-formatting.yml diff --git a/.github/workflows/check-prettier-formatting-task.yml b/.github/workflows/check-prettier-formatting-task.yml new file mode 100644 index 00000000..caccbcf9 --- /dev/null +++ b/.github/workflows/check-prettier-formatting-task.yml @@ -0,0 +1,219 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md +name: Check Prettier Formatting + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/check-prettier-formatting-task.ya?ml" + - "Taskfile.ya?ml" + - "**/.prettierignore" + - "**/.prettierrc*" + # CSS + - "**.css" + - "**.wxss" + # PostCSS + - "**.pcss" + - "**.postcss" + # Less + - "**.less" + # SCSS + - "**.scss" + # GraphQL + - "**.graphqls?" + - "**.gql" + # handlebars + - "**.handlebars" + - "**.hbs" + # HTML + - "**.mjml" + - "**.html?" + - "**.html.hl" + - "**.st" + - "**.xht" + - "**.xhtml" + # Vue + - "**.vue" + # JavaScript + - "**.flow" + - "**._?jsb?" + - "**.bones" + - "**.cjs" + - "**.es6?" + - "**.frag" + - "**.gs" + - "**.jake" + - "**.jscad" + - "**.jsfl" + - "**.js[ms]" + - "**.[mn]js" + - "**.pac" + - "**.wxs" + - "**.[xs]s?js" + - "**.xsjslib" + # JSX + - "**.jsx" + # TypeScript + - "**.ts" + # TSX + - "**.tsx" + # JSON + - "**/.eslintrc" + - "**.json" + - "**.avsc" + - "**.geojson" + - "**.gltf" + - "**.har" + - "**.ice" + - "**.JSON-tmLanguage" + - "**.mcmeta" + - "**.tfstate" + - "**.topojson" + - "**.webapp" + - "**.webmanifest" + - "**.yyp?" + # JSONC + - "**/.babelrc" + - "**/.jscsrc" + - "**/.js[hl]intrc" + - "**.jsonc" + - "**.sublime-*" + # JSON5 + - "**.json5" + # Markdown + - "**.mdx?" + - "**.markdown" + - "**.mk?down" + - "**.mdwn" + - "**.mkdn?" + - "**.ronn" + - "**.workbook" + # YAML + - "**/.clang-format" + - "**/.clang-tidy" + - "**/.gemrc" + - "**/glide.lock" + - "**.ya?ml*" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + pull_request: + paths: + - ".github/workflows/check-prettier-formatting-task.ya?ml" + - "Taskfile.ya?ml" + - "**/.prettierignore" + - "**/.prettierrc*" + # CSS + - "**.css" + - "**.wxss" + # PostCSS + - "**.pcss" + - "**.postcss" + # Less + - "**.less" + # SCSS + - "**.scss" + # GraphQL + - "**.graphqls?" + - "**.gql" + # handlebars + - "**.handlebars" + - "**.hbs" + # HTML + - "**.mjml" + - "**.html?" + - "**.html.hl" + - "**.st" + - "**.xht" + - "**.xhtml" + # Vue + - "**.vue" + # JavaScript + - "**.flow" + - "**._?jsb?" + - "**.bones" + - "**.cjs" + - "**.es6?" + - "**.frag" + - "**.gs" + - "**.jake" + - "**.jscad" + - "**.jsfl" + - "**.js[ms]" + - "**.[mn]js" + - "**.pac" + - "**.wxs" + - "**.[xs]s?js" + - "**.xsjslib" + # JSX + - "**.jsx" + # TypeScript + - "**.ts" + # TSX + - "**.tsx" + # JSON + - "**/.eslintrc" + - "**.json" + - "**.avsc" + - "**.geojson" + - "**.gltf" + - "**.har" + - "**.ice" + - "**.JSON-tmLanguage" + - "**.mcmeta" + - "**.tfstate" + - "**.topojson" + - "**.webapp" + - "**.webmanifest" + - "**.yyp?" + # JSONC + - "**/.babelrc" + - "**/.jscsrc" + - "**/.js[hl]intrc" + - "**.jsonc" + - "**.sublime-*" + # JSON5 + - "**.json5" + # Markdown + - "**.mdx?" + - "**.markdown" + - "**.mk?down" + - "**.mdwn" + - "**.mkdn?" + - "**.ronn" + - "**.workbook" + # YAML + - "**/.clang-format" + - "**/.clang-tidy" + - "**/.gemrc" + - "**/glide.lock" + - "**.ya?ml*" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + workflow_dispatch: + repository_dispatch: + +jobs: + check: + 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: Format with Prettier + run: task general:format-prettier + + - name: Check formatting + run: git diff --color --exit-code diff --git a/.github/workflows/verify-formatting.yml b/.github/workflows/verify-formatting.yml deleted file mode 100644 index 9acaab79..00000000 --- a/.github/workflows/verify-formatting.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: "Verify files formatting" - -on: - push: - paths: - - "**/*.md" - - "**/*.yml" - - "**/*.yaml" - - ".prettierrc" - - ".prettierignore" - pull_request: - paths: - - "**/*.md" - - "**/*.yml" - - "**/*.yaml" - - ".prettierrc" - - ".prettierignore" - -jobs: - verify-formatting: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Taskfile - uses: arduino/setup-task@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: 3.x - - - name: Verify formatting of all files - run: task docs:check config:check diff --git a/.prettierignore b/.prettierignore index 6260782e..3f5168a1 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,3 +3,8 @@ .vscode/ .vs/ .ionide/ + +indexes/download/testdata/module_firmware_index.json +indexes/download/testdata/package_index.json +indexes/firmwareindex/testdata/module_firmware_index.json +indexes/testdata/package_index.json diff --git a/Taskfile.yml b/Taskfile.yml index ddc1adcc..f37f2014 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -171,16 +171,6 @@ tasks: - task: markdown:lint - task: python:check - config:check: - desc: Check linting of configuration and supporting files - cmds: - - npx {{ .PRETTIER }} --check "**/*.{yml,yaml}" - - config:format: - desc: Automatically formats configuration and supporting files - cmds: - - npx {{ .PRETTIER }} --write "**/*.{yml,yaml}" - # 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 @@ -266,5 +256,3 @@ vars: -X {{.CONFIGURATION_PACKAGE}}.commit={{.TEST_COMMIT}} -X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}} ' - # check-lint vars - PRETTIER: prettier@2.0.5 diff --git a/generator/boards.json b/generator/boards.json index 86ccaaf8..6d01ad90 100644 --- a/generator/boards.json +++ b/generator/boards.json @@ -1,16 +1,11 @@ { - "arduino:samd:mkr1000":{ - "moduleName":"WINC1500", - "versions":[ - "19.4.4", - "19.5.2", - "19.5.4", - "19.6.1" - ] + "arduino:samd:mkr1000": { + "moduleName": "WINC1500", + "versions": ["19.4.4", "19.5.2", "19.5.4", "19.6.1"] }, - "arduino:samd:mkrwifi1010":{ - "moduleName":"NINA", - "versions":[ + "arduino:samd:mkrwifi1010": { + "moduleName": "NINA", + "versions": [ "1.0.0", "1.1.0", "1.2.1", @@ -29,9 +24,9 @@ "1.4.8" ] }, - "arduino:samd:nano_33_iot":{ - "moduleName":"NINA", - "versions":[ + "arduino:samd:nano_33_iot": { + "moduleName": "NINA", + "versions": [ "1.0.0", "1.1.0", "1.2.1", @@ -50,16 +45,13 @@ "1.4.8" ] }, - "arduino:samd:mkrvidor4000":{ - "moduleName":"NINA", - "versions":[ - "1.0.0", - "1.1.0" - ] + "arduino:samd:mkrvidor4000": { + "moduleName": "NINA", + "versions": ["1.0.0", "1.1.0"] }, - "arduino:megaavr:uno2018":{ - "moduleName":"NINA", - "versions":[ + "arduino:megaavr:uno2018": { + "moduleName": "NINA", + "versions": [ "1.2.1", "1.2.2", "1.2.3", @@ -76,13 +68,8 @@ "1.4.8" ] }, - "arduino:mbed_nano:nanorp2040connect":{ - "moduleName":"NINA", - "versions":[ - "1.4.5", - "1.4.6", - "1.4.7", - "1.4.8" - ] + "arduino:mbed_nano:nanorp2040connect": { + "moduleName": "NINA", + "versions": ["1.4.5", "1.4.6", "1.4.7", "1.4.8"] } }