From 7e678913ff14e04ef128e3d06523eabd0df4d639 Mon Sep 17 00:00:00 2001 From: Fred Date: Mon, 7 Sep 2020 12:29:18 +0000 Subject: [PATCH] feat: use config-conventional as default config --- src/action.js | 3 +-- src/action.test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/action.js b/src/action.js index f1a299f..9070842 100644 --- a/src/action.js +++ b/src/action.js @@ -120,11 +120,10 @@ const handleOnlyWarnings = formattedResults => { } const showLintResults = async ([from, to]) => { - const failOnWarnings = core.getInput('failOnWarnings') const commits = await getHistoryCommits(from, to) const config = existsSync(configPath) ? await load({}, { file: configPath }) - : {} + : await load({ extends: ['@commitlint/config-conventional'] }) const opts = getOptsFromConfig(config) const lintedCommits = await Promise.all( commits.map(async commit => ({ diff --git a/src/action.test.js b/src/action.test.js index 22d9237..7810dd7 100644 --- a/src/action.test.js +++ b/src/action.test.js @@ -60,6 +60,20 @@ describe('Commit Linter action', () => { jest.resetModules() }) + it('should use default config when config file does not exist', async () => { + td.when(core.getInput('configFile')).thenReturn('./not-existing-config.js') + cwd = await git.bootstrap('fixtures/conventional') + await gitEmptyCommit(cwd, 'wrong message') + const [to] = await getCommitHashes(cwd) + await createPushEventPayload(cwd, { to }) + updatePushEnvVars(cwd, to) + td.replace(process, 'cwd', () => cwd) + + await runAction() + + td.verify(core.setFailed(contains('You have commit messages with errors'))) + }) + it('should fail for single push with incorrect message', async () => { cwd = await git.bootstrap('fixtures/conventional') await gitEmptyCommit(cwd, 'wrong message')