Skip to content

Commit

Permalink
Merge pull request #132 from anaxite/reviewdog
Browse files Browse the repository at this point in the history
Bump reviewdog to 0.20.2
  • Loading branch information
jdkato authored Nov 15, 2024
2 parents 2690bc9 + c2a8a93 commit 72a0a95
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
name: runner / vale
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ./ # Uses an action in the root directory
with:
reporter: github-check
fail_on_error: true
fail_level: error
level: warning
debug: true
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ with:

### `fail_on_error` (default: false)

> [!WARNING]
> This input is deprecated. Use [`fail_level`](#fail_level-default-none)
> instead. If `fail_level` and `fail_on_error` are both set, `fail_level`
> takes precedence.

By default, `reviewdog` will return exit code `0` even if it finds errors. If
`fail_on_error` is enabled, `reviewdog` exits with `1` when at least one error
was reported.
Expand All @@ -140,6 +145,19 @@ with:
fail_on_error: true
```

### `fail_level` (default: none)


By default, `reviewdog` will return exit code `0`. If `fail_level` is set to
`any`, `info`, `warning`, or `error`, `reviewdog` exits with code `1` if it
finds at least one issue with severity greater than or equal to the given
setting.

```yaml
with:
fail_level: any
```

### `filter_mode` (default: added)

Set the [filter mode](https://github.com/reviewdog/reviewdog#filter-mode) for
Expand Down
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ inputs:

fail_on_error:
description: |
Exit code for reviewdog when errors are found [true,false]
(Deprecated) Exit code for reviewdog when errors are found [true,false]
Default is `false`.
required: false
default: "false"

fail_level:
description: |
Minimum report level at which reviewdog exits with code `1` [none,any,info,warning,error]
Default is `none`.
required: false
default: "none"

level:
description: "Report level for reviewdog [info,warning,error]."
required: false
Expand Down
2 changes: 1 addition & 1 deletion lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function logIfDebug(msg) {
function get(tok, dir) {
return __awaiter(this, void 0, void 0, function* () {
const localVale = yield (0, install_1.installLint)(core.getInput('version'));
const localReviewDog = yield (0, install_1.installReviewDog)("0.17.0", core.getInput('reviewdog_url'));
const localReviewDog = yield (0, install_1.installReviewDog)("0.20.2", core.getInput('reviewdog_url'));
const valeFlags = core.getInput("vale_flags");
let version = '';
yield exec.exec(localVale, ['-v'], {
Expand Down
17 changes: 12 additions & 5 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,24 @@ function run(actionInput) {
return 2; // Exit the function early
}
const should_fail = core.getInput('fail_on_error');
const should_fail_on_level = core.getInput('fail_level');
// Pipe to reviewdog ...
core.info('Calling reviewdog 🐶');
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token');
return yield exec.exec(actionInput.reviewdogPath, [
options = [
'-f=rdjsonl',
`-name=vale`,
`-reporter=${core.getInput('reporter')}`,
`-fail-on-error=${should_fail}`,
`-filter-mode=${core.getInput('filter_mode')}`,
`-level=${vale_code == 1 && should_fail === 'true' ? 'error' : 'info'}`
], {
`-filter-mode=${core.getInput('filter_mode')}`
];
if (should_fail === 'true' && should_fail_on_level === 'none') {
options.push(`-fail-on-error=true`);
options.push(`-level=${vale_code == 1 ? 'error' : 'info'}`);
} else {
options.push(`-fail-level=${should_fail_on_level}`);
options.push(`-level=${vale_code == 1 ? should_fail_on_level : 'info'}`);
}
return yield exec.exec(actionInput.reviewdogPath, options, {
cwd,
input: Buffer.from(output.stdout, 'utf-8'),
ignoreReturnCode: true
Expand Down
2 changes: 1 addition & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function logIfDebug(msg: string) {
*/
export async function get(tok: string, dir: string): Promise<Input> {
const localVale = await installLint(core.getInput('version'));
const localReviewDog = await installReviewDog("0.17.0", core.getInput('reviewdog_url'));
const localReviewDog = await installReviewDog("0.20.2", core.getInput('reviewdog_url'));
const valeFlags = core.getInput("vale_flags");

let version = '';
Expand Down
38 changes: 21 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,31 @@ export async function run(actionInput: input.Input): Promise<void> {
}

const should_fail = core.getInput('fail_on_error');
const should_fail_on_level = core.getInput('fail_level');

// Pipe to reviewdog ...
core.info('Calling reviewdog 🐶');
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token');
return await exec.exec(
actionInput.reviewdogPath,
[
'-f=rdjsonl',
`-name=vale`,
`-reporter=${core.getInput('reporter')}`,
`-fail-on-error=${should_fail}`,
`-filter-mode=${core.getInput('filter_mode')}`,
`-level=${vale_code == 1 && should_fail === 'true' ? 'error' : 'info'
}`
],
{
cwd,
input: Buffer.from(output.stdout, 'utf-8'),
ignoreReturnCode: true
}
);

options = [
'-f=rdjsonl',
`-name=vale`,
`-reporter=${core.getInput('reporter')}`,
`-filter-mode=${core.getInput('filter_mode')}`
];
if (should_fail === 'true' && should_fail_on_level === 'none') {
options.push(`-fail-on-error=true`);
options.push(`-level=${vale_code == 1 ? 'error' : 'info'}`);
} else {
options.push(`-fail-level=${should_fail_on_level}`);
options.push(`-level=${vale_code == 1 ? should_fail_on_level : 'info'}`);
}
return yield exec.exec(actionInput.reviewdogPath, options, {
cwd,
input: Buffer.from(output.stdout, 'utf-8'),
ignoreReturnCode: true
});

}
);

Expand Down

0 comments on commit 72a0a95

Please sign in to comment.