benchmark-action / benchmark-action/github-action-benchmark
Bug: Commit message does not comply with organisation policy.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 184
- PR merge metrics
- No merged PRs in 30d
Description
# Scenario
We have a pre-commit hook that enforces commit messages are in a particular format. For example, it might enforce [Semantic Commits](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716), or [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/).
These hooks may be enforced organisation-wide.
# Steps to reproduce
* Add a hook to enforce a particular style of commit message.
* Run a benchmarking workflow.
# Expected result
* The commit pushed to Github Pages has a commit message that matches the required style
* The commit is successfully pushed.
# Actual result
* The following error is received:
```
remote: commit-msg: failed with exit status 1
remote: [POLICY] Aborting commit 9e0367e61d255bf5584361d5ce52e2eec170c83a. Your commit message is missing a JIRA ID. e.g. Should start with something like 'ABC-1234: ' -- If your change is too insignificant to require a Jira number, you may add the prefix 'Minor'
To https://contoso.org/contose/people_service.git
! [remote rejected] gh-pages -> gh-pages (pre-receive hook declined)
error: failed to push some refs to 'https://contoso.org/contose/people_service.git'
Warning: Auto-push failed because the remote gh-pages was updated after git pull
```
# Technical implementation
The commit message is created [here](https://github.com/benchmark-action/github-action-benchmark/blob/e7180f51a3e2d715fd8990ea6ad8ca50034100d6/src/write.ts#L438).
Ideally, the user would be able to specify a message format for the commit message, for example:
```yml
- name: Store benchmark result
uses: actions/github-action-benchmark@v1.19.3
with:
name: Benchmark.Net Benchmark
tool: 'benchmarkdotnet'
output-file-path: src/Benchmarks/results/Benchmarks-report-full-compressed.json
auto-push: false
commit-message-format: "MINOR: add {name} ({tool}) benchmark result for {bench_commit_id}"
```
A common implementation would be:
```javascript
const commitTemplate = args.outputFilePath;
function fillTemplate(template, values) {
return template.replace(/{(.*?)}/g, (match, key) => values[key.trim()] || match);
}
const templateValues = {
name: name,
tool: tool,
bench_commit_id: bench.commit.id}
};
const commitMessage = fillTemplate(commitTemplate, templateValues );
```
Contributor guide
Assessment
This issue has not been assessed yet.