23.12-config-file
Motivation
Simple json/yaml/toml configuration - key feature. That is more effective than the Danger.
Checkers
- PR changes max lines
- Commit changes max lines
- Commit format: max length and title regex
- Footer regex or footer words
- Conventional commits (check + changelog)
- Emoji ban, symbol set whitelist
- Rebase forcing
commits:
# max: 10
pr-limit: 10 # max commits per PR
subject: # default - conventional commit
format: "(task) (context)?: (type) (title)"
types: [ feat, fix, chore, docs ]
limits:
title: 50
context: 5
unique: [title] # commits should not repeat this
body:
width-limit: 80
task-regex: ^abc-123
banned-words:
- emoji
- fixed -> fix
author:
regex: (.+)@company.com
diff:
total-max: 2000
per-file-max:
additions: 300
deletions: 1000
all: 1000
must-change: [ "changelog.md" ]
protected-files:
paths: [ ".golangci-lint", "git-checks.go" ]
allowed-authors: [ "bibaboba@gmail.com" ]
Footers and task validation
Type of footers
- key value
ref: #123
- value
#123
footer:
- key: task # task: #123
format: task
required: true
- format: task # #123
required: true
- key: breaking_change # breaking_change: $break_description
- key: see-also # "see also: $task"
format: task
- key: something-custom # something-custom: 123-blabla
format: custom-custom # must be declared value
- key: context
format: context
Values validation
values:
type:
- allowed: [ feat, fix, chore, docs ]
title:
- limit: 50
body:
- limit: 500
width-limit: 80
context:
- limit: 5 # optional
- allowed: [ docs, some, other ] # optional
task:
- regex: ^abc-123
custom-custom:
- regex: ^abc-123
allowed: [ feat, fix, chore, docs ]
limit: 50
Pros of values separation:
- Can be used across all message text (subject, body, footers)
- Same structure
- Single place
- Simpler API for Lua in future because of single map of standard and custom values.
Testing
Ability to easily test your config is important.
I like Danger, but its local testing with danger pr
is not comfortable.
Last commits testing
changes/git
package already can give last 10 commits data.
We can use that to run checks upon last N commits.
Samples testing
Configuration can contain sample commits data and simplified expected output.
# draft
config-tests:
commits:
- message: "test title"
alias: "first"
author: "rusinikit@gmail.com"
expects:
- checker: "title"
commits: [ "first" ]
Good commits can be used as examples in CLI output for PR message.
Problems with diff
Files diff checks is important too. But it’s complicated. Feature request required.
Changelog generation
changelog:
group-by: [context, type] # commit titles will be grouped
# (version) and (title) will be replaced with params
title-format: "**(version)**: (title)" # default - **(version)**
version-tag-format: # how to create new tag
starts-with: "v"
type: number # semver, number, commit hash
commit-message-format: "docs(log): (version)" # how to create new commit
Diff regeneration
Program needs to find a previous version changelog title to replace lines on top of that. It will look for exact previous version tag symbols appeared in markdown header.
## test1.2.3: Some title that will be replaced
Some text that will be replaced.
## v1.2.3: Header that we are looking for
Text that will not be replaced.