benchmark-action / github-action-benchmark

GitHub Action for continuous benchmarking to keep performance
https://benchmark-action.github.io/github-action-benchmark/dev/bench/
MIT License
1.01k stars 152 forks source link

Bug: Commit message does not comply with organisation policy. #234

Open RowlandBanks opened 7 months ago

RowlandBanks commented 7 months ago

Scenario

We have a pre-commit hook that enforces commit messages are in a particular format. For example, it might enforce Semantic Commits, or Conventional Commits.

These hooks may be enforced organisation-wide.

Steps to reproduce

Expected result

Actual result

Technical implementation

The commit message is created here.

Ideally, the user would be able to specify a message format for the commit message, for example:

      - 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:

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 );
ktrz commented 6 months ago

Hi @RowlandBanks

Thanks for filing this issue. I'm putting it on my todo list as a new feature and will try to get it done but if you want to have a go at it then I would appreciate a contribution!

martincostello commented 2 months ago

I've made a start on this in #262.