Skip to content

Commit

Permalink
refactor(manage-merge-queue): add debug logging (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Aug 21, 2024
1 parent 3983efb commit 28f44ef
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 14 deletions.
9 changes: 7 additions & 2 deletions dist/374.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/374.index.js.map

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

4 changes: 3 additions & 1 deletion dist/431.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/431.index.js.map

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions dist/676.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/676.index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/helpers/approvals-satisfied.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export const approvalsSatisfied = async ({
return numberOfApprovals >= Number(numberOfRequiredReviews);
};

logs.push(`Required code owners: ${requiredCodeOwnersEntriesWithOwners.map(({ owners }) => owners).toString()}`);
if (requiredCodeOwnersEntriesWithOwners.length) {
logs.push(`Required code owners: ${requiredCodeOwnersEntriesWithOwners.map(({ owners }) => owners).toString()}`);
}

const booleans = await Promise.all(requiredCodeOwnersEntriesWithOwners.map(codeOwnersEntrySatisfiesApprovals));
const approvalsSatisfied = booleans.every(Boolean);
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/is-user-in-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License.
import { HelperInputs } from '../types/generated';
import { context } from '@actions/github';
import { octokit } from '../octokit';
import * as core from '@actions/core';

export class IsUserInTeam extends HelperInputs {
login? = '';
Expand All @@ -25,5 +26,7 @@ export const isUserInTeam = async ({ login = context.actor, team }: IsUserInTeam
org: context.repo.owner,
team_slug: team
});
core.debug(`Checking if ${login} is in team ${team}`);
core.debug(`Team members: ${response.data.map(({ login }) => login).join(', ')}`);
return response.data.some(({ login: memberLogin }) => memberLogin === login);
};
4 changes: 2 additions & 2 deletions src/helpers/manage-merge-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export const manageMergeQueue = async ({
}
if (pullRequest.labels.find(label => label.name === JUMP_THE_QUEUE_PR_LABEL)) {
if (allow_only_for_maintainers === 'true') {
const isMaintainer = await isUserInTeam({ team: team });
const isMaintainer = await isUserInTeam({ login, team: team });
if (!isMaintainer) {
await removeLabelIfExists(JUMP_THE_QUEUE_PR_LABEL, pullRequest.number);
return await createPrComment({
body: `Only core maintainers can jump the queue. Please have a core maintainer jump the queue for you`
body: `@${login} Only core maintainers can jump the queue. Please have a core maintainer jump the queue for you.`
});
}
}
Expand Down

0 comments on commit 28f44ef

Please sign in to comment.