You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
In the first place I'd suggest to create a dedicated test action instead. For me it looks you mix up various jobs here which I really would not suggest to do.
The test I'm referring to is run in local dev environment and devs paste the result into their commit. We want to use this check to make sure that the most-recent commit has passed this test before approving the PR.
@bbchase You should try it by set excludeDescription, excludeTitle and checkAllCommitMessages to true. This should work for your case I'd say. Then check the end of the message.
I have tried that. In that case, all commits associated with a PR are checked and if any commit does not contain the test message for whatever reason, the check will fail. I really only care that the latest commit contains this message.
Here's the contents of the yml file if it helps:
name: 'Commit Message Check'on:
pull_request:
types:
- opened
- edited
- reopened
- synchronizepull_request_target:
types:
- opened
- edited
- reopened
- synchronizepush:
branches:
- mainjobs:
check-commit-message:
name: Look for Test Suite messageruns-on: ubuntu-lateststeps:
- name: Check Commit Typeuses: gsactions/commit-message-checker@v1with:
pattern: '^Successful Full Test Suite Run at \d\d\d\d+-\d\d-\d\d \d\d:\d\d:\d\d UTC$'error: 'The commit message must include a successful full test suite run.'excludeTitle: trueexcludeDescription: truecheckAllCommitMessages: trueaccessToken: ${{ secrets.GITHUB_TOKEN }}
The problem here is your pattern, which tests for the start. Try this one Successful Full Test Suite Run at \d\d\d\d+-\d\d-\d\d \d\d:\d\d:\d\d UTC$ which will only take care about the end.
changed the title [-][Feature Request] Option to check only the most recent commit message[/-][+]Check only the most recent commit message[/+]on Mar 6, 2022
Activity
gilbertsoft commentedon Feb 24, 2022
In the first place I'd suggest to create a dedicated test action instead. For me it looks you mix up various jobs here which I really would not suggest to do.
Have a look at my workflows here, there is a clear separation of CI and pull request handling https://github.com/GsTYPO3/core-patches/tree/main/.github/workflows
PR related action: https://github.com/GsTYPO3/core-patches/actions/runs/1818090001
CI related action: https://github.com/GsTYPO3/core-patches/actions/runs/1818090153
bbchase commentedon Feb 28, 2022
The test I'm referring to is run in local dev environment and devs paste the result into their commit. We want to use this check to make sure that the most-recent commit has passed this test before approving the PR.
gilbertsoft commentedon Mar 2, 2022
@bbchase You should try it by set
excludeDescription,excludeTitleandcheckAllCommitMessagestotrue. This should work for your case I'd say. Then check the end of the message.See also https://github.com/GsActions/commit-message-checker#configuration.
bbchase commentedon Mar 2, 2022
I have tried that. In that case, all commits associated with a PR are checked and if any commit does not contain the test message for whatever reason, the check will fail. I really only care that the latest commit contains this message.
Here's the contents of the yml file if it helps:
gilbertsoft commentedon Mar 6, 2022
The problem here is your pattern, which tests for the start. Try this one
Successful Full Test Suite Run at \d\d\d\d+-\d\d-\d\d \d\d:\d\d:\d\d UTC$which will only take care about the end.If this does still not work, enable debugging see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging. Then you will see the message which is built and you can use tools like https://regexr.com/ afterwards to find a working pattern.
And if you enforce pull request, it does not make much sense to run the action for the main branch btw.
[-][Feature Request] Option to check only the most recent commit message[/-][+]Check only the most recent commit message[/+]