Skip to content

Commit

Permalink
Merge pull request #5 from computerjazz/dm-add-error-threshold
Browse files Browse the repository at this point in the history
Add error threshold input parameter
  • Loading branch information
Gozala committed Jun 15, 2023
2 parents 4dffc95 + 02d0a10 commit 6b3b6cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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/[email protected]
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

0 comments on commit 6b3b6cf

Please sign in to comment.