Skip to content

Commit

Permalink
fix: action shows error ouput when not all commits have warnings
Browse files Browse the repository at this point in the history
Fixes #43
  • Loading branch information
wagoid committed Aug 20, 2020
1 parent e93ddf0 commit 0911cae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ const formatErrors = lintedCommits =>

const hasOnlyWarnings = lintedCommits =>
lintedCommits.length &&
lintedCommits.every(
({ lintResult }) => lintResult.valid && lintResult.warnings.length,
)
lintedCommits.every(({ lintResult }) => lintResult.valid) &&
lintedCommits.some(({ lintResult }) => lintResult.warnings.length)

const setFailed = formattedResults => {
core.setFailed(`You have commit messages with errors\n\n${formattedResults}`)
Expand Down
13 changes: 11 additions & 2 deletions src/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,14 @@ describe('Commit Linter action', () => {

beforeEach(async () => {
cwd = await git.bootstrap('fixtures/conventional')
await gitEmptyCommit(cwd, 'chore: previous commit')
await gitEmptyCommit(cwd, 'chore: correct message with no warnings')
await gitEmptyCommit(
cwd,
'chore: correct message\nsome context without leading blank line',
)
const [to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { to })
const [before, from, to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { before, to })
updatePushEnvVars(cwd, to)
td.replace(process, 'cwd', () => cwd)
td.replace(console, 'log')
Expand All @@ -419,6 +421,13 @@ describe('Commit Linter action', () => {
errors: [],
warnings: ['body must have leading blank line'],
},
{
hash: from,
message: 'chore: correct message with no warnings',
valid: true,
errors: [],
warnings: [],
},
]
})

Expand Down

0 comments on commit 0911cae

Please sign in to comment.