Skip to content

Commit 2ec4f0a

Browse files
authored
fix(initiate-deployment): don't set commit statuses on merge queue PRs (#694)
1 parent 9dc4581 commit 2ec4f0a

File tree

8 files changed

+9
-207
lines changed

8 files changed

+9
-207
lines changed

.github/workflows/deployments.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ jobs:
5353
helper: delete-deployment
5454
sha: ${{ github.event.pull_request.head.sha }}
5555
environment: test
56+
github_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

dist/264.index.js

Lines changed: 3 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/264.index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42996,13 +42996,11 @@ var map = {
4299642996
"./initiate-deployment": [
4299742997
5264,
4299842998
461,
42999-
366,
4300042999
264
4300143000
],
4300243001
"./initiate-deployment.ts": [
4300343002
5264,
4300443003
461,
43005-
366,
4300643004
264
4300743005
],
4300843006
"./is-user-core-member": [

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/initiate-deployment.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ limitations under the License.
1212
*/
1313

1414
import { DeploymentState } from '../types/github';
15-
import { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS } from '../constants';
15+
import { GITHUB_OPTIONS } from '../constants';
1616
import { HelperInputs } from '../types/generated';
1717
import { context as githubContext } from '@actions/github';
1818
import { octokit } from '../octokit';
19-
import { map } from 'bluebird';
20-
import { getMergeQueueCommitHashes } from '../utils/merge-queue';
2119

2220
export class InitiateDeployment extends HelperInputs {
2321
sha = '';
@@ -31,7 +29,6 @@ export class InitiateDeployment extends HelperInputs {
3129
export const initiateDeployment = async ({
3230
sha,
3331
state = 'in_progress',
34-
context = DEFAULT_PIPELINE_STATUS,
3532
environment,
3633
environment_url,
3734
description,
@@ -58,17 +55,5 @@ export const initiateDeployment = async ({
5855
...GITHUB_OPTIONS
5956
});
6057

61-
const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();
62-
await map(commitHashesForMergeQueueBranches, async sha =>
63-
octokit.repos.createCommitStatus({
64-
sha,
65-
context,
66-
state: 'pending',
67-
description,
68-
target_url,
69-
...githubContext.repo
70-
})
71-
);
72-
7358
return deployment_id;
7459
};

test/helpers/initiate-deployment.test.ts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS } from '../../src/constants';
14+
import { GITHUB_OPTIONS } from '../../src/constants';
1515
import { Mocktokit } from '../types';
1616
import { context } from '@actions/github';
1717
import { initiateDeployment } from '../../src/helpers/initiate-deployment';
@@ -23,7 +23,6 @@ jest.mock('@actions/github', () => ({
2323
getOctokit: jest.fn(() => ({
2424
rest: {
2525
repos: {
26-
createCommitStatus: jest.fn(),
2726
createDeployment: jest.fn(),
2827
createDeploymentStatus: jest.fn(),
2928
listBranches: jest.fn(() => ({ data: [] }))
@@ -81,92 +80,6 @@ describe('initiateDeployment', () => {
8180
});
8281
});
8382

84-
it('should call createCommitStatus with correct params', async () => {
85-
await initiateDeployment({
86-
sha,
87-
environment,
88-
description,
89-
target_url
90-
});
91-
expect(octokit.repos.createCommitStatus).not.toHaveBeenCalledWith({
92-
sha: 'normal sha 1',
93-
context: DEFAULT_PIPELINE_STATUS,
94-
state: 'pending',
95-
description,
96-
target_url,
97-
...context.repo
98-
});
99-
expect(octokit.repos.createCommitStatus).not.toHaveBeenCalledWith({
100-
sha: 'merge queue sha 1',
101-
context: DEFAULT_PIPELINE_STATUS,
102-
state: 'pending',
103-
description,
104-
target_url,
105-
...context.repo
106-
});
107-
expect(octokit.repos.createCommitStatus).not.toHaveBeenCalledWith({
108-
sha: 'merge queue sha 2',
109-
context: DEFAULT_PIPELINE_STATUS,
110-
state: 'pending',
111-
description,
112-
target_url,
113-
...context.repo
114-
});
115-
});
116-
117-
it('should call createCommitStatus with correct params when merge queue branches are present', async () => {
118-
(octokit.repos.listBranches as unknown as Mocktokit).mockImplementation(async ({ page }) =>
119-
page > 1
120-
? { data: [] }
121-
: {
122-
data: [
123-
{
124-
name: 'some-branch',
125-
commit: { sha: 'normal sha 1' }
126-
},
127-
{
128-
name: 'gh-readonly-queue/default-branch/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27',
129-
commit: { sha: 'merge queue sha 1' }
130-
},
131-
{
132-
name: 'gh-readonly-queue/default-branch/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27',
133-
commit: { sha: 'merge queue sha 2' }
134-
}
135-
]
136-
}
137-
);
138-
await initiateDeployment({
139-
sha,
140-
environment,
141-
description,
142-
target_url
143-
});
144-
expect(octokit.repos.createCommitStatus).not.toHaveBeenCalledWith({
145-
sha: 'normal sha 1',
146-
context: DEFAULT_PIPELINE_STATUS,
147-
state: 'pending',
148-
description,
149-
target_url,
150-
...context.repo
151-
});
152-
expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({
153-
sha: 'merge queue sha 1',
154-
context: DEFAULT_PIPELINE_STATUS,
155-
state: 'pending',
156-
description,
157-
target_url,
158-
...context.repo
159-
});
160-
expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({
161-
sha: 'merge queue sha 2',
162-
context: DEFAULT_PIPELINE_STATUS,
163-
state: 'pending',
164-
description,
165-
target_url,
166-
...context.repo
167-
});
168-
});
169-
17083
it('should return deployment id as output', async () => {
17184
const result = await initiateDeployment({
17285
sha,

test/helpers/manage-merge-queue.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jest.mock('../../src/helpers/is-user-in-team');
3333
jest.mock('../../src/helpers/approvals-satisfied');
3434
jest.mock('../../src/helpers/create-pr-comment');
3535
jest.mock('../../src/utils/../../src/helpers/prepare-queued-pr-for-merge');
36+
jest.mock('path');
3637
jest.mock('@actions/core');
3738
jest.mock('@actions/github', () => ({
3839
context: { repo: { repo: 'repo', owner: 'owner' }, issue: { number: 123 }, serverUrl: 'sampleUrl' },

0 commit comments

Comments
 (0)