Open dolby360 opened 2 years ago
Thanks for opening your first issue here!
hmm... good catch! please feel free to fix it! :-)
@TomerFi sorry, I'm leaving this for now. I have no idea what is going on there.
That's cool bro - thank you for reporting this issue and trying to fix it. :-)
hey @dolby360
I'm looking around for a Win station to verify this on, in the meantime, can you please elaborate on your experience?
Did you:
npm i
npm test
and witness a test case failure? if so, what was the failing test case?
you know what... I think I have an idea of what's the cause of this...
throughout all tests, I used os.EOL for line breaks, I specifically used this to make the tests work for Win-based developers too, I guess it didn't work.
regardless, I was able to confirm the issue you reported by manually setting the EOL
variable.
I'm on Linux, so this worked for me:
const EOL = '\n';
but when I did this, I was able to confirm the reported issue:
const EOL = '\r\n';
but... that actually doesn't get us anywhere,
it was obvious that it was an EOL
issue based on the error you provided,
and the two assignments I manually did are exactly what we get when we use os.EOL
,
but at least I was able to confirm the issue.
maybe it has something to do with the js file itself using Linux-type EOLs, can you perhaps try setting:
const EOL = '\n';
on your end?
Sure I install and run tests this way.
npm i
npm run test
This is what I'm getting
C:\Users\dolevb\Downloads\Personal\auto-me-bot>npm run tests
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> auto-me-bot@1.1.0 tests
> mocha --check-leaks --fail-zero --color --parallel --ui tdd --recursive ./tests/
Testing the pr-tasks-list handler
1) Test with all tasks checked, expect the check to pass with a summary of the completed tasks
2) Test with unchecked tasks, expect the check to fail with a report of the not yet completed tasks
✔ Test with not tasks, expect the check to fail providing notification indicating no tasks found
Testing the pr-signed-commits handler
✔ Test with one commit signed by the author, expect a successful check run
✔ Test with one commit signed by the committer, expect a successful check run
✔ Test with two commits signed by the author, expect a successful check run
✔ Test with one commit signed by someone else (not author/committer), expect a failed check run
✔ Test with one unsigned commit, expect a failed check run
✔ Test with two commits, one unsigned and one signed by the author, expect a failed check run
✔ Test with one commit signed by the author, with a SMTPConnectionError service error, expect a failed check run
✔ Test with one commit signed by the author, with a SMTPConnectionTimeout service error, expect a failed check run
✔ Test with one commit signed by the author, with a domainNotFound service error, expect a failed check run
✔ Test with one commit signed by the author, with a invalidEmailStructure service error, expect a failed check run
✔ Test with one commit signed by the author, with a noMxRecords service error, expect a failed check run
✔ Test with one commit signed by a Bot, not author or committer, expect a successful check run
Testing the auto-me-bot export
✔ When invoking the application, expect a registration of the events
Test various pull request related configurations
✔ When all PR operations are checked, execute all PR related handlers
✔ When the conventionalCommits operation is checked, execute the related handler
✔ When the signedCommits operation is checked, execute the related handler
✔ When the tasksList operation is checked, execute the related handler
✔ When no operations is checked and config is {"pr":{}}, do not execute any handlers
✔ When no operations is checked and config is {}, do not execute any handlers
✔ When no operations is checked and config is null, do not execute any handlers
Testing the pr-conventional-commits handler
3) Test with one warning commit message, expect one warning report
✔ Test with one error commit message, expect one error report (140ms)
✔ Test with one good commit message, expect a successful result
4) Test with one warning, one error, and one good commit message, expect a report for warning and error
5) Test with one error and custom commit configuration, expect a report error on custom violation
23 passing (2s)
5 failing
1) Testing the pr-tasks-list handler
Test with all tasks checked, expect the check to pass with a summary of the completed tasks:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'success',
output: {
title: 'All Done!',
summary: 'You made it through',
text: "### Here's a list of your accomplishments\r\n- task 1\r\n- task 2\r\n- task 3"
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Tasks List',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.333Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'success',
output: {
title: 'All Done!',
summary: 'You made it through',
text: "### Here's a list of your accomplishments\r\n- task 1\r\n- task 2\r\n- task 3"
}
}
Call 2:
{
check_run_id: 13,
name: 'Auto-Me-Bot Tasks List',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.333Z',
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'success',
completed_at: '2022-08-08T07:42:40.349Z',
output: {
title: 'All Done!',
summary: 'You made it through',
text: "### Here's a list of your accomplishments\r\n" +
'- task 1\r\r\n' +
'- task 2\r\r\n' +
'- task 3'
text: "### Here's a list of your accomplishments\r\n- task 1\r\n- task 2\r\n- task 3"
}
}
at Context.<anonymous> (tests\handlers\pr-tasks-list.test.js:182:42)
2) Testing the pr-tasks-list handler
Test with unchecked tasks, expect the check to fail with a report of the not yet completed tasks:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'failure',
output: {
title: 'Found 2 unchecked tasks',
summary: "I'm sure you know what do with these",
text: '### The following tasks needs to be completed\r\n- task 2\r\n- task 3'
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Tasks List',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.360Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'failure',
output: {
title: 'Found 2 unchecked tasks',
summary: "I'm sure you know what do with these",
text: '### The following tasks needs to be completed\r\n- task 2\r\n- task 3'
}
}
Call 2:
{
check_run_id: 13,
name: 'Auto-Me-Bot Tasks List',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.360Z',
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
conclusion: 'failure',
completed_at: '2022-08-08T07:42:40.360Z',
output: {
title: 'Found 2 unchecked tasks',
summary: "I'm sure you know what do with these",
text: '### The following tasks needs to be completed\r\n- task 2\r\r\n- task 3'
text: '### The following tasks needs to be completed\r\n- task 2\r\n- task 3'
}
}
at Context.<anonymous> (tests\handlers\pr-tasks-list.test.js:182:42)
3) Testing the pr-conventional-commits handler
Test with one warning commit message, expect one warning report:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'success',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'Take a look at these',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.613Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'success',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'Take a look at these',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
Call 2:
{
check_run_id: 13,
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:40.613Z',
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'success',
completed_at: '2022-08-08T07:42:40.889Z',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'Take a look at these',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\n' +
'\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
at Context.<anonymous> (tests\handlers\pr-conventional-commits.test.js:355:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
4) Testing the pr-conventional-commits handler
Test with one warning, one error, and one good commit message, expect a report for warning and error:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 2 non-conventional commit messages',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
"it doesn't matter what you stash\r\n" +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| subject-empty | 2 | subject may not be empty |\r\n' +
'| type-empty | 2 | type may not be empty |\r\n' +
'### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:41.071Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 2 non-conventional commit messages',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
"it doesn't matter what you stash\r\n" +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| subject-empty | 2 | subject may not be empty |\r\n' +
'| type-empty | 2 | type may not be empty |\r\n' +
'### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
Call 2:
{
check_run_id: 13,
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:41.071Z',
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: '2022-08-08T07:42:41.206Z',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 2 non-conventional commit messages',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
"it doesn't matter what you stash\r\n" +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| subject-empty | 2 | subject may not be empty |\r\n' +
'| type-empty | 2 | type may not be empty |\r\n' +
'### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\n' +
'\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'missing line break\r\n' +
'```\r\n' +
'#### Warnings\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'| body-leading-blank | 1 | body must have leading blank line |'
}
}
at Context.<anonymous> (tests\handlers\pr-conventional-commits.test.js:379:38)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
5) Testing the pr-conventional-commits handler
Test with one error and custom commit configuration, expect a report error on custom violation:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'Lorem ipsum dolor sit amet\r\n' +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
"| body-max-line-length | 2 | body's lines must not be longer than 10 characters |"
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:42:41.209Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'Lorem ipsum dolor sit amet\r\n' +
'\n' +
'chore: unit test this thing\r\n' +
'\r\n' +
'Lorem ipsum dolor sit amet\r\n' +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
"| body-max-line-length | 2 | body's lines must not be longer than 10 characters |"
}
}
at Context.<anonymous> (tests\handlers\pr-conventional-commits.test.js:406:38)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
@TomerFi I also immediately suspected on the EOL and even tried your suggestion. The results are the same. I did this:
const errorCommitMessageBody = 'Lorem ipsum dolor sit amet';
const longCommitBodyMsg = `${goodCommitMessage}${'\n'}${'\n'}${errorCommitMessageBody}`;
const oneErrorCustom_commitsListResponse = {
data: [
{
html_url: fakeCommitUrl,
commit: {
message: longCommitBodyMsg
}
},
]
}
const oneErrorCustom_expectedUpdateCheck = {
check_run_id: fakeCheckId,
name: sinon.match.string,
details_url: sinon.match(u => new URL(u)),
started_at: sinon.match(t => Date.parse(t)),
status: 'completed',
conclusion: 'failure',
completed_at: sinon.match(t => Date.parse(t)),
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: [
`### ${fakeCommitUrl}`,
'```',
goodCommitMessage + '\n',
errorCommitMessageBody,
'```',
'#### Errors',
'| name | level | message |',
'| - | - | - |',
'| body-max-line-length | 2 | body\'s lines must not be longer than 10 characters |'
].join('\n')
}
}
I run the tests this way:
"C:\Program Files\nodejs\node.exe" .\node_modules\mocha\bin\_mocha --check-leaks --fail-zero --color --parallel --ui tdd --recursive ./tests/ -g "Test with one error and custom commit configuration, expect a report error on custom violation"
Results:
1) Testing the pr-conventional-commits handler
Test with one error and custom commit configuration, expect a report error on custom violation:
AssertionError: expected repo to have been called with arguments {
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\n' +
'```\n' +
'chore: unit test this thing\n' +
'\n' +
'Lorem ipsum dolor sit amet\n' +
'```\n' +
'#### Errors\n' +
'| name | level | message |\n' +
'| - | - | - |\n' +
"| body-max-line-length | 2 | body's lines must not be longer than 10 characters |"
}
}
Call 1:
{
head_sha: '#f54dda543@',
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:45:45.561Z',
status: 'in_progress'
check_run_id: 13,
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\n' +
'```\n' +
'chore: unit test this thing\n' +
'\n' +
'Lorem ipsum dolor sit amet\n' +
'```\n' +
'#### Errors\n' +
'| name | level | message |\n' +
'| - | - | - |\n' +
"| body-max-line-length | 2 | body's lines must not be longer than 10 characters |"
}
}
Call 2:
{
check_run_id: 13,
name: 'Auto-Me-Bot Conventional Commits',
details_url: 'https://auto-me-bot.tomfi.info',
started_at: '2022-08-08T07:45:45.561Z',
name: { test: [Function (anonymous)], message: 'typeOf("string")' },
details_url: { test: [Function (anonymous)], message: 'match(undefined)' },
started_at: { test: [Function (anonymous)], message: 'match(undefined)' },
status: 'completed',
conclusion: 'failure',
completed_at: '2022-08-08T07:45:45.801Z',
completed_at: { test: [Function (anonymous)], message: 'match(undefined)' },
output: {
title: 'Found 1 non-conventional commit message',
summary: 'We need to amend these commits messages',
text: '### https://fake.commit.url/#f54dda543@\r\n' +
'```\r\n' +
text: '### https://fake.commit.url/#f54dda543@\n' +
'```\n' +
'chore: unit test this thing\n' +
'\n' +
'Lorem ipsum dolor sit amet\r\n' +
'```\r\n' +
'#### Errors\r\n' +
'| name | level | message |\r\n' +
'| - | - | - |\r\n' +
'Lorem ipsum dolor sit amet\n' +
'```\n' +
'#### Errors\n' +
'| name | level | message |\n' +
'| - | - | - |\n' +
"| body-max-line-length | 2 | body's lines must not be longer than 10 characters |"
}
}
at Context.<anonymous> (tests\handlers\pr-conventional-commits.test.js:406:38)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I have Win machine if you want to have a live session.
What did you have in mind?
The behavior on win is weird, some of the fields in tests results duplicate for some reason.
'```\r\n' + 'chore: unit test this thing\n' + '\n' + 'chore: unit test this thing\r\n' + '\r\n' + 'Lorem ipsum dolor sit amet\r\n' + '```\r\n' +
Are you trying to fix a problem?
Any lead on how this feature can be implemented?
No response