Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions dist/264.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/264.index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/467.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/467.index.js.map

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions src/helpers/initiate-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@ export const initiateDeployment = async ({
...GITHUB_OPTIONS
});

if (githubContext.eventName === 'merge_group') {
const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();
await map(commitHashesForMergeQueueBranches, async sha =>
octokit.repos.createCommitStatus({
sha,
context,
state: 'pending',
description,
target_url,
...githubContext.repo
})
);
}
const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();
await map(commitHashesForMergeQueueBranches, async sha =>
octokit.repos.createCommitStatus({
sha,
context,
state: 'pending',
description,
target_url,
...githubContext.repo
})
);

return deployment_id;
};
3 changes: 2 additions & 1 deletion src/helpers/notify-pipeline-complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const notifyPipelineComplete = async ({
...githubContext.repo
});
const commitHashesForOpenPullRequests = pullRequests.map(pullRequest => pullRequest.head.sha);
const commitHashes = githubContext.eventName === 'merge_group' ? await getMergeQueueCommitHashes() : commitHashesForOpenPullRequests;
const mergeQueueCommitHashes = await getMergeQueueCommitHashes();
const commitHashes = mergeQueueCommitHashes.length ? mergeQueueCommitHashes : commitHashesForOpenPullRequests;
await map(commitHashes, async sha =>
octokit.repos.createCommitStatus({
sha,
Expand Down
47 changes: 23 additions & 24 deletions test/helpers/initiate-deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,7 @@ jest.mock('@actions/github', () => ({
createCommitStatus: jest.fn(),
createDeployment: jest.fn(),
createDeploymentStatus: jest.fn(),
listBranches: jest.fn(({ page }) =>
page > 1
? { data: [] }
: {
data: [
{
name: 'some-branch',
commit: { sha: 'normal sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 2' }
}
]
}
)
listBranches: jest.fn(() => ({ data: [] }))
}
}
}))
Expand Down Expand Up @@ -100,8 +81,7 @@ describe('initiateDeployment', () => {
});
});

it('should call createCommitStatus with correct params on non merge_group event', async () => {
context.eventName = 'some_event';
it('should call createCommitStatus with correct params', async () => {
await initiateDeployment({
sha,
environment,
Expand Down Expand Up @@ -134,8 +114,27 @@ describe('initiateDeployment', () => {
});
});

it('should call createCommitStatus with correct params on merge_group event', async () => {
context.eventName = 'merge_group';
it('should call createCommitStatus with correct params when merge queue branches are present', async () => {
(octokit.repos.listBranches as unknown as Mocktokit).mockImplementation(async ({ page }) =>
page > 1
? { data: [] }
: {
data: [
{
name: 'some-branch',
commit: { sha: 'normal sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 2' }
}
]
}
);
await initiateDeployment({
sha,
environment,
Expand Down
47 changes: 23 additions & 24 deletions test/helpers/notify-pipeline-complete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,7 @@ jest.mock('@actions/github', () => ({
createCommitStatus: jest.fn(),
createDeploymentStatus: jest.fn(),
listDeployments: jest.fn(() => ({ data: [{ id: 123 }] })),
listBranches: jest.fn(({ page }) =>
page > 1
? { data: [] }
: {
data: [
{
name: 'some-branch',
commit: { sha: 'normal sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 2' }
}
]
}
)
listBranches: jest.fn(() => ({ data: [] }))
}
}
}))
Expand All @@ -60,8 +41,7 @@ jest.mock('../../src/helpers/set-deployment-status');
describe('notify-pipeline-complete', () => {
const description = 'Pipeline clear.';

it('should notify that the pipeline is clear on non merge_group event', async () => {
context.eventName = 'some_event';
it('should notify that the pipeline is clear', async () => {
await notifyPipelineComplete({});

expect(octokit.pulls.list).toHaveBeenCalledWith({
Expand Down Expand Up @@ -123,8 +103,27 @@ describe('notify-pipeline-complete', () => {
});
});

it('should notify that the pipeline is clear on merge_group event', async () => {
context.eventName = 'merge_group';
it('should notify that the pipeline is clear when merge queue branches are present', async () => {
(octokit.repos.listBranches as unknown as Mocktokit).mockImplementation(async ({ page }) =>
page > 1
? { data: [] }
: {
data: [
{
name: 'some-branch',
commit: { sha: 'normal sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 1' }
},
{
name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27',
commit: { sha: 'merge queue sha 2' }
}
]
}
);
await notifyPipelineComplete({});

expect(octokit.pulls.list).toHaveBeenCalledWith({
Expand Down
Loading