From 7e678913ff14e04ef128e3d06523eabd0df4d639 Mon Sep 17 00:00:00 2001 From: Fred Date: Mon, 7 Sep 2020 12:29:18 +0000 Subject: [PATCH 1/2] 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') From 183e260e9b4286895d5185278beef2575e50db25 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Mon, 14 Sep 2020 09:03:09 +0200 Subject: [PATCH 2/2] docs: mention default config fallback --- README.md | 2 ++ action.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ec8202..d845206 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ The path to your commitlint config file. Default: `commitlint.config.js` +If the config file doesn't exist, [config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) settings will be loaded as a default fallback. + ### `firstParent` When set to true, we follow only the first parent commit when seeing a merge commit. diff --git a/action.yml b/action.yml index 7200788..f4e8d69 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ description: Lints Pull Request commit messages with commitlint author: Wagner Santos inputs: configFile: - description: Commitlint config file + description: Commitlint config file. If the file doesn't exist, config-conventional settings will be loaded as a fallback. default: ./commitlint.config.js required: false firstParent: