Skip to content

Commit 7e67891

Browse files
committed
feat: use config-conventional as default config
1 parent f58503b commit 7e67891

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/action.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@ const handleOnlyWarnings = formattedResults => {
120120
}
121121

122122
const showLintResults = async ([from, to]) => {
123-
const failOnWarnings = core.getInput('failOnWarnings')
124123
const commits = await getHistoryCommits(from, to)
125124
const config = existsSync(configPath)
126125
? await load({}, { file: configPath })
127-
: {}
126+
: await load({ extends: ['@commitlint/config-conventional'] })
128127
const opts = getOptsFromConfig(config)
129128
const lintedCommits = await Promise.all(
130129
commits.map(async commit => ({

src/action.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ describe('Commit Linter action', () => {
6060
jest.resetModules()
6161
})
6262

63+
it('should use default config when config file does not exist', async () => {
64+
td.when(core.getInput('configFile')).thenReturn('./not-existing-config.js')
65+
cwd = await git.bootstrap('fixtures/conventional')
66+
await gitEmptyCommit(cwd, 'wrong message')
67+
const [to] = await getCommitHashes(cwd)
68+
await createPushEventPayload(cwd, { to })
69+
updatePushEnvVars(cwd, to)
70+
td.replace(process, 'cwd', () => cwd)
71+
72+
await runAction()
73+
74+
td.verify(core.setFailed(contains('You have commit messages with errors')))
75+
})
76+
6377
it('should fail for single push with incorrect message', async () => {
6478
cwd = await git.bootstrap('fixtures/conventional')
6579
await gitEmptyCommit(cwd, 'wrong message')

0 commit comments

Comments
 (0)