Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
* v1
  • Loading branch information
mattallty authored Apr 21, 2020
1 parent 0b71672 commit 993b972
Show file tree
Hide file tree
Showing 23 changed files with 3,855 additions and 33,700 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
lib/
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
root: true,
env: {
node: true,
es6: true,
jest: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
overrides: [
{
files: ['**/*.ts'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:jest/recommended'
],
plugins: ['@typescript-eslint', 'jest'],
rules: {
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true
}
],
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-use-before-define': 'off',
'no-console': 'error',
// nededed for mixins to avoid unecessary warnings
'@typescript-eslint/no-empty-interface': 'off'
}
}
]
}
17 changes: 0 additions & 17 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
# unit tests
test:
tests:
name: "Unit tests"
runs-on: ubuntu-latest
steps:
Expand All @@ -17,14 +17,13 @@ jobs:
- run: npm test

# Failing tests on purpose
action-test:
failing-tests:
name: "Failing tests (on purpose)"
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v1
- run: npm ci
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
test-command: "npm run failing-test"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/

jest.results.json
lib/

# Editors
.vscode
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
trailingComma: "all",
tabWidth: 2,
semi: false,
printWidth: 90,
}
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
# Jest Github Action

> Jest action adding checks to your pull requests
Main features:

- Add status checks with code annotations to your pull requests
- Comment your pull requests with code coverage table (if tests succeeded)

## Usage

You can now consume the action by referencing the v1 branch

```yaml
uses: actions/javascript-action@v1
uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Overriding the test command
By default, this action will execute `npm test` to run your tests.
You can change this behavior by providing a custom `test-command` like this:

```yaml
uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# this is just an example, this could be any command that will trigger jest
test-command: "yarn test"
```

### Running tests only on changed files

```yaml
uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
milliseconds: 1000
# Runs tests related to the changes since the base branch of your pull request
# Default to false if not set
changes-only: true
```

See the [actions tab](https://github.com/mattallty/jest-github-action/actions) for runs of this action! :rocket:
11 changes: 8 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: "jest-github-action"
description: "Jest action adding checks to your pull requests"
inputs:
github-token:
description: "Your Github token"
required: true
test-command:
description: "The test command to run"
required: false
default: "npm test"
coverage-comment:
description: "Comment PRs with code coverage"
required: false
default: "true"
changes-only:
description: "Only run tests on changed files (over base branch)"
required: false
default: "false"

runs:
using: "node12"
Expand Down
Loading

0 comments on commit 993b972

Please sign in to comment.