Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error threshold input parameter #5

Merged
merged 4 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

## Passing `project` parameter

If your working with a monorepo or your `tsconfig.json` is not in the root repo,
If you're working with a monorepo or your `tsconfig.json` is not in the root repo,
or you use different config file, you can provide a `project` parmeter with a
path to the repo itself:

Expand All @@ -62,3 +62,13 @@ path to the repo itself:
with:
project: packages/subpackage/tsconfig.json
```
## Passing `error_fail_threshold` parameter

If you're incrementally adopting typescript in a project, you may not want to fail the entire workflow on a single typescript error. `error_fail_threshold` allows you to pass the maximum number of errors at which the step passes. Defaults to 0:

```yaml
- name: Typecheck
uses: gozala/typescript-error-reporter-action@v1.0.9
with:
error_fail_threshold: 100
```
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ inputs:
project:
description: 'Optional project path.'
required: false
error_fail_threshold:
description: 'Optional number of errors threshold at which this step fails.'
required: false

8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ const typecheck = (projectPath:string) => {
? performIncrementalCompilation(ts, projectPath)
: performCompilation(ts, config)

if (errors > 0) {
setFailed(`Found ${errors} errors!`)

const errThreshold = Number(getInput('error_fail_threshold') || 0)
const logString = `Found ${errors} errors!`
console.log(logString)
if (errors > errThreshold) {
setFailed(logString)
}
}

Expand Down