From 249640d0f7856ed7aa13b66ef6f3e3141ed7ea83 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 16 Jun 2020 14:16:50 -0700 Subject: [PATCH 1/5] Remove external status check --- src/main.ts | 14 ++++++-------- src/services/checks.ts | 32 -------------------------------- src/services/index.ts | 1 - 3 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 src/services/checks.ts diff --git a/src/main.ts b/src/main.ts index e880f27..52438db 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,8 +5,6 @@ import { getChangedFiles, writeComments, getTargetState, - startCheck, - completeCheck, updateComments, resolveComments } from './services'; @@ -38,16 +36,12 @@ async function run() { return; } - const octokit = new github.GitHub(token, { - previews: ['squirrel-girl'] - }); + const octokit = new github.GitHub(token); const eventName = process.env.GITHUB_EVENT_NAME; console.log('starting check'); - const checkRun = await startCheck(octokit); - const changes: Change[] = await getChangedFiles(octokit, eventName); const targetState = await getTargetState(octokit, comments, changes); @@ -57,7 +51,11 @@ async function run() { resolveComments(octokit, targetState.commentsToResolve) ]); - await completeCheck(octokit, checkRun.id, targetState.conclusion); + if (targetState.conclusion !== 'success') { + core.setFailed( + 'Nitpicker has failed due to blocking comments being applied' + ); + } } catch (error) { core.setFailed(error.message); } diff --git a/src/services/checks.ts b/src/services/checks.ts deleted file mode 100644 index 10bf800..0000000 --- a/src/services/checks.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as github from '@actions/github'; -import { parseContext } from './context'; -import { Conclusion } from '../models'; - -export async function startCheck(octokit: github.GitHub) { - const context = parseContext(); - - const result = await octokit.checks.create({ - owner: context.owner, - repo: context.repo, - name: 'nitpicker', - head_sha: context.sha, - status: 'in_progress' - }); - - return result.data; -} - -export async function completeCheck( - octokit: github.GitHub, - checkId: number, - conclusion: Conclusion -) { - const context = parseContext(); - - await octokit.checks.update({ - owner: context.owner, - repo: context.repo, - check_run_id: checkId, - conclusion: conclusion - }); -} diff --git a/src/services/index.ts b/src/services/index.ts index 9d50f9e..3a57527 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,6 +1,5 @@ export * from './configReader'; export * from './comments'; export * from './changes'; -export * from './checks'; export * from './context'; export * from './state'; From e690dad4c6777084054cf622ebe8abf60586daf5 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 16 Jun 2020 14:17:52 -0700 Subject: [PATCH 2/5] Add blocking comment --- test.dll | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.dll diff --git a/test.dll b/test.dll new file mode 100644 index 0000000..e69de29 From 6a2c4728f1d7c554101e7e03785314cad2abc207 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 16 Jun 2020 14:20:32 -0700 Subject: [PATCH 3/5] Revert "Add blocking comment" This reverts commit e690dad4c6777084054cf622ebe8abf60586daf5. --- test.dll | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test.dll diff --git a/test.dll b/test.dll deleted file mode 100644 index e69de29..0000000 From 2827fa48b6c6859692b096d55c44afbc77b52eb9 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 16 Jun 2020 14:21:10 -0700 Subject: [PATCH 4/5] Update readme --- README.md | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 655959f..ad11ebf 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the Nitpicker action to your workflow and allow access to the `secrets.GITHU ## Blocking comments -A blocking comment indicates that a PR containing changed files that match a specified path filter will be blocked from being completed. After the indicated file/folder has been removed from the PR, the blocking comment will be considered 'resolved' and the PR can be completed. +A blocking comment indicates that a PR containing changed files that match a specified path filter will fail the build job that the nitpicker is run in. After the indicated file/folder has been removed from the PR, the blocking comment will be considered 'resolved' the build job will succeed and the PR can be completed. ## Common use-cases diff --git a/src/main.ts b/src/main.ts index 52438db..7582cda 100644 --- a/src/main.ts +++ b/src/main.ts @@ -53,7 +53,7 @@ async function run() { if (targetState.conclusion !== 'success') { core.setFailed( - 'Nitpicker has failed due to blocking comments being applied' + 'nitpicker has failed due to blocking comments being applied' ); } } catch (error) { From 6c4d37fe9586997e4227fb154d938b6efa933f5b Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 16 Jun 2020 14:22:37 -0700 Subject: [PATCH 5/5] Use proper english --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad11ebf..ba0a114 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Add the Nitpicker action to your workflow and allow access to the `secrets.GITHU ## Blocking comments -A blocking comment indicates that a PR containing changed files that match a specified path filter will fail the build job that the nitpicker is run in. After the indicated file/folder has been removed from the PR, the blocking comment will be considered 'resolved' the build job will succeed and the PR can be completed. +A blocking comment indicates that a PR containing changed files that match a specified path filter will fail the build job that the nitpicker is run in. After the indicated file/folder has been removed from the PR, the blocking comment will be considered 'resolved', the build job will succeed, and the PR can be completed. ## Common use-cases