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

feat: truncate build info commit message to 200chars #14

Closed
Closed
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
3 changes: 2 additions & 1 deletion setup-env/src/actionInput/inputValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class InputValidator {

const probableBranchOrTag = ref.split('/').pop();
const slicedSHA = commitSHA.slice(0, 7);
return `[${probableBranchOrTag}] Commit ${slicedSHA}: ${commitMessage} [Workflow: ${workflowNumber}]`;
const slicedCommitMessage = commitMessage.slice(0,200);
return `[${probableBranchOrTag}] Commit ${slicedSHA}: ${slicedCommitMessage} [Workflow: ${workflowNumber}]`;
}
case 'pull_request': {
const {
Expand Down
21 changes: 21 additions & 0 deletions setup-env/test/actionInput/inputValidator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ describe('InputValidator class to validate individual fields of the action input
});
});

context('Push event with long commit message', () => {
beforeEach(() => {
sinon.stub(github, 'context').value({
payload: {
head_commit: {
message: 'messageOfHeadCommit Lorem ipsum dolor sit amet, nonummy ligula volutpat hac integer nonummy. Suspendisse ultricies, congue etiam tellus, erat libero, nulla eleifend, mauris pellentesque. Suspendisse integer praesent vel, integer gravida mauris, fringilla vehicula lacinia non',
},
},
sha: 'someSHA',
runNumber: 123,
ref: 'refs/head/branchOrTagName',
eventName: 'push',
});
});

it('Generate build info with commit information', () => {
const expectedValue = '[branchOrTagName] Commit someSHA: messageOfHeadCommit Lorem ipsum dolor sit amet, nonummy ligula volutpat hac integer nonummy. Suspendisse ultricies, congue etiam tellus, erat libero, nulla eleifend, mauris pellentesque. Suspendisse [Workflow: 123]';
expect(InputValidator._getBuildInfo()).to.eq(expectedValue);
});
});

context('Pull Request event', () => {
beforeEach(() => {
sinon.stub(github, 'context').value({
Expand Down