Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RowlandBanks opened this issue Mar 22, 2024 · 2 comments
Open

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

RowlandBanks opened this issue Mar 22, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@RowlandBanks
Copy link

RowlandBanks commented Mar 22, 2024

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

  • 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.

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

      - name: Store benchmark result
        uses: actions/[email protected]
        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 );
@RowlandBanks RowlandBanks changed the title Bug: Bug: Commit message does not comply with organisation policy. Mar 22, 2024
@ktrz ktrz added the enhancement New feature or request label Mar 25, 2024
@ktrz
Copy link
Member

ktrz commented Mar 25, 2024

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 added a commit to martincostello/github-action-benchmark that referenced this issue Aug 13, 2024
- Add support for configuring the Git commit message, user name and user email.
- Run `npm audit fix` to resolve vulnerability.
- Fix prettier complaining about line-endings on Windows.
- Skip test that is not supported on Windows.

Relates to benchmark-action#234.
@martincostello
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants