зеркало из https://github.com/github/combine-prs.git
Коммит
e7a7e2371f
|
@ -33,6 +33,7 @@ As mentioned above is this README, a core reason why this Action exists is to "c
|
|||
| `ignore_label` | The label to ignore when combining PRs | `"nocombine"` | `true` |
|
||||
| `select_label` | The label which marks PRs that should be combined. Leave empty to consider all PRs. | `""` | `false` |
|
||||
| `labels` | A comma separated list of labels to add to the combined PR - Example: `dependencies,combined-pr,etc` | `""` | `false` |
|
||||
| `assignees` | A comma separated list of assignees the combined PR is assigned to - Example: `octocat` | `""` | `false` |
|
||||
| `autoclose` | Whether or not to close combined PRs if the combined PR is merged - can be `"true"` or `"false"` | `"true"` | `false` |
|
||||
| `update_branch` | Whether or not to update the combined branch with the latest changes from the base branch after creating the combined pull request | `"true"` | `false` |
|
||||
| `create_from_scratch` | Whether or not to start from a clean base branch when (re)creating the combined PR | `"false"` | `false` |
|
||||
|
|
|
@ -49,6 +49,7 @@ beforeEach(() => {
|
|||
process.env.GITHUB_REPOSITORY = 'test-owner/test-repo'
|
||||
process.env.INPUT_MIN_COMBINE_NUMBER = '2'
|
||||
process.env.INPUT_LABELS = ''
|
||||
process.env.INPUT_ASSIGNEES = ''
|
||||
process.env.INPUT_AUTOCLOSE = 'true'
|
||||
process.env.INPUT_UPDATE_BRANCH = 'true'
|
||||
process.env.INPUT_CREATE_FROM_SCRATCH = 'false'
|
||||
|
@ -1773,6 +1774,88 @@ test('runs the action and fails to create a working branch', async () => {
|
|||
expect(setFailedMock).toHaveBeenCalledWith('Failed to create working branch')
|
||||
})
|
||||
|
||||
test('successfully runs the action and sets assignees', async () => {
|
||||
jest.spyOn(github, 'getOctokit').mockImplementation(() => {
|
||||
return {
|
||||
paginate: jest.fn().mockImplementation(() => {
|
||||
return [
|
||||
buildPR(1, 'dependabot-1', ['question']),
|
||||
buildPR(2, 'dependabot-2')
|
||||
]
|
||||
}),
|
||||
graphql: jest.fn().mockImplementation((_query, params) => {
|
||||
switch (params.pull_number) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return buildStatusResponse('APPROVED', 'SUCCESS')
|
||||
case 4:
|
||||
return buildStatusResponse('APPROVED', 'FAILURE')
|
||||
case 5:
|
||||
return buildStatusResponse(null, 'SUCCESS')
|
||||
case 6:
|
||||
return buildStatusResponse('REVIEW_REQUIRED', 'SUCCESS')
|
||||
default:
|
||||
throw new Error(
|
||||
`params.pull_number of ${params.pull_number} is not configured.`
|
||||
)
|
||||
}
|
||||
}),
|
||||
rest: {
|
||||
issues: {
|
||||
addAssignees: jest.fn().mockReturnValueOnce({
|
||||
data: {}
|
||||
}),
|
||||
addLabels: jest.fn().mockReturnValueOnce({
|
||||
data: {}
|
||||
})
|
||||
},
|
||||
git: {
|
||||
createRef: jest.fn().mockReturnValueOnce({
|
||||
data: {}
|
||||
}),
|
||||
updateRef: jest.fn().mockReturnValueOnce({
|
||||
data: {}
|
||||
}),
|
||||
getRef: jest.fn().mockReturnValueOnce({
|
||||
data: {
|
||||
object: {
|
||||
sha: randomSha1()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
repos: {
|
||||
// mock the first value of merge to be a success and the second to be an exception
|
||||
merge: jest.fn().mockReturnValueOnce({
|
||||
data: {
|
||||
merged: true
|
||||
}
|
||||
})
|
||||
},
|
||||
pulls: {
|
||||
create: jest.fn().mockReturnValueOnce({
|
||||
data: {
|
||||
number: 100,
|
||||
html_url: 'https://github.com/test-owner/test-repo/pull/100'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
process.env.INPUT_REVIEW_REQUIRED = 'true'
|
||||
process.env.INPUT_ASSIGNEES = 'octocat ,another-user, kolossal'
|
||||
expect(await run()).toBe('success')
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Adding assignees to combined PR: octocat,another-user,kolossal`
|
||||
)
|
||||
|
||||
expect(setOutputMock).toHaveBeenCalledWith('pr_number', 100)
|
||||
})
|
||||
|
||||
function buildStatusResponse(reviewDecision, ciStatus) {
|
||||
return {
|
||||
repository: {
|
||||
|
|
|
@ -53,6 +53,10 @@ inputs:
|
|||
description: A comma seperated list of labels to add to the combined PR
|
||||
required: false
|
||||
default: ""
|
||||
assignees:
|
||||
description: A comma seperated list of assignees to add to the combined PR
|
||||
required: false
|
||||
default: ""
|
||||
autoclose:
|
||||
description: Whether or not to close combined PRs if the combined PR is merged
|
||||
required: false
|
||||
|
|
|
@ -31263,6 +31263,7 @@ async function run() {
|
|||
const ignoreLabel = core.getInput('ignore_label')
|
||||
const selectLabel = core.getInput('select_label')
|
||||
const labels = core.getInput('labels').trim()
|
||||
const assignees = core.getInput('assignees').trim()
|
||||
const token = core.getInput('github_token', {required: true})
|
||||
const prTitle = core.getInput('pr_title', {required: true})
|
||||
const prBodyHeader = core.getInput('pr_body_header', {required: true})
|
||||
|
@ -31541,6 +31542,22 @@ async function run() {
|
|||
}
|
||||
}
|
||||
|
||||
if (assignees !== '') {
|
||||
// split and trim assignees
|
||||
const assigneesArray = assignees.split(',').map(label => label.trim())
|
||||
|
||||
// add assignees to the combined PR if specified
|
||||
if (assigneesArray.length > 0) {
|
||||
core.info(`Adding assignees to combined PR: ${assigneesArray}`)
|
||||
await octokit.rest.issues.addAssignees({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
issue_number: pullRequest.data.number,
|
||||
assignees: assigneesArray
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// lastly, if the pull request's branch can be updated cleanly, update it
|
||||
if (updateBranch === true) {
|
||||
core.info('Attempting to update branch')
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
17
src/main.js
17
src/main.js
|
@ -17,6 +17,7 @@ export async function run() {
|
|||
const ignoreLabel = core.getInput('ignore_label')
|
||||
const selectLabel = core.getInput('select_label')
|
||||
const labels = core.getInput('labels').trim()
|
||||
const assignees = core.getInput('assignees').trim()
|
||||
const token = core.getInput('github_token', {required: true})
|
||||
const prTitle = core.getInput('pr_title', {required: true})
|
||||
const prBodyHeader = core.getInput('pr_body_header', {required: true})
|
||||
|
@ -295,6 +296,22 @@ export async function run() {
|
|||
}
|
||||
}
|
||||
|
||||
if (assignees !== '') {
|
||||
// split and trim assignees
|
||||
const assigneesArray = assignees.split(',').map(label => label.trim())
|
||||
|
||||
// add assignees to the combined PR if specified
|
||||
if (assigneesArray.length > 0) {
|
||||
core.info(`Adding assignees to combined PR: ${assigneesArray}`)
|
||||
await octokit.rest.issues.addAssignees({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: pullRequest.data.number,
|
||||
assignees: assigneesArray
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// lastly, if the pull request's branch can be updated cleanly, update it
|
||||
if (updateBranch === true) {
|
||||
core.info('Attempting to update branch')
|
||||
|
|
Загрузка…
Ссылка в новой задаче