Skip to content

Commit 4eda8f9

Browse files
authored
Merge pull request #192 from github/prechecks-fixes
Prechecks Fixes
2 parents ccff97c + bc37876 commit 4eda8f9

File tree

4 files changed

+77
-7
lines changed

4 files changed

+77
-7
lines changed

__tests__/functions/prechecks.test.js

+60-2
Original file line numberDiff line numberDiff line change
@@ -2096,15 +2096,73 @@ test('runs prechecks and finds that the commit status is success and skip_review
20962096
)
20972097
).toStrictEqual({
20982098
message:
2099-
'✅ CI checked passsed and required reviewers have been disabled for this environment',
2099+
'✅ CI checks passed and required reviewers have been disabled for this environment',
21002100
noopMode: false,
21012101
ref: 'test-ref',
21022102
status: true,
21032103
sha: 'abc123'
21042104
})
21052105

21062106
expect(infoMock).toHaveBeenCalledWith(
2107-
'✅ CI checked passsed and required reviewers have been disabled for this environment'
2107+
'✅ CI checks passed and required reviewers have been disabled for this environment'
2108+
)
2109+
})
2110+
2111+
test('runs prechecks and finds that no ci checks are defined and skip_reviews is set for the environment', async () => {
2112+
octokit.graphql = jest.fn().mockReturnValue({
2113+
repository: {
2114+
pullRequest: {
2115+
reviewDecision: 'REVIEW_REQUIRED',
2116+
commits: {
2117+
nodes: [
2118+
{
2119+
commit: {
2120+
checkSuites: {
2121+
totalCount: 0
2122+
},
2123+
statusCheckRollup: null
2124+
}
2125+
}
2126+
]
2127+
}
2128+
}
2129+
}
2130+
})
2131+
jest.spyOn(isAdmin, 'isAdmin').mockImplementation(() => {
2132+
return false
2133+
})
2134+
2135+
environmentObj.target = 'staging'
2136+
2137+
expect(
2138+
await prechecks(
2139+
'.deploy to staging',
2140+
'.deploy',
2141+
'.noop',
2142+
'disabled',
2143+
'main',
2144+
'123',
2145+
true,
2146+
'development', // skip_ci
2147+
'staging', // skip_reviews
2148+
'development', // draft_permitted_targets
2149+
'staging', // the environment the deployment was sent to
2150+
environmentObj,
2151+
help_trigger,
2152+
context,
2153+
octokit
2154+
)
2155+
).toStrictEqual({
2156+
message:
2157+
'✅ CI checks have not been defined and required reviewers have been disabled for this environment',
2158+
noopMode: false,
2159+
ref: 'test-ref',
2160+
status: true,
2161+
sha: 'abc123'
2162+
})
2163+
2164+
expect(infoMock).toHaveBeenCalledWith(
2165+
'✅ CI checks have not been defined and required reviewers have been disabled for this environment'
21082166
)
21092167
})
21102168

dist/index.js

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/prechecks.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export async function prechecks(
293293
} else if (
294294
(commitStatus === 'SUCCESS' ||
295295
commitStatus === null ||
296-
commitStatus == 'skip_ci') &&
296+
commitStatus === 'skip_ci') &&
297297
update_branch !== 'disabled' &&
298298
behind === true
299299
) {
@@ -357,7 +357,13 @@ export async function prechecks(
357357
// CI checks are passing and reviews are set to be bypassed
358358
} else if (commitStatus === 'SUCCESS' && reviewDecision == 'skip_reviews') {
359359
message =
360-
'✅ CI checked passsed and required reviewers have been disabled for this environment'
360+
'✅ CI checks passed and required reviewers have been disabled for this environment'
361+
core.info(message)
362+
363+
// CI checks have not been defined and reviews are set to be bypassed
364+
} else if (commitStatus === null && reviewDecision === 'skip_reviews') {
365+
message =
366+
'✅ CI checks have not been defined and required reviewers have been disabled for this environment'
361367
core.info(message)
362368

363369
// CI checks are set to be bypassed and the pull request is approved

0 commit comments

Comments
 (0)