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
12 changes: 2 additions & 10 deletions .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions ng-dev/caretaker/check/ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class CiModule extends BaseModule<CiData> {
override async printToTerminal() {
const data = await this.data;
const minLabelLength = Math.max(...data.map((result) => result.label.length));
Log.info.group(bold(`CI`));
Log.info(bold(`CI`));
data.forEach((result) => {
if (result.active === false) {
Log.debug(`No active release train for ${result.name}`);
Expand All @@ -93,7 +93,6 @@ export class CiModule extends BaseModule<CiData> {
Log.info(`${label} ${red('✘')}`);
}
});
Log.info.groupEnd();
Log.info();
}
}
3 changes: 1 addition & 2 deletions ng-dev/caretaker/check/g3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class G3Module extends BaseModule<G3StatsData | void> {
if (!stats) {
return;
}
Log.info.group(bold('g3 branch check'));
Log.info(bold('g3 branch check'));
if (stats.files === 0 && stats.separateFiles === 0) {
Log.info(`${stats.commits} commits between g3 and ${this.git.mainBranchName}`);
Log.info(` ${green('✔')} No sync is needed at this time`);
Expand All @@ -39,7 +39,6 @@ export class G3Module extends BaseModule<G3StatsData | void> {
`deletions(-) from ${stats.commits} commits will be included in the next sync`,
);
}
Log.info.groupEnd();
Log.info();
}
}
10 changes: 3 additions & 7 deletions ng-dev/caretaker/check/github.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import {GithubQueriesModule} from './github.js';
describe('GithubQueriesModule', () => {
let githubApiSpy: jasmine.Spy;
let infoSpy: jasmine.Spy;
let infoGroupSpy: jasmine.Spy;
let git: AuthenticatedGitClient;

beforeEach(async () => {
githubApiSpy = spyOn(AuthenticatedGithubClient.prototype, 'graphql').and.throwError(
'The graphql query response must always be manually defined in a test.',
);
installVirtualGitClientSpies();
infoGroupSpy = spyOn(Log.info, 'group');
infoSpy = spyOn(Log, 'info');
git = await AuthenticatedGitClient.get();
});
Expand Down Expand Up @@ -108,7 +106,7 @@ describe('GithubQueriesModule', () => {

await module.printToTerminal();

expect(infoGroupSpy).toHaveBeenCalledWith('Github Tasks');
expect(infoSpy).toHaveBeenCalledWith('Github Tasks');
expect(infoSpy).toHaveBeenCalledWith('query1 0');
expect(infoSpy).toHaveBeenCalledWith('query2 0');
});
Expand All @@ -134,11 +132,9 @@ describe('GithubQueriesModule', () => {

await module.printToTerminal();

expect(infoGroupSpy).toHaveBeenCalledWith('Github Tasks');
expect(infoSpy).toHaveBeenCalledWith('Github Tasks');
expect(infoSpy).toHaveBeenCalledWith('query1 1');
expect(infoGroupSpy).toHaveBeenCalledWith(
'https://github.com/owner/name/issues?q=issue:%20yes',
);
expect(infoSpy).toHaveBeenCalledWith('https://github.com/owner/name/issues?q=issue:%20yes');
expect(infoSpy).toHaveBeenCalledWith('- http://github.com/owner/name/issue/1');
expect(infoSpy).toHaveBeenCalledWith('query2 0');
});
Expand Down
6 changes: 2 additions & 4 deletions ng-dev/caretaker/check/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,19 @@ export class GithubQueriesModule extends BaseModule<GithubQueryResults | void> {
if (!queryResults) {
return;
}
Log.info.group(bold('Github Tasks'));
Log.info(bold('Github Tasks'));
const minQueryNameLength = Math.max(...queryResults.map((result) => result.queryName.length));
for (const queryResult of queryResults) {
Log.info(`${queryResult.queryName.padEnd(minQueryNameLength)} ${queryResult.count}`);

if (queryResult.count > 0) {
Log.info.group(queryResult.queryUrl);
Log.info(queryResult.queryUrl);
queryResult.matchedUrls.forEach((url) => Log.info(`- ${url}`));
if (queryResult.count > MAX_RETURNED_ISSUES) {
Log.info(`... ${queryResult.count - MAX_RETURNED_ISSUES} additional matches`);
}
Log.info.groupEnd();
}
}
Log.info.groupEnd();
Log.info();
}
}
6 changes: 2 additions & 4 deletions ng-dev/caretaker/check/services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {services, ServicesModule} from './services.js';
describe('ServicesModule', () => {
let getStatusFromStandardApiSpy: jasmine.Spy;
let infoSpy: jasmine.Spy;
let infoGroupSpy: jasmine.Spy;
let git: AuthenticatedGitClient;

services.splice(0, Infinity, {
Expand All @@ -27,7 +26,6 @@ describe('ServicesModule', () => {
beforeEach(async () => {
getStatusFromStandardApiSpy = spyOn(ServicesModule.prototype, 'getStatusFromStandardApi');
installVirtualGitClientSpies();
infoGroupSpy = spyOn(Log.info, 'group');
infoSpy = spyOn(Log, 'info');
git = await AuthenticatedGitClient.get();
});
Expand Down Expand Up @@ -67,9 +65,9 @@ describe('ServicesModule', () => {
Object.defineProperty(module, 'data', {value: fakeData});
await module.printToTerminal();

expect(infoGroupSpy).toHaveBeenCalledWith('Service Statuses');
expect(infoSpy).toHaveBeenCalledWith('Service Statuses');
expect(infoSpy).toHaveBeenCalledWith(`Service 1 ${green('✔')}`);
expect(infoGroupSpy).toHaveBeenCalledWith(
expect(infoSpy).toHaveBeenCalledWith(
`Service 2 ${red('✘')} (Updated: ${new Date(0).toLocaleString()})`,
);
expect(infoSpy).toHaveBeenCalledWith(' Details: Literally everything is broken');
Expand Down
6 changes: 2 additions & 4 deletions ng-dev/caretaker/check/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ export class ServicesModule extends BaseModule<StatusCheckResult[]> {
override async printToTerminal() {
const statuses = await this.data;
const serviceNameMinLength = Math.max(...statuses.map((service) => service.name.length));
Log.info.group(bold('Service Statuses'));
Log.info(bold('Service Statuses'));
for (const status of statuses) {
const name = status.name.padEnd(serviceNameMinLength);
if (status.status === 'passing') {
Log.info(`${name} ${green('✔')}`);
} else {
Log.info.group(`${name} ${red('✘')} (Updated: ${status.lastUpdated.toLocaleString()})`);
Log.info(`${name} ${red('✘')} (Updated: ${status.lastUpdated.toLocaleString()})`);
Log.info(` Details: ${status.description}`);
Log.info(` Status URL: ${status.statusUrl}`);
Log.info.groupEnd();
}
}
Log.info.groupEnd();
Log.info();
}

Expand Down
3 changes: 1 addition & 2 deletions ng-dev/caretaker/handoff/update-github-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ async function setCaretakerGroup(group: string, members: string[]) {
});
};

Log.debug.group(`Caretaker Group: ${fullSlug}`);
Log.debug(`Caretaker Group: ${fullSlug}`);
Log.debug(`Current Membership: ${current.join(', ')}`);
Log.debug(`New Membership: ${members.join(', ')}`);
Log.debug(`Removed: ${removed.join(', ')}`);
Log.debug.groupEnd();

// Add members before removing to prevent the account performing the action from removing their
// permissions to change the group membership early.
Expand Down
3 changes: 1 addition & 2 deletions ng-dev/commit-message/validate-range/validate-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export async function validateCommitRange(from: string, to: string): Promise<voi
} else {
Log.error('✘ Invalid commit message');
errors.forEach(([header, validationErrors]) => {
Log.error.group(header);
Log.error(header);
printValidationErrors(validationErrors);
Log.error.groupEnd();
});
// Exit with a non-zero exit code if invalid commit messages have
// been discovered.
Expand Down
3 changes: 1 addition & 2 deletions ng-dev/commit-message/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ export async function validateCommitMessage(

/** Print the error messages from the commit message validation to the console. */
export function printValidationErrors(errors: string[], print = Log.error) {
print.group(`Error${errors.length === 1 ? '' : 's'}:`);
print(`Error${errors.length === 1 ? '' : 's'}:`);
errors.forEach((line) => print(line));
print.groupEnd();
print();
print('The expected format for a commit is: ');
print('<type>(<scope>): <summary>');
Expand Down
3 changes: 1 addition & 2 deletions ng-dev/format/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ export async function checkFiles(files: string[]) {

if (failures.length) {
// Provide output expressing which files are failing formatting.
Log.warn.group('\nThe following files are out of format:');
Log.warn('\nThe following files are out of format:');
for (const {filePath} of failures) {
Log.warn(` • ${filePath}`);
}
Log.warn.groupEnd();
Log.warn();

// If the command is run in a non-CI environment, prompt to format the files immediately.
Expand Down
3 changes: 1 addition & 2 deletions ng-dev/misc/generated-files/update-generated-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export async function updateGeneratedFileTargets(): Promise<void> {
.split(/\r?\n/)
.map((x) => x.replace(/_generated$/, ''));

Log.debug.group('Discovered Targets');
Log.debug('Discovered Targets');
targets.forEach((target) => Log.debug(target));
Log.debug.groupEnd();

spinner.update(`Found ${targets.length} generated file targets to update`);

Expand Down
3 changes: 1 addition & 2 deletions ng-dev/pr/check-target-branches/check-target-branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export async function printTargetBranchesForPr(prNumber: number) {

const target = await getTargetBranchesForPr(prNumber, config);
Log.info(`PR has the following target label: ${target.label.name}`);
Log.info.group(`PR #${prNumber} will merge into:`);
Log.info(`PR #${prNumber} will merge into:`);
target.branches.forEach((name) => Log.info(`- ${name}`));
Log.info.groupEnd();
}
3 changes: 1 addition & 2 deletions ng-dev/pr/discover-new-conflicts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ export async function discoverNewConflictsForPr(newPrNumber: number, updatedAfte
}

// Inform about discovered conflicts, exit with failure.
Log.error.group(`${conflicts.length} PR(s) which conflict(s) after #${newPrNumber} merges:`);
Log.error(`${conflicts.length} PR(s) which conflict(s) after #${newPrNumber} merges:`);
for (const pr of conflicts) {
Log.error(` - #${pr.number}: ${pr.title}`);
}
Log.error.groupEnd();
process.exit(1);
}
3 changes: 1 addition & 2 deletions ng-dev/pullapprove/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function logGroup(
printMessageFn = Log.info,
) {
const conditions = group[conditionsToPrint];
printMessageFn.group(`[${group.groupName}]`);
printMessageFn(`[${group.groupName}]`);
if (conditions.length) {
conditions.forEach((groupCondition) => {
const count = groupCondition.matchedFiles.size;
Expand All @@ -33,7 +33,6 @@ export function logGroup(
);
}
});
printMessageFn.groupEnd();
}
}

Expand Down
25 changes: 7 additions & 18 deletions ng-dev/pullapprove/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,45 +76,34 @@ export async function verify() {
if (groupsWithoutReviewers.length === 0) {
Log.info('All group contain at least one reviewer user or team.');
} else {
Log.info.group(
`Discovered ${groupsWithoutReviewers.length} group(s) without a reviewer defined`,
);
Log.info(`Discovered ${groupsWithoutReviewers.length} group(s) without a reviewer defined`);
groupsWithoutReviewers.forEach((g) => Log.info(g.groupName));
Log.info.groupEnd();
}
/**
* File by file Summary
*/
logHeader('PullApprove results by file');
Log.info.group(`Matched Files (${matchedFiles.length} files)`);
Log.info(`Matched Files (${matchedFiles.length} files)`);
matchedFiles.forEach((file) => Log.debug(file));
Log.info.groupEnd();
Log.info.group(`Unmatched Files (${unmatchedFiles.length} files)`);
Log.info(`Unmatched Files (${unmatchedFiles.length} files)`);
unmatchedFiles.forEach((file) => Log.info(file));
Log.info.groupEnd();
/**
* Group by group Summary
*/
logHeader('PullApprove results by group');
Log.info.group(`Groups skipped (${groupsSkipped.length} groups)`);
Log.info(`Groups skipped (${groupsSkipped.length} groups)`);
groupsSkipped.forEach((group) => Log.debug(`${group.groupName}`));
Log.info.groupEnd();
const matchedGroups = resultsByGroup.filter((group) => !group.unmatchedCount);
Log.info.group(`Matched conditions by Group (${matchedGroups.length} groups)`);
Log.info(`Matched conditions by Group (${matchedGroups.length} groups)`);
matchedGroups.forEach((group) => logGroup(group, 'matchedConditions', Log.debug));
Log.info.groupEnd();
const unmatchedGroups = resultsByGroup.filter((group) => group.unmatchedCount);
Log.info.group(`Unmatched conditions by Group (${unmatchedGroups.length} groups)`);
Log.info(`Unmatched conditions by Group (${unmatchedGroups.length} groups)`);
unmatchedGroups.forEach((group) => logGroup(group, 'unmatchedConditions'));
Log.info.groupEnd();
const unverifiableConditionsInGroups = resultsByGroup.filter(
(group) => group.unverifiableConditions.length > 0,
);
Log.info.group(
`Unverifiable conditions by Group (${unverifiableConditionsInGroups.length} groups)`,
);
Log.info(`Unverifiable conditions by Group (${unverifiableConditionsInGroups.length} groups)`);
unverifiableConditionsInGroups.forEach((group) => logGroup(group, 'unverifiableConditions'));
Log.info.groupEnd();

// Provide correct exit code based on verification success.
process.exit(overallResult ? 0 : 1);
Expand Down
15 changes: 1 addition & 14 deletions ng-dev/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,14 @@ function buildLogLevelFunction(
defaultColor: ChalkInstance | null,
) {
/** Write to stdout for the LOG_LEVEL. */
const loggingFunction = (...values: unknown[]) => {
return (...values: unknown[]) => {
runConsoleCommand(
loadCommand,
level,
// For string values, apply the default color.
...values.map((v) => (typeof v === 'string' && defaultColor ? defaultColor(v) : v)),
);
};

/** Start a group at the LOG_LEVEL, optionally starting it as collapsed. */
loggingFunction.group = (label: string, collapsed = false) => {
const command = collapsed ? console.groupCollapsed : console.group;
runConsoleCommand(() => command, level, defaultColor ? defaultColor(label) : label);
};

/** End the group at the LOG_LEVEL. */
loggingFunction.groupEnd = () => {
runConsoleCommand(() => console.groupEnd, level);
};

return loggingFunction;
}

/**
Expand Down
Loading