gsactions / commit-message-checker Goto Github PK
View Code? Open in Web Editor NEWGitHub Action that checks commit messages of pushes and pull request against a regex pattern
License: MIT License
GitHub Action that checks commit messages of pushes and pull request against a regex pattern
License: MIT License
Thanks to the author, we can use this action to check commit message following the proper format.
But I found the action failed to check following situations:
(1) the PR contains 2 or more commits;
(2) at least one commit in the PR following the proper format;
(3) at least one commit in the PR broken the rule of proper format.
In this case, the check still treat the situation as proper one then check pass. but in the controversary, the action check shall be failed due to "at least one commit broken the rule of format".
Can you let me know, how to enable the action to check on every commit of one PR. Or, is it possible to improve in next version?
I am trying to fail if a commit message starts with fixup
or squash
. I am also trying to fail if a message contains [no-merge]
. It is far easier to check for the existence of these things than confirm the negative.
A new flag: failOnMatch
. It defaults to false
(current behavior). Setting to true
will fail if the pattern matches on a commit.
RegExp negative lookahead. Ugh. Not easy to understand for the next person to look at the code. (AKA me, in five minutes.)
No response
Hi,
Is there any way to disable checking title after merging a pull request?
Here is my WIP workflow:
name: 'Commit Message Check'
on: [push]
# pull_request:
# types:
# - opened
# - edited
# - reopened
# - synchronize
# push:
# branches:
# - main
# - 'releases/*'
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v1
with:
pattern: '^(add|remove|fix|chore)\([^\{\}\[\]\(\)]+?\) : '
flags: 'gm'
error: 'Your first line has to contain a commit type like "add|remove|fix|chore(...) : ".'
- name: Check Line Length
uses: gsactions/commit-message-checker@v1
with:
pattern: '^[^#].{74}'
error: 'The maximum line length of 74 characters is exceeded.'
excludeDescription: 'true' # optional: this excludes the description body of a pull request
excludeTitle: 'true' # optional: this excludes the title of a pull request
#checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
#accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
- name: Check for Resolves / Fixes
uses: gsactions/commit-message-checker@v1
with:
pattern: '^(Closes|Fixes) : \#((?!([A-Z0-9a-z]{1,10})-?$)[A-Z]{1}[A-Z0-9]+-[1-9][0-9]*).+$'
error: 'You need at least one "Closes|Fixes : #<Jira issue key>" line.'
Thanks.
I tested this PR #12 and it is working, but I noticed that the PR's title can trigger the rule, is it possible to add an option to remove it too?
Is it possible to ignore Github UI commits? For example, something like Merge branch 'master' into codestyle/#113-check-commits
I am using this action in my workflow:
name: 'Commit Message Check'
on: [push]
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v1
with:
pattern: '^[\(\)\-a-z0-9,\s]+: .+(?:\n(?:\n.+)+)?(?:\n\n.+)?$'
error: 'Your message must have the correct format "<scope>: <subject>" with an optional body and footer separated by blank lines.'
And it is falling with this msg:
##[error]Error: No commits found in the payload.
##[error]No commits found in the payload.
Here is the commit: shellhub-io/shellhub@2a40e96
My guess is something related to this msg: "This commit does not belong to any branch on this repository", but based on error msg it is something else.
ubuntu-latest
No response
After github action failed as it didnot find the regex in the commit message . but it still failed when commit message are rewrited and pushed.
It should pass if the commit message is updated as per the regex
I have put regex like below
- name: Check Jira ID or Skip tag
uses: gsactions/commit-message-checker@v1
with:
pattern: '(ED-[\d]+|TECH)'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}
error: 'You need at least Jira ID or Skip tag i.e [ED-123] | [skip|no issue].'
so to reproduce the problem , you can commit a message without the Jira ID i,e ED-123 , this one will fail which is expected but when you ammend your pushed commit then it should passed.
No response
I have a disdain for the "floating" versions that are supported by actions. Could you create a full release version for this as well?
I've been burnt by using v1
style versions with other 3rd party actions.
Just to be clear, in case you aren't sure what I mean:
v1
is both a version and an alias. It can be aliased to v1.0.0
and when v1.0.1
comes out it aliases to v1.0.1
. When v1.1.0
comes out v1
is now an alias to v1.1.0
.
I've had issues where an action was promoted from v5.4
to v5.5
and it stops working due to a bug. In this case I was using v5
and suddenly my workflows were failing without any change to them.
While I'm a huge supporter of semver, I also need to have the confidence that things are not changing without my knowledge. I've since required (in my work environment) that we use full versions of actions when possible, and do a round of testing when upgrading actions.
Thank you for your contribution to actions, this one will be helpful to us :D
Hi,
I am trying to run a organizational workflow across multiple repos, trying to enforce work items to be linked to every commit. But i am getting this error
Run gsactions/commit-message-checker@v1
Error: Error: Event "repository_dispatch" is not supported.
Regards
Vaishnav
Update action to use Node 16 instead of Node 12
No response
No response
I created a wrong commit in order to test the new github action. Then I ammended to the commit and fixed it, I expected the action to become green but it still failed. Then I fixed the PR title and included the "[BUGFIX]" prefix as well, still failing...
This is my config
Run gsactions/commit-message-checker@v1
with:
pattern: \[[^]]+\] .+$
flags: gm
error: Your first line has to contain a commit type like "[BUGFIX]".
excludeTitle: false
excludeDescription: false
checkAllCommitMessages: false
accessToken: false
and this is my output:
Checking commit messages against "\[[^]]+\] .+$"...
- failed: "[BUGFIX] Testing commit message github action"
Error: Error: Your first line has to contain a commit type like "[BUGFIX]".
Both, my github title and my commit message have the "[BUGFIX]" prefix and the action still fails.
See my attempts here to play with it FriendsOfTYPO3/extension_builder#453
Workflow passes despite pattern not being present in the PRs commits.
repro steps:
This is my action definition:
name: Jira Message Check
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Message For Jira Tag
uses: gsactions/commit-message-checker@v1
with:
pattern: 'JIRA: (KAT\-[0-9]+|NOJIRA)$'
error: 'You need at least one "JIRA: KAT-<issue number>" line below the title line. If there is no jira associated with this PR/commit you may also use JIRA: NOJIRA. Please see docs/contributing/git-style.rst#submitting-changes for examples'
excludeTitle: 'true'
excludeDescription: 'true'
Could the previous commit messages be still cached somewhere in the workflow, and end up getting passed to the check-commit-message
workflow?
a data point to support this theory: if I add checkAllCommitMessages: 'true'
to my workflow, it fails as expected since none of the commits contain the pattern.
If I then switch back to the default checkAllCommitMessages: 'false'
it incorrectly passes.
Hi folks,
Thanks for this life-saving tool.
I was thinking that could be really cool to provide some checks for duplicity in the commit messages. This is because sometimes new contributor does not take care of the commit messages when developing and uses the same message for all commits.
It would be wonderful to have some input parameters to check duplicity such as:
checkDuplicityMessages: "true"
This will take an input commit list and check duplicity.
Run gsactions/commit-message-checker@v[1](https://github.com/user/repo/actions/runs/3837184384/jobs/6532199)
Checking commit messages duplicity...
- OK: "AB#000000 feat: add commit checker"
- OK: "AB#000000 fix: my message 2"
- OK: "AB#000000 docs: update docs"
- failed: "AB#000000 docs: update docs"
- OK: "AB#000000 fix: my message 3"
Error: Error: You have duplicated commit messages
Maybe using a regex pattern, but I don't know how to apply this
No response
GitHub actions will deprecate the use of node 12 starting on September 27th,
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
Upgrade to node 16
No response
No response
I would like to be able to check for a pattern only in the most-recent commit message. Our use case is checking for the result of a test that I want to make sure has passed before a PR can be merged. e.g., Does the commit message contain "Test Successful"?
Some commits in a PR may not contain a test result or may contain an invalid test result, but I only care that the test was run and succeeds as of the latest commit.
I don't want to put the test result in the PR description because a commit made while the PR is open could cause my test to fail, but the GHA check would still pass because of the old message in the PR description.
At the moment each of the commit messages needs to match regex for the action to complete
A new flag that would check whether one of the commit messages matches the regex.
No response
No response
The README has a few typos and missing punctuation, submitted a PR to fix that.
If a PR title or description is changed the checker still uses the primary submitted values e.g. see benjaminkott/bootstrap_package#943
Instead always the current values should be used.
ubuntu-latest
No response
I set up a commit-message-checker workflow to check the commit message of a Pull request.
The pattern is to make sure the message begin with certain formatted text.
Then I send a PR with a commit message that doesn't match the pattern, the workflow
detects it and give failure result.
Then I updated the commit's message to something that matches the pattern (locally, run git comment --amend
to modify the commit message) and force pushed the commit to repository. The workflow re-triggered automatically. However it still use the old commit message and failed the workflow.
I'd expect the workflow could pick up my commit updates and give a successful workflow result.
It would be always check the updated commit message rather than the original one.
We need to enable this action on pull_request, but we don't need to check the description of PR.
This feature request was created based on this conversation #11
We are trying to automate, checking whether commits match a regex - your action works great.
Unless it's a merge commit (e.g. locally a developer merged one branch into another, created a merge commit and pushed that).
The commit message will not match the desired regex.
You can check if a commit is a merge commit:
git cat-file -p $commit_id
If there's more than one `parent' line in the output, you found a merge.
If there's a "ignoreMergeCommits" setting acitvated, then do not even test for the regex (just list it as 'ignored'?)
No response
No response
Noticed while running CI/CD today that the node16 actions runner was deprecated by GitHub last year.
A new version pushed on node20.
We can fork the project to use internally, but would prefer to use the existing solution in the marketplace.
No response
Hi, I'm wondering if there can be a boolean flag to check if a PR description exists. I'd like to be able to check if a description exists given a specific pattern for PR title :)
We forgot to add these argument to the list of valid arguments.
args:
excludeDescription: true
excludeTitle: true
checkAllCommitMessages: true
accessToken: ${{ secrets.GITHUB_TOKEN }}
warning message:
##[warning]Unexpected input(s) 'excludeTitle', 'checkAllCommitMessages', 'accessToken', valid inputs are ['pattern', 'flags', 'error', 'excludeDescription']
ubuntu-latest
- name: validate commit format -- Check if HEAD commit message contains [xyz] or FAIL.
uses: gsactions/commit-message-checker@v1
with:
pattern: '\[[^]]+\]'
flags: 'gm'
error: 'Your commit must contain `[..]` like "[BUGFIX] or [SDK-974]".'
#checkAllCommitMessages: 'false' # optional: this checks all commits associated with a pull request
#accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
#pattern: '^[^#].{74}' error: 'The maximum line length of 74 characters is exceeded.'
#excludeDescription: 'true' # optional: this excludes the description body of a pull request
#excludeTitle: 'true' # optional: this excludes the title of a pull request
#pattern: '^.+(Resolves|Fixes): \#[0-9]+$' # Check for Resolves / Fixes
The above mentioned yaml is not working on head commit but rather the PR title. i wish to check on just the head commit and not enforce namings on PR title/ description
expected the regex '\[[^]]+\]'
to match for commit [FIX] [SDK-974] validate head commit format (should be successful)
, but not sure why it isn't matching . on regex101 site, it seems to work correctly. : https://regex101.com/r/VapGyU/1
run the above yaml mentioned in any github runner and you will find the title getting validated but not the head commit
https://github.com/CleverTap/clevertap-android-sdk/actions/runs/2014762191
in my repo i had a bad commit, so i renamed it and force pushed in my PR however the check still fails somehow, and shows the old message. It seems it catches something in the wrong way.
On top of this, if i let this run on my master branch, it will fail on my newest commit because i have a really old commit that doesn't conform the my naming convetion, rather than only checking the commit at hand. should i use another regex flag? (for thsi reason i disabled the check on anything but pull requests)
name: "Commit Message Check"
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v1
with:
pattern: '(ID-\d+|FIX): .+'
flags: "gm"
error: "Naming convention is `[ID]: [summary]` i.e `ID-404: Fixed My Shit`"
ubuntu-latest
No response
When I changed the checkAllCommitMessages
to "true"
, I started getting a Error: HttpError: Bad credentials
error.
Step specification:
- name: Check commit message
uses: GsActions/commit-message-checker@v1
with:
checkAllCommitMessages: "true"
pattern: "^(?!WIP).*$"
error: "The first line cannot start with WIP"
Job output:
Run GsActions/commit-message-checker@v1
with:
checkAllCommitMessages: true
pattern: ^(?!WIP).*$
error: The first line cannot start with WIP
flags: gm
excludeTitle: false
excludeDescription: false
accessToken: false
env:
JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.16-1/x6[4](https://github.com/oxidefrp/oxide-kotlin/runs/8246008060?check_suite_focus=true#step:4:4)
Error: HttpError: Bad credentials
No Error: HttpError: Bad credentials
error.
No response
No response
I am running the same workflows for push and pull_request. The push is running well, but the pull_request is falling:
https://github.com/TotalCross/totalcross/pull/117/checks?check_run_id=1000747757
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.