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
6a784366
Unverified
Commit
6a784366
authored
Jun 14, 2022
by
Tobias
Committed by
GitHub
Jun 14, 2022
Browse files
Options
Downloads
Patches
Plain Diff
feat(github): enable platformAutomerge feature for GHES>=3.3 (#15924)
parent
572a01b4
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/modules/platform/github/index.spec.ts
+88
-0
88 additions, 0 deletions
lib/modules/platform/github/index.spec.ts
lib/modules/platform/github/index.ts
+21
-2
21 additions, 2 deletions
lib/modules/platform/github/index.ts
with
109 additions
and
2 deletions
lib/modules/platform/github/index.spec.ts
+
88
−
0
View file @
6a784366
...
...
@@ -2338,6 +2338,94 @@ describe('modules/platform/github/index', () => {
]);
});
it
(
'
should skip automerge if GHE <3.3.0
'
,
async
()
=>
{
const
scope
=
httpMock
.
scope
(
'
https://github.company.com
'
)
.
head
(
'
/
'
)
.
reply
(
200
,
''
,
{
'
x-github-enterprise-version
'
:
'
3.1.7
'
})
.
get
(
'
/user
'
)
.
reply
(
200
,
{
login
:
'
renovate-bot
'
,
})
.
get
(
'
/user/emails
'
)
.
reply
(
200
,
{})
.
post
(
'
/repos/some/repo/pulls
'
)
.
reply
(
200
,
{
number
:
123
,
})
.
post
(
'
/repos/some/repo/issues/123/labels
'
)
.
reply
(
200
,
[]);
initRepoMock
(
scope
,
'
some/repo
'
);
await
github
.
initPlatform
({
endpoint
:
'
https://github.company.com
'
,
token
:
'
123test
'
,
});
hostRules
.
find
.
mockReturnValue
({
token
:
'
123test
'
,
});
await
github
.
initRepo
({
repository
:
'
some/repo
'
,
}
as
any
);
await
github
.
createPr
(
prConfig
);
expect
(
logger
.
logger
.
debug
).
toHaveBeenNthCalledWith
(
10
,
{
prNumber
:
123
},
'
GitHub-native automerge: not supported on this GHE version. Requires >=3.3.0
'
);
});
it
(
'
should perform automerge if GHE >=3.3.0
'
,
async
()
=>
{
const
scope
=
httpMock
.
scope
(
'
https://github.company.com
'
)
.
head
(
'
/
'
)
.
reply
(
200
,
''
,
{
'
x-github-enterprise-version
'
:
'
3.3.5
'
})
.
get
(
'
/user
'
)
.
reply
(
200
,
{
login
:
'
renovate-bot
'
,
})
.
get
(
'
/user/emails
'
)
.
reply
(
200
,
{})
.
post
(
'
/repos/some/repo/pulls
'
)
.
reply
(
200
,
{
number
:
123
,
})
.
post
(
'
/repos/some/repo/issues/123/labels
'
)
.
reply
(
200
,
[])
.
post
(
'
/graphql
'
)
.
reply
(
200
,
{
data
:
{
repository
:
{
defaultBranchRef
:
{
name
:
'
main
'
,
},
nameWithOwner
:
'
some/repo
'
,
autoMergeAllowed
:
true
,
},
},
});
initRepoMock
(
scope
,
'
some/repo
'
);
await
github
.
initPlatform
({
endpoint
:
'
https://github.company.com
'
,
token
:
'
123test
'
,
});
hostRules
.
find
.
mockReturnValue
({
token
:
'
123test
'
,
});
await
github
.
initRepo
({
repository
:
'
some/repo
'
,
}
as
any
);
await
github
.
createPr
(
prConfig
);
expect
(
logger
.
logger
.
debug
).
toHaveBeenNthCalledWith
(
11
,
{
prNumber
:
123
},
'
GitHub-native automerge: success
'
);
});
it
(
'
should set automatic merge
'
,
async
()
=>
{
const
scope
=
await
mockScope
();
scope
.
post
(
'
/graphql
'
).
reply
(
200
,
graphqlAutomergeResp
);
...
...
This diff is collapsed.
Click to expand it.
lib/modules/platform/github/index.ts
+
21
−
2
View file @
6a784366
...
...
@@ -269,7 +269,13 @@ export async function initRepo({
try
{
let
infoQuery
=
repoInfoQuery
;
if
(
platformConfig
.
isGhe
)
{
// GitHub Enterprise Server <3.3.0 doesn't support autoMergeAllowed and hasIssuesEnabled objects
if
(
platformConfig
.
isGhe
&&
// semver not null safe, accepts null and undefined
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
semver
.
satisfies
(
platformConfig
.
gheVersion
!
,
'
<3.3.0
'
)
)
{
infoQuery
=
infoQuery
.
replace
(
/
\n\s
*autoMergeAllowed
\s
*
\n
/
,
'
\n
'
);
infoQuery
=
infoQuery
.
replace
(
/
\n\s
*hasIssuesEnabled
\s
*
\n
/
,
'
\n
'
);
}
...
...
@@ -1323,10 +1329,23 @@ async function tryPrAutomerge(
prNodeId
:
string
,
platformOptions
:
PlatformPrOptions
|
undefined
):
Promise
<
void
>
{
if
(
platformConfig
.
isGhe
||
!
platformOptions
?.
usePlatformAutomerge
)
{
if
(
!
platformOptions
?.
usePlatformAutomerge
)
{
return
;
}
// If GitHub Enterprise Server <3.3.0 it doesn't support automerge
if
(
platformConfig
.
isGhe
)
{
// semver not null safe, accepts null and undefined
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
if
(
semver
.
satisfies
(
platformConfig
.
gheVersion
!
,
'
<3.3.0
'
))
{
logger
.
debug
(
{
prNumber
},
'
GitHub-native automerge: not supported on this GHE version. Requires >=3.3.0
'
);
return
;
}
}
if
(
!
config
.
autoMergeAllowed
)
{
logger
.
debug
(
{
prNumber
},
...
...
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