Skip to content

Commit

Permalink
Improve Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Nov 7, 2020
1 parent ad98388 commit 2b362c4
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 70 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check

on:
push:
branches:
- "main"
pull_request:

jobs:
main:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [15.x]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: "${{ matrix.node-version }}"

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}

- name: npm ci
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci

- name: Build
run: npm run build

- name: ESLint
run: npx --no-install eslint . --report-unused-disable-directives

- name: Prettier
run: npx --no-install prettier --check .
39 changes: 0 additions & 39 deletions .github/workflows/ci.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
push:
branches:
- "main"
pull_request:

jobs:
main:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: "${{ matrix.node-version }}"

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}

- name: npm ci
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci

- name: Jest
run: npx --no-install jest --coverage
27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ This is for those who use `eslint --fix` (autofix) a lot and want to completely
- [The sorting autofix causes some odd whitespace!](#the-sorting-autofix-causes-some-odd-whitespace)
- [Can I use this without autofix?](#can-i-use-this-without-autofix)
- [How do I use eslint-ignore for this rule?](#how-do-i-use-eslint-ignore-for-this-rule)
- [Development](#development)
- [npm scripts](#npm-scripts)
- [Directories](#directories)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -536,33 +533,12 @@ Not really. The error message for this rule is literally “Run autofix to sort

Looking for `/* eslint-disable */` for this rule? Read all about **[ignoring (parts of) sorting][example-ignore].**

## Development

You need [Node.js] ~12 and npm 6.

### npm scripts

- `npx jest --watch`: Run [Jest] tests in watch mode.
- `npm run doctoc`: Run [doctoc] on README.md.
- `npm run prettier`: Autoformat files with [Prettier].
- `npm run eslint`: Autofix [ESLint] errors.
- `npm run eslint:examples`: Used by `test/examples.test.js`.
- `npm test`: Check that everything works.
- `npm publish`: Publish to [npm], but only if `npm test` passes.

### Directories

- `src/`: Source code.
- `examples/`: Examples, tested in `test/examples.test.js`.
- `test/`: [Jest] tests.

## License

[MIT](LICENSE)

[comment-handling]: #comment-and-whitespace-handling
[custom grouping]: #custom-grouping
[doctoc]: https://github.com/thlorenz/doctoc/
[eslint-fix]: https://eslint.org/docs/user-guide/command-line-interface#--fix
[eslint]: https://eslint.org/
[example-ignore]: https://github.com/lydell/eslint-plugin-simple-import-sort/blob/master/examples/ignore.js
Expand All @@ -575,10 +551,7 @@ You need [Node.js] ~12 and npm 6.
[import/order]: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
[intl.collator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator
[issue #31]: https://github.com/lydell/eslint-plugin-simple-import-sort/issues/31
[jest]: https://jestjs.io/
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
[node.js]: https://nodejs.org/en/
[npm]: https://www.npmjs.com/
[odd-whitespace]: #the-sorting-autofix-causes-some-odd-whitespace
[padding-line-between-statements]: https://eslint.org/docs/rules/padding-line-between-statements
[sort order]: #sort-order
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"type": "commonjs",
"scripts": {
"doctoc": "doctoc README.md",
"prettier": "prettier --write .",
"eslint": "eslint . --fix",
"eslint:examples": "eslint --rulesdir src --no-ignore --fix-dry-run --format json --report-unused-disable-directives examples --ext .js,.ts,.vue,.md",
"test": "prettier --check . && eslint . --report-unused-disable-directives && node build.js && jest --coverage"
"pretest": "prettier --check . && eslint . --report-unused-disable-directives",
"test": "jest --coverage",
"posttest": "npm run build",
"build": "node build.js",
"eslint:examples": "eslint --rulesdir src --no-ignore --fix-dry-run --format json --report-unused-disable-directives examples --ext .js,.ts,.vue,.md"
},
"devDependencies": {
"@typescript-eslint/parser": "4.6.1",
Expand Down

0 comments on commit 2b362c4

Please sign in to comment.