mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 16:06:56 +00:00
Merge pull request #50 from fredicious/master
feat: use config-conventional as default config
This commit is contained in:
commit
d46e8fea0a
4 changed files with 18 additions and 3 deletions
|
|
@ -32,6 +32,8 @@ The path to your commitlint config file.
|
||||||
|
|
||||||
Default: `commitlint.config.js`
|
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`
|
### `firstParent`
|
||||||
|
|
||||||
When set to true, we follow only the first parent commit when seeing a merge commit.
|
When set to true, we follow only the first parent commit when seeing a merge commit.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ description: Lints Pull Request commit messages with commitlint
|
||||||
author: Wagner Santos
|
author: Wagner Santos
|
||||||
inputs:
|
inputs:
|
||||||
configFile:
|
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
|
default: ./commitlint.config.js
|
||||||
required: false
|
required: false
|
||||||
firstParent:
|
firstParent:
|
||||||
|
|
|
||||||
|
|
@ -120,11 +120,10 @@ const handleOnlyWarnings = formattedResults => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const showLintResults = async ([from, to]) => {
|
const showLintResults = async ([from, to]) => {
|
||||||
const failOnWarnings = core.getInput('failOnWarnings')
|
|
||||||
const commits = await getHistoryCommits(from, to)
|
const commits = await getHistoryCommits(from, to)
|
||||||
const config = existsSync(configPath)
|
const config = existsSync(configPath)
|
||||||
? await load({}, { file: configPath })
|
? await load({}, { file: configPath })
|
||||||
: {}
|
: await load({ extends: ['@commitlint/config-conventional'] })
|
||||||
const opts = getOptsFromConfig(config)
|
const opts = getOptsFromConfig(config)
|
||||||
const lintedCommits = await Promise.all(
|
const lintedCommits = await Promise.all(
|
||||||
commits.map(async commit => ({
|
commits.map(async commit => ({
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,20 @@ describe('Commit Linter action', () => {
|
||||||
jest.resetModules()
|
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 () => {
|
it('should fail for single push with incorrect message', async () => {
|
||||||
cwd = await git.bootstrap('fixtures/conventional')
|
cwd = await git.bootstrap('fixtures/conventional')
|
||||||
await gitEmptyCommit(cwd, 'wrong message')
|
await gitEmptyCommit(cwd, 'wrong message')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue