Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
2e72efde
Unverified
Commit
2e72efde
authored
4 years ago
by
Sergei Zharinov
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(limits): Ignore prNotPendingHours when stabilityDays is set (#7459)
Co-authored-by:
Rhys Arkins
<
rhys@arkins.net
>
parent
9239a4b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/pr/index.spec.ts
+24
-1
24 additions, 1 deletion
lib/workers/pr/index.spec.ts
lib/workers/pr/index.ts
+6
-2
6 additions, 2 deletions
lib/workers/pr/index.ts
with
30 additions
and
3 deletions
lib/workers/pr/index.spec.ts
+
24
−
1
View file @
2e72efde
...
...
@@ -176,6 +176,7 @@ describe('workers/pr', () => {
'
Some body<!-- Reviewable:start -->something<!-- Reviewable:end -->
\n\n
'
,
}
as
never
;
beforeEach
(()
=>
{
jest
.
resetAllMocks
();
setupChangelogMock
();
config
=
partial
<
BranchConfig
>
({
...
defaultConfig
,
...
...
@@ -361,12 +362,24 @@ describe('workers/pr', () => {
expect
(
prResult
).
toEqual
(
PrResult
.
AwaitingNotPending
);
expect
(
pr
).
toBeUndefined
();
});
it
(
'
should not create PR if waiting for not pending with stabilityStatus yellow
'
,
async
()
=>
{
platform
.
getBranchStatus
.
mockResolvedValueOnce
(
BranchStatus
.
yellow
);
git
.
getBranchLastCommitTime
.
mockImplementationOnce
(()
=>
Promise
.
resolve
(
new
Date
())
);
config
.
prCreation
=
'
not-pending
'
;
config
.
stabilityStatus
=
BranchStatus
.
yellow
;
const
{
prResult
,
pr
}
=
await
prWorker
.
ensurePr
(
config
);
expect
(
prResult
).
toEqual
(
PrResult
.
AwaitingNotPending
);
expect
(
pr
).
toBeUndefined
();
});
it
(
'
should create PR if pending timeout hit
'
,
async
()
=>
{
platform
.
getBranchStatus
.
mockResolvedValueOnce
(
BranchStatus
.
yellow
);
git
.
getBranchLastCommitTime
.
mockImplementationOnce
(()
=>
Promise
.
resolve
(
new
Date
(
'
2017-01-01
'
))
);
config
.
prCreation
=
'
not-pending
'
;
config
.
stabilityStatus
=
BranchStatus
.
yellow
;
const
{
prResult
,
pr
}
=
await
prWorker
.
ensurePr
(
config
);
expect
(
prResult
).
toEqual
(
PrResult
.
Created
);
expect
(
pr
).
toMatchObject
({
displayNumber
:
'
New Pull Request
'
});
...
...
@@ -572,7 +585,7 @@ describe('workers/pr', () => {
expect
(
prResult
).
toEqual
(
PrResult
.
BlockedByBranchAutomerge
);
expect
(
pr
).
toBeUndefined
();
});
it
(
'
should
not
return
no
PR if branch automerging taking too long
'
,
async
()
=>
{
it
(
'
should return PR if branch automerging taking too long
'
,
async
()
=>
{
config
.
automerge
=
true
;
config
.
automergeType
=
'
branch
'
;
platform
.
getBranchStatus
.
mockResolvedValueOnce
(
BranchStatus
.
yellow
);
...
...
@@ -581,6 +594,16 @@ describe('workers/pr', () => {
expect
(
prResult
).
toEqual
(
PrResult
.
Created
);
expect
(
pr
).
toBeDefined
();
});
it
(
'
should return no PR if stabilityStatus yellow
'
,
async
()
=>
{
config
.
automerge
=
true
;
config
.
automergeType
=
'
branch
'
;
config
.
stabilityStatus
=
BranchStatus
.
yellow
;
platform
.
getBranchStatus
.
mockResolvedValueOnce
(
BranchStatus
.
yellow
);
git
.
getBranchLastCommitTime
.
mockResolvedValueOnce
(
new
Date
(
'
2018-01-01
'
));
const
{
prResult
,
pr
}
=
await
prWorker
.
ensurePr
(
config
);
expect
(
prResult
).
toEqual
(
PrResult
.
BlockedByBranchAutomerge
);
expect
(
pr
).
toBeUndefined
();
});
it
(
'
handles duplicate upgrades
'
,
async
()
=>
{
config
.
upgrades
.
push
(
config
.
upgrades
[
0
]);
const
{
prResult
,
pr
}
=
await
prWorker
.
ensurePr
(
config
);
...
...
This diff is collapsed.
Click to expand it.
lib/workers/pr/index.ts
+
6
−
2
View file @
2e72efde
...
...
@@ -161,7 +161,10 @@ export async function ensurePr(
logger
.
debug
(
`Branch is configured for branch automerge, branch status) is:
${
await
getBranchStatus
()}
`
);
if
((
await
getBranchStatus
())
===
BranchStatus
.
yellow
)
{
if
(
config
.
stabilityStatus
!==
BranchStatus
.
yellow
&&
(
await
getBranchStatus
())
===
BranchStatus
.
yellow
)
{
logger
.
debug
(
'
Checking how long this branch has been pending
'
);
const
lastCommitTime
=
await
getBranchLastCommitTime
(
branchName
);
const
currentTime
=
new
Date
();
...
...
@@ -214,7 +217,8 @@ export async function ensurePr(
);
if
(
!
dependencyDashboardCheck
&&
elapsedHours
<
config
.
prNotPendingHours
(
config
.
stabilityStatus
!==
BranchStatus
.
yellow
||
elapsedHours
<
config
.
prNotPendingHours
)
)
{
logger
.
debug
(
`Branch is
${
elapsedHours
}
hours old - skipping PR creation`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment