Skip to content

refactor: Improve logging in processors/action chain#1338

Open
RichardUri wants to merge 5 commits intofinos:mainfrom
RichardUri:main
Open

refactor: Improve logging in processors/action chain#1338
RichardUri wants to merge 5 commits intofinos:mainfrom
RichardUri:main

Conversation

@RichardUri
Copy link

Resolves log data not being recorded due to use of console.log. Now properly uses step.log.
Fixes #1281

@netlify
Copy link

netlify bot commented Jan 8, 2026

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 2d914ea
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/69600b7028eb5a000852c491

@linux-foundation-easycla
Copy link

CLA Not Signed

Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this clean-up. Needs a few small tweaks and cleanup of commented lines.

import { getCommitConfig } from '../../../config';

const isMessageAllowed = (commitMessage: string): boolean => {
const isMessageAllowed = (commitMessage: any): string | null => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix the any

if (!commitMessage) {
console.log('No commit message included...');
return false;
// console.log('No commit message included...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented lines

import { getCommitConfig } from '../../../config';

const isMessageAllowed = (commitMessage: string): boolean => {
const isMessageAllowed = (commitMessage: any): string | null => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment explaining that a string response indicates failure would be good

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also renaming the function to match output style, e.g. to checkCommitMessage

if (typeof commitMessage !== 'string') {
console.log('A non-string value has been captured for the commit message...');
return false;
// console.log('A non-string value has been captured for the commit message...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented lines

if (literalMatches.length || patternMatches.length) {
console.log('Commit message is blocked via configured literals/patterns...');
return false;
// console.log('Commit message is blocked via configured literals/patterns...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented lines

console.log('Invalid regex pattern...');
return false;
// console.log('Invalid regex pattern...');
return 'Invalid regex pattern...';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 'Invalid regex pattern...';
return 'Invalid regex pattern';

const uniqueCommitMessages = [...new Set(action.commitData?.map((commit) => commit.message))];

const illegalMessages = uniqueCommitMessages.filter((message) => !isMessageAllowed(message));
// const illegalMessages = uniqueCommitMessages.filter((message) => !isMessageAllowed(message));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented line

Comment on lines +57 to +69
const illegalMessages = uniqueCommitMessages.filter(
(message) => isMessageAllowed(message) !== null,
);

if (illegalMessages.length > 0) {
console.log(`The following commit messages are illegal: ${illegalMessages}`);
// console.log(`The following commit messages are illegal: ${illegalMessages}`);

step.error = true;
step.log(`The following commit messages are illegal: ${illegalMessages}`);
illegalMessages.forEach((message) => {
const error = isMessageAllowed(message);
step.log(
`Illegal commit message detected: "${message}" - Reason: ${error ?? 'Unknown reason'}`,
);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the function twice is inefficent. Perhaps swap out filter for map, then filter the result for non-null messages

Comment on lines +71 to +72
// step.error = true;
// step.log(`The following commit messages are illegal: ${illegalMessages}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed

}

console.log(`The following commit messages are legal: ${uniqueCommitMessages}`);
// console.log(`The following commit messages are legal: ${uniqueCommitMessages}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@kriswest
Copy link
Contributor

kriswest commented Feb 6, 2026

@RichardUri have you hit the Please click here to be authorized link yet? If you've been added to your firm's CLA it should make the EasyCLA check pass you (but you have to manually click on it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve logging in processors/action chain

2 participants