Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(manage-merge-queue): add debug logging #657

Merged
merged 1 commit into from
Aug 21, 2024
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
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