Skip to content

Commit 74a3ed1

Browse files
authored
Merge pull request #127 from adobe/remove-magento-team-check
DEVX-311: Update Adobe CLA bot
2 parents 4090cb7 + b7b2f9c commit 74a3ed1

File tree

3 files changed

+10
-124
lines changed

3 files changed

+10
-124
lines changed

checker/checker.js

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ const utils = require('../utils.js');
1717
const config = utils.get_config();
1818
/*
1919
gets fired from github pr creation/update webhook.
20-
* Check if they are adobe/magento employee, if yes, give checkmark
20+
* Check if they are adobe employee, if yes, give checkmark
2121
* If not an employee, report back if the CLA is already signed
2222
* if signed, give checkmark
2323
* if not signed, give an 'x' and tell them to go sign at https://opensource.adobe.com/cla.html
2424
*/
2525
const valid_pr_events = ['opened', 'reopened', 'synchronize'];
26-
const MAGENTO_EMPLOYEES_TEAM = 2032477;
2726

2827
async function main (params) {
2928
if (!params.pull_request || !valid_pr_events.includes(params.action)) {
@@ -66,27 +65,11 @@ async function main (params) {
6665
return utils.action_error(e, 'Error retrieving GitHub API instance on behalf of app installation.');
6766
}
6867

69-
// Check if author is employee; this has separate logic for Adobe vs. Magento
70-
// employees.
68+
// Check if author is employee.
7169
let is_employee;
7270
if (org === 'magento') {
73-
// For the magento org, we need to see if the user is a member of the
74-
// magento-employees team to determine whether they are an employee
75-
// m.then(gh => gh.teams.getMembership({ team_id: teamId, username: user }).then(result => console.log(`${user} is a ${result.data.state} ${result.data.role} of the magento-employees team`)).catch(err => { console.error(`${user} got membership in magento-employees team result of "${err.message}"!`); }));
76-
try {
77-
is_employee = await github.teams.getMembership({
78-
team_id: MAGENTO_EMPLOYEES_TEAM,
79-
username: user
80-
});
81-
} catch (e) {
82-
if (e.message.includes('Not Found')) {
83-
const res = await check_cla(ow, args);
84-
return res;
85-
} else {
86-
return utils.action_error(e, 'Error during checking of Magento employees membership in the Magento org.');
87-
}
88-
}
89-
const res = await set_green_is_adobe_employee(ow, args, org);
71+
// For the magento org, we want everyone to sign the CLA
72+
const res = await check_cla(ow, args);
9073
return res;
9174
} else {
9275
// For non-Magento orgs, as long as user is a member of the org, they are
@@ -130,7 +113,7 @@ async function main (params) {
130113
// the promise.
131114
// more details here: https://developer.github.com/v3/orgs/members/#check-public-membership
132115
if (public_member.status === 204) {
133-
const res = await set_green_is_adobe_employee(ow, args);
116+
const res = await set_green_is_adobe_employee(ow, args, 'adobe');
134117
return res;
135118
}
136119
} else {
@@ -285,12 +268,8 @@ async function set_green_is_bot (ow, args) {
285268
}
286269

287270
async function set_green_is_adobe_employee (ow, args, membership_org) {
288-
let company = 'Adobe';
289-
let reason = `membership in github.com/${membership_org}`;
290-
if (membership_org === 'magento') {
291-
company += ' (Magento)';
292-
reason = `membership in github.com/magento's employees team`;
293-
}
271+
const company = 'Adobe';
272+
const reason = `membership in github.com/${membership_org}`;
294273
let result;
295274
try {
296275
result = await ow.actions.invoke({

test/integration/github.test.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -134,61 +134,6 @@ describe('github integration tests', () => {
134134
await teardown();
135135
});
136136
});
137-
describe('pull requests from user who is a member of the adobe or magento orgs (and magento-employees team) (account adobeiotest4)', () => {
138-
const user = 'adobeiotest4';
139-
const newBranch = '' + new Date().valueOf();
140-
const github = new Octokit({
141-
auth: process.env.TEST_FOUR_PAC
142-
});
143-
it('should approve a pull request to an adobe repo', async () => {
144-
const setup = createBranch(github, user, ADOBE_REPO, newBranch);
145-
await setup();
146-
console.log(`Creating pull request to adobe/${ADOBE_REPO}...`);
147-
const pr = await github.pulls.create({
148-
owner: 'adobe',
149-
repo: ADOBE_REPO,
150-
title: `testing build ${newBranch}`,
151-
head: `${user}:${newBranch}`,
152-
base: 'master'
153-
});
154-
const suite = await waitForCheck(github, 'adobe', ADOBE_REPO, pr.data.head.sha);
155-
expect(suite.conclusion).toEqual('success');
156-
const teardown = deleteBranch(github, user, ADOBE_REPO, newBranch);
157-
await teardown();
158-
});
159-
it('should approve a pull request to a private magento repo', async () => {
160-
const setup = createBranch(github, user, PRIVATE_MAGENTO_REPO, newBranch);
161-
await setup();
162-
console.log(`Creating pull request to magento/${PRIVATE_MAGENTO_REPO}...`);
163-
const pr = await github.pulls.create({
164-
owner: 'magento',
165-
repo: PRIVATE_MAGENTO_REPO,
166-
title: `testing build ${newBranch}`,
167-
head: `${user}:${newBranch}`,
168-
base: 'master'
169-
});
170-
const suite = await waitForCheck(github, 'magento', PRIVATE_MAGENTO_REPO, pr.data.head.sha);
171-
expect(suite.conclusion).toEqual('success');
172-
const teardown = deleteBranch(github, user, PRIVATE_MAGENTO_REPO, newBranch);
173-
await teardown();
174-
});
175-
it('should approve a pull request to a public magento repo', async () => {
176-
const setup = createBranch(github, user, PUBLIC_MAGENTO_REPO, newBranch);
177-
await setup();
178-
console.log(`Creating pull request to magento/${PUBLIC_MAGENTO_REPO}...`);
179-
const pr = await github.pulls.create({
180-
owner: 'magento',
181-
repo: PUBLIC_MAGENTO_REPO,
182-
title: `testing build ${newBranch}`,
183-
head: `${user}:${newBranch}`,
184-
base: 'master'
185-
});
186-
const suite = await waitForCheck(github, 'magento', PUBLIC_MAGENTO_REPO, pr.data.head.sha);
187-
expect(suite.conclusion).toEqual('success');
188-
const teardown = deleteBranch(github, user, PUBLIC_MAGENTO_REPO, newBranch);
189-
await teardown();
190-
});
191-
});
192137
describe('pull requests from user with a signed Adobe ICLA (account adobeiotest1)', () => {
193138
const user = 'adobeiotest1';
194139
const newBranch = '' + new Date().valueOf();

test/unit/checker.test.js

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ describe('checker action', function () {
4444
orgs: {
4545
checkMembership: jasmine.createSpy('orgs.checkMembership spy'),
4646
checkPublicMembership: jasmine.createSpy('orgs.checkPublicMembership spy')
47-
},
48-
teams: {
49-
getMembership: jasmine.createSpy('team.getMembership spy')
5047
}
5148
};
5249
app_spy = jasmine.createSpy('github app spy').and.returnValue({
@@ -119,7 +116,7 @@ describe('checker action', function () {
119116
expect(response.statusCode).toBe(200);
120117
});
121118
describe('for PRs issued to the magento github organization', () => {
122-
it('should invoke the setgithubcheck action with a status of completed if user is a member of the magento employees team', async function () {
119+
it('should invoke the setgithubcheck action with a status of completed if user has signed a cla', async function () {
123120
const params = {
124121
pull_request: {
125122
user: { login: 'hiren' },
@@ -134,35 +131,6 @@ describe('checker action', function () {
134131
action: 'opened',
135132
installation: { id: '5431' }
136133
};
137-
github_api_stub.teams.getMembership.and.returnValue(Promise.resolve({
138-
status: 204
139-
}));
140-
openwhisk_stub.actions.invoke.and.returnValue(Promise.resolve({}));
141-
const response = await checker.main(params);
142-
const action_invoke_args = openwhisk_stub.actions.invoke.calls.mostRecent().args[0];
143-
expect(action_invoke_args.name).toBe('cla-setgithubcheck');
144-
expect(action_invoke_args.params.status).toBe('completed');
145-
expect(action_invoke_args.params.title).toContain('Adobe (Magento) Employee');
146-
expect(response.statusCode).toBe(200);
147-
});
148-
it('should invoke the setgithubcheck action with a status of completed if user is not a member of the magento org but has signed a cla', async function () {
149-
const params = {
150-
pull_request: {
151-
user: { login: 'hiren' },
152-
base: {
153-
repo: {
154-
owner: { login: 'magento' },
155-
name: 'magento2'
156-
}
157-
},
158-
head: { sha: '12345' }
159-
},
160-
action: 'opened',
161-
installation: { id: '5431' }
162-
};
163-
github_api_stub.teams.getMembership.and.returnValue(Promise.reject({
164-
message: 'Not Found'
165-
}));
166134
request_spy.and.callFake(function (options) {
167135
if (options.url.includes('agreements')) {
168136
return Promise.resolve({
@@ -195,7 +163,7 @@ describe('checker action', function () {
195163
expect(action_invoke_args.params.title).toContain('CLA Signed');
196164
expect(response.statusCode).toBe(200);
197165
});
198-
it(`should invoke the setgithubcheck action with a conclusion of action_required if user is not a member of the magento org and no agreements are found containing the user's github username`, async function () {
166+
it(`should invoke the setgithubcheck action with a conclusion of action_required if user no agreements are found containing the user's github username`, async function () {
199167
const params = {
200168
pull_request: {
201169
user: { login: 'hiren' },
@@ -210,9 +178,6 @@ describe('checker action', function () {
210178
action: 'opened',
211179
installation: { id: '5431' }
212180
};
213-
github_api_stub.teams.getMembership.and.returnValue(Promise.reject({
214-
message: 'Not Found'
215-
}));
216181
request_spy.and.callFake(function (options) {
217182
if (options.url.includes('agreements')) {
218183
return Promise.resolve({
@@ -245,7 +210,7 @@ describe('checker action', function () {
245210
expect(action_invoke_args.params.title).toContain('Sign the Adobe CLA');
246211
expect(response.statusCode).toBe(200);
247212
});
248-
it('should invoke the setgithubcheck action with a conclusion of action_required if user is not a member of the magento org and zero signed CLAs exist', async function () {
213+
it('should invoke the setgithubcheck action with a conclusion of action_required if zero signed CLAs exist', async function () {
249214
const params = {
250215
pull_request: {
251216
user: { login: 'hiren' },
@@ -260,9 +225,6 @@ describe('checker action', function () {
260225
action: 'opened',
261226
installation: { id: '5431' }
262227
};
263-
github_api_stub.teams.getMembership.and.returnValue(Promise.reject({
264-
message: 'Not Found'
265-
}));
266228
request_spy.and.callFake(function (options) {
267229
if (options.url.includes('agreements')) {
268230
return Promise.resolve({ userAgreementList: [] });

0 commit comments

Comments
 (0)