From 288a4cd077713fca857524b2ff564d74c386e72b Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 7 May 2021 04:33:39 -0700 Subject: [PATCH 1/4] Use Prettier to format all supported file types Prettier is a general-purpose formatter tool. There is no reason to restrict it to only .ts files. --- .prettierignore | 3 +++ package.json | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..ccc2c5d2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +/dist/ +/lib/ +/node_modules/ diff --git a/package.json b/package.json index e1371b8d..80cd9f58 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "description": "Setup Task action", "main": "lib/main.js", "scripts": { - "format": "prettier --write **/*.ts", - "format-check": "prettier --check **/*.ts" + "format": "prettier --write .", + "format-check": "prettier --check ." }, "repository": { "type": "git", From c1b58238d5fec9fa476afda52bfeac23b74f77bc Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 7 May 2021 04:34:26 -0700 Subject: [PATCH 2/4] Bring all files into Prettier formatting compliance --- .github/workflows/check-license.yml | 2 +- CONTRIBUTING.md | 1 + README.md | 4 ++-- action.yml | 12 ++++++------ jest.config.js | 14 +++++++------- tsconfig.json | 14 +++++++------- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check-license.yml b/.github/workflows/check-license.yml index f2e2ddc8..ace186c4 100644 --- a/.github/workflows/check-license.yml +++ b/.github/workflows/check-license.yml @@ -3,7 +3,7 @@ name: Check License env: EXPECTED_LICENSE_FILENAME: LICENSE # SPDX identifier: https://spdx.org/licenses/ - EXPECTED_LICENSE_TYPE: GPL-3.0 + EXPECTED_LICENSE_TYPE: GPL-3.0 # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows on: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 86b7e50b..f1694623 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,6 +60,7 @@ Everything is now ready to make your contribution to the project, so commit it t Thanks! ## Enable verbose logging for a pipeline + Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. See [step-debug-logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs) for reference. diff --git a/README.md b/README.md index 58a94702..bee1aaa3 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ If you want to pin a major or minor version you can use the `.x` wildcard: - name: Install Task uses: arduino/setup-task@main with: - version: '2.x' + version: 2.x ``` To pin the exact version: @@ -51,7 +51,7 @@ To pin the exact version: - name: Install Task uses: arduino/setup-task@main with: - version: '2.6.1' + version: 2.6.1 ``` ## Security diff --git a/action.yml b/action.yml index a06b2f74..7bee8e48 100644 --- a/action.yml +++ b/action.yml @@ -1,15 +1,15 @@ -name: 'arduino/setup-task' -description: 'Download Task and add it to the PATH' -author: 'Arduino' +name: "arduino/setup-task" +description: "Download Task and add it to the PATH" +author: "Arduino" inputs: version: - description: 'Version to use. Example: 3.4.2' + description: "Version to use. Example: 3.4.2" required: false - default: '3.x' + default: "3.x" repo-token: description: "Token with permissions to do repo things" required: false runs: - using: 'node12' + using: "node12" main: "dist/index.js" diff --git a/jest.config.js b/jest.config.js index 563d4ccb..82cc9945 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,11 +1,11 @@ module.exports = { clearMocks: true, - moduleFileExtensions: ['js', 'ts'], - testEnvironment: 'node', - testMatch: ['**/*.test.ts'], - testRunner: 'jest-circus/runner', + moduleFileExtensions: ["js", "ts"], + testEnvironment: "node", + testMatch: ["**/*.test.ts"], + testRunner: "jest-circus/runner", transform: { - '^.+\\.ts$': 'ts-jest' + "^.+\\.ts$": "ts-jest", }, - verbose: true -} \ No newline at end of file + verbose: true, +}; diff --git a/tsconfig.json b/tsconfig.json index 74870b06..9a2e5859 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,8 @@ "compilerOptions": { /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ @@ -11,8 +11,8 @@ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./lib", /* Redirect output structure to the directory. */ - "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "outDir": "./lib" /* Redirect output structure to the directory. */, + "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ @@ -22,8 +22,8 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ @@ -45,7 +45,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ From d65ce984a52e87aa7e113c9a7141403088d81e9e Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 7 May 2021 04:37:26 -0700 Subject: [PATCH 3/4] Use Task to run formatting operation The project uses Task as the runner for all common development processes. --- .github/workflows/setup-taskflile.yml | 7 +++++-- Taskfile.yml | 10 ++++++++++ package.json | 4 ---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/setup-taskflile.yml b/.github/workflows/setup-taskflile.yml index f280f415..7e61cc8b 100644 --- a/.github/workflows/setup-taskflile.yml +++ b/.github/workflows/setup-taskflile.yml @@ -34,8 +34,11 @@ jobs: - name: Install dependencies run: task ts:install-deps - - name: npm lint - run: npm run format-check + - name: Format with Prettier + run: task general:format + + - name: Check formatting + run: git diff --color --exit-code - name: Run tests run: task ts:test diff --git a/Taskfile.yml b/Taskfile.yml index 0f085b3e..42f9ac8e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,6 +6,11 @@ tasks: deps: - task: ts:build + format: + desc: Format all files + deps: + - task: general:format + check: desc: Check for problems with the project deps: @@ -78,6 +83,11 @@ tasks: done exit $STATUS' + general:format: + desc: Format all supported files with Prettier + cmds: + - npx prettier --write . + general:check-spelling: desc: Check for commonly misspelled words cmds: diff --git a/package.json b/package.json index 80cd9f58..64b5b238 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,6 @@ "private": true, "description": "Setup Task action", "main": "lib/main.js", - "scripts": { - "format": "prettier --write .", - "format-check": "prettier --check ." - }, "repository": { "type": "git", "url": "git+https://github.com/arduino/setup-task.git" From 71e1e800bea127c661d96bd1091a90b7864ee8f9 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 7 May 2021 04:40:56 -0700 Subject: [PATCH 4/4] Add CI workflow to check for Prettier formatting compliance On every push and pull request that affects relevant files, check whether the formatting of supported files is compliant with the Prettier style. --- .../check-prettier-formatting-task.yml | 226 ++++++++++++++++++ .github/workflows/setup-taskflile.yml | 13 - README.md | 1 + 3 files changed, 227 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/check-prettier-formatting-task.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..0a8a8074 --- /dev/null +++ b/.github/workflows/check-prettier-formatting-task.yml @@ -0,0 +1,226 @@ +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.yml" + - "Taskfile.yml" + - "**/.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" + - "**.yml" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + - "**.yaml" + - "**.yaml-tmlanguage" + - "**.yaml.sed" + - "**.yml.mysql" + pull_request: + paths: + - ".github/workflows/check-prettier-formatting-task.yml" + - "Taskfile.yml" + - "**/.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" + - "**.yml" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + - "**.yaml" + - "**.yaml-tmlanguage" + - "**.yaml.sed" + - "**.yml.mysql" + workflow_dispatch: + repository_dispatch: + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Taskfile + uses: arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Format with Prettier + run: task general:format + + - name: Check formatting + run: git diff --color --exit-code diff --git a/.github/workflows/setup-taskflile.yml b/.github/workflows/setup-taskflile.yml index 7e61cc8b..f55983a5 100644 --- a/.github/workflows/setup-taskflile.yml +++ b/.github/workflows/setup-taskflile.yml @@ -13,10 +13,6 @@ jobs: operating-system: [ubuntu-latest, windows-latest] steps: - # GitHub Actions has the annoying behavior of converting LF to CRLF when checking out on the Windows runner - - name: Disable EOL conversions - run: git config --global core.autocrlf false - - name: Checkout uses: actions/checkout@master @@ -31,15 +27,6 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} version: 3.x - - name: Install dependencies - run: task ts:install-deps - - - name: Format with Prettier - run: task general:format - - - name: Check formatting - run: git diff --color --exit-code - - name: Run tests run: task ts:test diff --git a/README.md b/README.md index bee1aaa3..d3b92e22 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Check npm status](https://github.com/arduino/setup-task/actions/workflows/check-npm.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-npm.yml) [![Integration Tests status](https://github.com/arduino/setup-task/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/test-integration.yml) [![Check Action Metadata status](https://github.com/arduino/setup-task/actions/workflows/check-action-metadata-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-action-metadata-task.yml) +[![Check Prettier Formatting status](https://github.com/arduino/setup-task/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-prettier-formatting-task.yml) [![Check Markdown status](https://github.com/arduino/setup-task/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-markdown-task.yml) [![Spell Check status](https://github.com/arduino/setup-task/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/spell-check-task.yml) [![Check License status](https://github.com/arduino/setup-task/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/setup-task/actions/workflows/check-license.yml)