Skip to content

Commit

Permalink
v3.2.0 release (bradennapier#25)
Browse files Browse the repository at this point in the history
* feat: batched annotations (bradennapier#21)

* take first 50 annotations from file to respect [Github Check annotation limit](https://developer.github.com/v3/checks/runs/#output-object-1)

* fix: handle batched annotations

* feat: run batched annotations in parallel

Co-authored-by: Braden Napier <brady.napier@dashos.net>

Co-authored-by: Stephen Chung <spchung95@gmail.com>

* feat: semantic-release (bradennapier#22)

* feat: batched annotations

* take first 50 annotations from file to respect [Github Check annotation limit](https://developer.github.com/v3/checks/runs/#output-object-1)

* fix: handle batched annotations

* feat: run batched annotations in parallel

Co-authored-by: Braden Napier <brady.napier@dashos.net>

* build: add semantic release action

* build: various build and release changes

Co-authored-by: Stephen Chung <spchung95@gmail.com>

* Next (bradennapier#23)

* feat: batched annotations

* take first 50 annotations from file to respect [Github Check annotation limit](https://developer.github.com/v3/checks/runs/#output-object-1)

* fix: handle batched annotations

* feat: run batched annotations in parallel

Co-authored-by: Braden Napier <brady.napier@dashos.net>

* fix: bullshit

Co-authored-by: Stephen Chung <spchung95@gmail.com>

* Next (bradennapier#24)

* feat: batched annotations

* take first 50 annotations from file to respect [Github Check annotation limit](https://developer.github.com/v3/checks/runs/#output-object-1)

* fix: handle batched annotations

* feat: run batched annotations in parallel

Co-authored-by: Braden Napier <brady.napier@dashos.net>

* fix: bullshit

* chore: readme

Co-authored-by: Stephen Chung <spchung95@gmail.com>

* fix: remove tag

* feat: beta

* fix: google replace

* fix: google replace version commit

* chore(release): 3.2.0-beta.2 [skip ci]

* feat: add release notes generator

* fix: bring readme template in workflow

* chore(release): 3.2.0-beta.3 [skip ci]

# [3.2.0-beta.3](bradennapier/eslint-plus-action@v3.2.0-beta.2...v3.2.0-beta.3) (2020-07-14)

### Bug Fixes

* bring readme template in workflow ([36f521f](bradennapier@36f521f))

### Features

* add release notes generator ([518309f](bradennapier@518309f))

Co-authored-by: Stephen Chung <spchung95@gmail.com>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
  • Loading branch information
3 people authored Jul 14, 2020
1 parent 74232b9 commit ad3f3f2
Show file tree
Hide file tree
Showing 20 changed files with 3,824 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ dist/
lib/
node_modules/
!.prettierrc.js
!.eslintrc.js
!.eslintrc.js
10 changes: 4 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
Expand All @@ -9,18 +12,13 @@ module.exports = {
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': ['error'],
'prettier/prettier': 'error',
// octokit/rest requires parameters that are not in camelcase
camelcase: 'off',
// '@typescript-eslint/camelcase': ['error', {properties: 'never'}],
},
env: {
node: true,
jest: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
};
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release
on:
push:
branches:
- master
- next
- beta
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2-beta
with:
node-version: '12'
check-latest: true
- name: Install dependencies
run: yarn
- name: Replace Template
run: cp -f docs/README.template.md README.md
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist/
lib/
node_modules/
1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ module.exports = {
useTabs: false,
singleQuote: true,
trailingComma: 'all',
parser: 'typescript',
};
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@v3.1.0
- uses: bradennapier/eslint-plus-action@v3.2.0-beta.3
```
## Features
Expand Down Expand Up @@ -97,11 +97,17 @@ GitHub Actions only have read permissions when a forked PR is opened. However,

Each time the schedule job runs it will run through any new artifacts and update the PR with the results like normal. *If a job hasn't been detected in the last 24 hours then the action will no longer save artifacts.* This is so you do not needlessly use up your data storage.

> Note that we delete the artifacts as soon as they have been processed so they will not use up your storage for very long.
> Note that we delete the artifacts as soon as they have been processed so they will
> not use up your storage for very long.

> You can optionally add additional optimization by also making sure to run this action on the `[closed]` event so that we can cleanup all the artifacts when this occurs.
> You can optionally add additional optimization by also making sure to run this action
> on the `[closed]` event so that we can cleanup all the artifacts when this occurs.

> The scheduler will not start running until you have pushed the workflow to your main branch (`master`). If it still does not run you can try pushing an empty commit, it seems that is sometimes required `git commit --allow-empty -m 'redeploy schedule action'`
<br />

> The scheduler will not start running until you have pushed the workflow to your main
> branch (`master`). If it still does not run you can try pushing an empty commit, it
> seems that is sometimes required `git commit --allow-empty -m 'redeploy schedule action'`

```yml
name: "lint"
Expand All @@ -122,7 +128,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@v3.1.0
- uses: bradennapier/eslint-plus-action@v3.2.0-beta.3
```

## Examples
Expand All @@ -140,7 +146,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@v3.1.0
- uses: bradennapier/eslint-plus-action@v3.2.0-beta.3
```

### Environment Variables
Expand All @@ -153,7 +159,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@v3.1.0
- uses: bradennapier/eslint-plus-action@v3.2.0-beta.3
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
```
Expand All @@ -166,7 +172,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@v3.1.0
- uses: bradennapier/eslint-plus-action@v3.2.0-beta.3
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
with:
Expand Down
194 changes: 194 additions & 0 deletions docs/README.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<div align="center">
<br />
<br/>
<br/>
<p align="center">
<img src="docs/img/annotation.png" width="100%" title="eslint-plus-action">
</p>
<br />
<h1>
eslint-plus-action
</h1>
<br />
<br />
<br />
<br />
<sup>
A flexible and dead simple Github Action which runs ESLint against the changed files in a PR with customizable options and rich summaries. ESLint issues are annotated inline on your PR diff.
</sup>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>

## Dead Simple

As easy as the following, and even the more advanced features are just a few extra lines.

```yml
name: "my-workflow"
on: [pull_request]

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@__VERSION__
```
## Features
- :tada: [**Works on Forked PR's Securely!**](https://github.com/bradennapier/eslint-plus-action#handle-forked-prs) :tada:
- [Inline Annotations of ESLint Warnings & Errors](https://github.com/bradennapier/eslint-plus-action/pull/3/files)
- Customizable ESLint options
- [Optional summary comments on each push to the PR](https://github.com/bradennapier/eslint-plus-action/pull/3)
- [Links to the rule documentation when available](https://github.com/bradennapier/eslint-plus-action/pull/3#issuecomment-646635983)
- [Annotation Summary Page](https://github.com/bradennapier/eslint-plus-action/pull/3/checks?check_run_id=788235048)
- Suggestions are printed when enabled (not yet provided as change suggestions)
- Button to run ESLint Fix [COMING SOON]
- More...
> The summary comments have some redundancy when there are suggestions available. This will be improved.
> The `fix` property is not yet setup but will come shortly. If fixes are available, it will render an action button to run the fix as well.

## Configuration

You provide configuration properties within your workflow by using the `with` property. See the `Simple Workflow Example` for an example of providing your github-token.

> `array` types are expected to be comma-separated values

### General Configuration Properties

| Property | Type | Default | Required | Description |
| ------------- | ---- | ------- | -------- | ----------- |
| github-token | string | secrets.GITHUB_TOKEN | false | Your Github token. You only need to provide this if you want to use something other than `secrets.GITHUB_TOKEN` |
| issueSummary | boolean | true | false | Should the bot provide a summary of the results as a comment? |
| issueSummaryType | string | compact | false | Changes the PR comment to be "full" (as shown on actions page) or "compact" |
| issueSummaryMethod | string | edit | false | When issueSummary is enabled, allows having the bot edit or refresh the comment on each new push, can be 'edit' or 'refresh' |
| issueSummaryOnlyOnEvent | boolean | false | false | Only provide the issue summary comment if there are warnings or errors present? |
| annotateWarnings | boolean | true | false | By setting this to "false", only errors will be annotated |
| reportSuggestions | boolean | true | false | Report suggestions when available within the annotations? |
| reportIgnoredFiles | boolean | false | false | Report a list of any ignored files? |
| reportWarningsAsErrors | boolean | false | false | Report any eslint warnings as errors? |
| extensions | array | .js,.jsx,.ts,.tsx | false | An array of extensions to lint |
| includeGlob | array | \*\*/\* | false | Optional array of globs to include from the changed files list |
| ignoreGlob | array | none | false | Optional array of globs to ignore from the changed files list |
| configFile | string | none | false | A config file to use if the default config resolution doesn't work. |
| rulePaths | array | none | false | Optional paths to custom rules directories to include. |
| errorOnUnmatchedPattern | boolean | false | false | Throw error if unmatched pattern is seen? |
| useEslintrc | boolean | true | false | Use eslintrc? |
| useEslintIgnore | boolean | true | false | Use eslintignore? |
| fix | boolean | false | false | Commit fixes when possible (UNFINISHED) |
| npmInstall | boolean | false | false | Force run npm ci (or yarn) for you. If you do not use this option, be sure to install the project dependencies before running this action. By default it will run if a node_modules directory is not found or this is set to true |

> The official settings can always be seen by viewing the [`action.yml`](https://github.com/bradennapier/eslint-plus-action/blob/master/action.yml) schema for the action.

## Handle Forked PRs

GitHub Actions only have read permissions when a forked PR is opened. However, we can work around this by setting up a scheduled job in our workflow. This runs at your given interval and will automatically enable serialization of results as workflow artifacts when required. Since these will **always run against our master branch**, we can safely run our results without concern that the fork has modified the workflow in any way which may be malicious.

Each time the schedule job runs it will run through any new artifacts and update the PR with the results like normal. *If a job hasn't been detected in the last 24 hours then the action will no longer save artifacts.* This is so you do not needlessly use up your data storage.

> Note that we delete the artifacts as soon as they have been processed so they will
> not use up your storage for very long.

> You can optionally add additional optimization by also making sure to run this action
> on the `[closed]` event so that we can cleanup all the artifacts when this occurs.

<br />

> The scheduler will not start running until you have pushed the workflow to your main
> branch (`master`). If it still does not run you can try pushing an empty commit, it
> seems that is sometimes required `git commit --allow-empty -m 'redeploy schedule action'`

```yml
name: "lint"
on:
# by adding a schedule task to this workflow we will automatically
# begin serializing read-only runs and handling them. The cron job
# below is set to run every 15 minutes, GitHub will ignore anything
# under 10 minutes and run every 10 minutes anyway.
schedule:
- cron: '*/15 * * * *'
pull_request:
types:
- opened
- synchronize
- closed
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@__VERSION__
```

## Examples

### Simple Workflow Example

Below is a basic example which should get you going. You can view the action.yml to see what other properties are available for customization.

```yml
name: "my-workflow"
on: [pull_request]
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@__VERSION__
```

### Environment Variables

There may be times that you need to provide a `NPM_TOKEN` so that the action can install your private repos. You do this by adding the secret to your repo `Settings -> Secrets` then providing it as an environment variable to the action:

```yml
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@__VERSION__
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
```

### Providing Parameters

```yml
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bradennapier/eslint-plus-action@__VERSION__
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
with:
issueSummaryType: full
reportIgnoredFiles: true
```

## More Previews

<p align="center">
<img src="docs/img/prcomment.png" width="100%" title="eslint-plus-action-pr-comment">
</p>

## Credits

This action was adapted from other actions which didn't quite work for me but were close. So special thanks to them for helping me get here.

- https://github.com/marketplace/actions/eslint-annotate
- https://github.com/marketplace/actions/eslint-action
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ fi
pushd /action
echo "Yarn Action Install"

[ -f yarn.lock ] && yarn install --frozen-lockfile --prefer-offline
[ -f package-lock.json ] && npm install
[ -f yarn.lock ] && NODE_ENV=production yarn install --frozen-lockfile --prefer-offline
[ -f package-lock.json ] && NODE_ENV=production npm install
popd


echo "Execute From Directory: $(pwd)"

NODE_PATH=node_modules GITHUB_TOKEN="${GITHUB_TOKEN:-${1:-.}}" SOURCE_ROOT=${2:-.} node /action/lib/run.js

rm -rf node_modules # cleanup to prevent some weird permission errors later on
# rm -rf node_modules # cleanup to prevent some weird permission errors later on
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GITHUB_WORKSPACE = exports.ISSUE_NUMBER = exports.REPO = exports.OWNER = exports.HEAD_FULL_NAME = exports.BASE_FULL_NAME = exports.SERIALIZED_ROUTES = exports.ARTIFACTS_BASE_DIR = exports.ARTIFACT_KEY_ISSUE_STATE = exports.ARTIFACT_KEY_LINT_RESULTS = exports.ARTIFACT_KEY = exports.NAME = exports.DEFAULT_WORKFLOW_STATE = exports.DEFAULT_ISSUE_STATE = void 0;
exports.GITHUB_WORKSPACE = exports.GITHUB_ANNOTATION_LIMIT = exports.ISSUE_NUMBER = exports.REPO = exports.OWNER = exports.HEAD_FULL_NAME = exports.BASE_FULL_NAME = exports.SERIALIZED_ROUTES = exports.ARTIFACTS_BASE_DIR = exports.ARTIFACT_KEY_ISSUE_STATE = exports.ARTIFACT_KEY_LINT_RESULTS = exports.ARTIFACT_KEY = exports.NAME = exports.DEFAULT_WORKFLOW_STATE = exports.DEFAULT_ISSUE_STATE = void 0;
const tslib_1 = require("tslib");
const github = tslib_1.__importStar(require("@actions/github"));
const guards_1 = require("./guards");
Expand Down Expand Up @@ -37,4 +37,5 @@ exports.HEAD_FULL_NAME = guards_1.isPullRequestPayload(context.payload)
? context.payload.pull_request.head.repo.full_name
: undefined;
_a = github.context.issue || github.context.repo, exports.OWNER = _a.owner, exports.REPO = _a.repo, exports.ISSUE_NUMBER = _a.number;
exports.GITHUB_ANNOTATION_LIMIT = 50;
exports.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE;
Loading

0 comments on commit ad3f3f2

Please sign in to comment.