From a9d842f3a816180d8609d75c2b7372e1caaaf0e3 Mon Sep 17 00:00:00 2001 From: computerjazz Date: Tue, 16 Mar 2021 09:39:37 -0700 Subject: [PATCH 1/4] add fail threshold --- action.yml | 4 ++++ src/index.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 2d654f4..5d45e9a 100644 --- a/action.yml +++ b/action.yml @@ -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 + diff --git a/src/index.ts b/src/index.ts index 5dc32f1..448a619 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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) } } From a7286d589a8c66d9c6a4f2670e4c1687d98cc5ca Mon Sep 17 00:00:00 2001 From: computerjazz Date: Tue, 16 Mar 2021 09:48:32 -0700 Subject: [PATCH 2/4] update readme --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50a2916..36e388e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - name: Typecheck - uses: gozala/typescript-error-reporter-action@v1.0.5 + uses: computerjazz/typescript-error-reporter-action@v1.0.9 ``` `tsconfig.json`: @@ -52,13 +52,23 @@ 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: ```yaml - name: Typecheck - uses: gozala/typescript-error-reporter-action@v1.0.5 + uses: computerjazz/typescript-error-reporter-action@v1.0.9 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: computerjazz/typescript-error-reporter-action@v1.0.9 + with: + error_fail_threshold: 100 +``` From f87398554585067bde7fba5b166e85e348cd30d4 Mon Sep 17 00:00:00 2001 From: computerjazz Date: Tue, 16 Mar 2021 12:09:22 -0700 Subject: [PATCH 3/4] revert README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36e388e..6f17150 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - name: Typecheck - uses: computerjazz/typescript-error-reporter-action@v1.0.9 + uses: gozala/typescript-error-reporter-action@v1.0.9 ``` `tsconfig.json`: @@ -58,7 +58,7 @@ path to the repo itself: ```yaml - name: Typecheck - uses: computerjazz/typescript-error-reporter-action@v1.0.9 + uses: gozala/typescript-error-reporter-action@v1.0.9 with: project: packages/subpackage/tsconfig.json ``` @@ -68,7 +68,7 @@ If you're incrementally adopting typescript in a project, you may not want to fa ```yaml - name: Typecheck - uses: computerjazz/typescript-error-reporter-action@v1.0.9 + uses: gozala/typescript-error-reporter-action@v1.0.9 with: error_fail_threshold: 100 ``` From 02d0a1022e6df6d8527e2cd2b791f4660fc91909 Mon Sep 17 00:00:00 2001 From: computerjazz Date: Tue, 16 Mar 2021 12:13:11 -0700 Subject: [PATCH 4/4] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f17150..dbb6ec1 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - name: Typecheck - uses: gozala/typescript-error-reporter-action@v1.0.9 + uses: gozala/typescript-error-reporter-action@v1.0.5 ``` `tsconfig.json`: @@ -58,7 +58,7 @@ path to the repo itself: ```yaml - name: Typecheck - uses: gozala/typescript-error-reporter-action@v1.0.9 + uses: gozala/typescript-error-reporter-action@v1.0.5 with: project: packages/subpackage/tsconfig.json ```