diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e6c409b..049a286b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/README.md b/README.md index 6973e8cb..e11cc5ea 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 diff --git a/action.yml b/action.yml index 33d9826d..6ca1f2cd 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/lib/input.js b/lib/input.js index ba86c8c0..a23be4c4 100644 --- a/lib/input.js +++ b/lib/input.js @@ -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'], { diff --git a/lib/main.js b/lib/main.js index 2988818f..88d9c21b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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 diff --git a/src/input.ts b/src/input.ts index 35583d3b..931743d8 100644 --- a/src/input.ts +++ b/src/input.ts @@ -50,7 +50,7 @@ function logIfDebug(msg: string) { */ export async function get(tok: string, dir: string): Promise { 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 = ''; diff --git a/src/main.ts b/src/main.ts index 7e23589a..91e2a672 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,27 +46,31 @@ export async function run(actionInput: input.Input): Promise { } 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 + }); + } );