Skip to content

Commit

Permalink
Allow for the PR number to be mocked for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Dec 6, 2023
1 parent 1f79ea9 commit 1ff344f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
required-approvers-list: peternied
min-required: 1
mock-approvers: 'peternied'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'success' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied'
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -33,6 +34,7 @@ jobs:
required-approvers-list: peternied
min-required: 1
mock-approvers: 'peternied greengiant'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'success' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied'
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -50,6 +52,7 @@ jobs:
required-approvers-list: peternied
min-required: 1
mock-approvers: ' '
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != ''
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -67,6 +70,7 @@ jobs:
required-approvers-list: peternied
min-required: 1
mock-approvers: 'greengiant'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != ''
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -84,6 +88,7 @@ jobs:
required-approvers-list: 'peternied, greengiant'
min-required: 2
mock-approvers: 'peternied'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied'
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -101,6 +106,7 @@ jobs:
required-approvers-list: 'peternied, greengiant, austin, billyjean robert'
min-required: 4
mock-approvers: 'peternied greengiant austin billyjean robert'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied'
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
Expand All @@ -116,6 +122,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
min-required: 2
mock-approvers: 'peternied bob kelly'
mock-pr-number: 42

- if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied bob kelly'
run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}"
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36724,7 +36724,7 @@ async function run() {
}
const minRequired = parseInt(minRequiredStr);

const pullRequestId = github.context.payload.pull_request?.number;
const pullRequestId = github.context.payload.pull_request?.number || core.getInput('mock-pr-number', { required: false });
if (!pullRequestId) {
core.setFailed(`Unable to find associated pull request from the context: ${JSON.stringify(github.context)}`);
return;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function run() {
}
const minRequired = parseInt(minRequiredStr);

const pullRequestId = github.context.payload.pull_request?.number;
const pullRequestId = github.context.payload.pull_request?.number || core.getInput('mock-pr-number', { required: false });
if (!pullRequestId) {
core.setFailed(`Unable to find associated pull request from the context: ${JSON.stringify(github.context)}`);
return;
Expand Down

0 comments on commit 1ff344f

Please sign in to comment.