thehanimo / pr-title-checker Goto Github PK
View Code? Open in Web Editor NEWAn action to automatically check if pull request titles conform to Contribution Guidelines
License: MIT License
An action to automatically check if pull request titles conform to Contribution Guidelines
License: MIT License
Hey, tried to test checker
as step in our CI, might I misunderstand something or did something wrong, would grate to get some clarification.
config:
"LABEL": {
"name": "INCORRECT PR TITLE",
"color": "FF0000"
},
"CHECKS": {
"regexp": "^\\[?(\\s?[A-Z\\d]{1,}-\\d+,?){1,}\\]?:\\s?(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)"
},
"MESSAGES": {
"success": "PR TITLE IS CORRECT",
"failure": "INCORRECT PR TITLE",
"notice": ""
}
}
this regex pass for example this PR title:
PROJECT2-979: feat(ci): testing PR title checker step
step definition:
uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.PACKAGES_GITHUB_TOKEN }}
github_configuration_owner: <orgName> #(optional. defaults to the owner of the repo in which the action is run)
github_configuration_repo: <repoName> #(optional. defaults to the repo in which the action is run)
github_configuration_path: .github/pr-title-checker-config.json #(optional. defaults to .github/pr-title-checker-config.json)
github_configuration_ref: <mybranchName> #(optional. defaults to the latest commit on the default branch or, if the repo specified is the same as the one on which the action is running, it defaults to the current context's sha)
github_configuration_token: ${{ secrets.PACKAGES_GITHUB_TOKEN }} #(optional. defaults to GITHUB_TOKEN)
Expected behaviour:
Is it correct? During testing I found out that point 6 for me not work, step still failing with changed to correct title, for test I have create another PR to another branch with same correct title, but from the start and it pass this step successfully
and this is second PR with same title but from the start
Might is it possible to add some debug logging to understand what title it's handle. might there some issue with getting correct code PR revision or something else
Thanks for the help)
Hi,
I would like to check that the title doesn't have any special character, but if I pass the regexp of this type the action files [<>'"/;
%]`
I'm using this yaml file config, but the workflow is not automatically triggered when I edit the title. Once it's wrong, it can't be fixed and the workflow fails.
name: Lint PR
run-name: Lint PR
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
merge_group:
jobs:
lint-pr:
name: Lint PR
check:
runs-on: ubuntu-latest
steps:
- name: Check PR title
uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Hi @jcw- @thehanimo
I wanted to use the following configuration
{
"CHECKS": {
"prefixes": ["fix: ", "feat: "]
}
}
To check the PR but not adding any label
Just failing the CI
This is currently not supported, what do you think about adding it ?
I am trying to encapsulate the config file with my own shared action that calls your action. My shared action includes my config file that is passes to your action. That way, multiple repos can call my shared action to check PR title consistently.
For this, I would like my action to call your action like this:
name: Check PR title
description: Check that the PR title conforms to the Contribution Guidelines embedded in this action.
runs:
using: composite
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ github.token }}
local_configuration_path: ${{ github.action_path }}/pr-title-checker-config.json
where pr-title-checker-config.json
is in the same location as my action.yaml
. The action thehanimo/pr-title-checker
seems to prefix the local_configuration_path
with the path to the folder of the workflow calling my shared action. The output is:
Using local config file /home/runner/_work/_actions/<ActionOwner>/<ActionRepo>/<GitRef>/.github/actions/pr-title-check/pr-title-checker-config.json
Error: Couldn't retrieve or parse the config file specified - Error: ENOENT: no such file or directory, open
'/home/runner/_work/<WorkflowRepo>/<WorkflowRepo>/home/runner/_work/_actions/<ActionOwner>/<ActionRepo>/<GitRef>/.github/actions/pr-title-check/pr-title-checker-config.json'
The workaround is to use this:
local_configuration_path: ../../../../..${{ github.action_path }}/pr-title-checker-config.json
Hi, here is what I am trying to do:
I want to check the regex in the PR title and when it matches, I want to check if a specific label is applied on the PR or not.
This is how my config json looks:
{
"LABEL": {
"name": ""
},
"CHECKS": {
"prefixes": ["xyz: "],
"regexpFlags": "i",
"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"],
"alwaysPassCI": true
},
"MESSAGES": {
"success": "y",
"failure": "n",
"notice": ""
}
}
And this is how the github action looks:
name: "PR Title Checker"
on:
pull_request:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
jobs:
titleCheck:
runs-on: [ self-hosted ]
steps:
- id: title_check
name: check pr title for keyword
uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: ".github/pr-title.json"
labelCheck:
runs-on: [ self-hosted ]
needs: [ titleCheck ]
# this check not working
if: needs.steps.title_check.result == 'y'
steps:
- name: check label
run: echo desired pr
Is there a way I can access the MESSAGES.success
in the labelCheck
job? Please help.
There should be a way to have checks per-branch
Meaning if targeting develop, check X
If targeting master, check Y
Could it have an option for we make the ci fail instead of just add the label?
Does this action support this linting?
For Example:
"feat(authentication): Creating Login UI + Logic(#GGG-2)" or "test: Implement Unit tests for Authentication(#GG-5)"
I think having output variable with the check results would be useful to chain more actions, e.g. add a PR comment.
I could do a PR for it if you're open to having this feature.
We're currently running v1.3.7 of the action and everything is working as expected, however when I upgrade to run with v1.4.0 it fails with the following error:
Using config file .github/pr-title-checker-config.json from repo Owner/Repo [ref: ... ]
Creating label (title needs formatting)...
Label (title needs formatting) already created.
TypeError: Cannot read properties of undefined (reading 'notice')
Error: Failed to add label (title needs formatting) to PR
This is reproducible in the following workflow definition which works at v1.3.7 but fails as soon as I upgrade to v1.4.0
name: PR Title Checker
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
- labeled
branches:
- feature/*
- sub-feature/*
jobs:
pr_title_check:
name: PR Title Check
runs-on: windows-latest
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The config is as follows:
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"regexp": "^((Feature|Sub-Feature) DEV-[0-9]+)|^Bump +"
}
}
I'm experiencing a strange behavior from the bot, as shown in the screenshot below.
My config looks like below (emoji is removed for clarity), the goal is to have the bot to check if the title is prefixed with a ticket number, add a No Ticket
label if not. But do not perform the check if the No Ticket
label is already present. It looks like the line 10052 https://github.com/bcchenbc/pr-title-checker/blob/main/dist/index.js#L10052 is removing label, which I guess is not intended. Would you mind taking a look? Thank you!
"LABEL": {
"name": "No Ticket",
...
"CHECKS": {
"ignoreLabels" : ["No Ticket"],
(I created a PR #39 to remove the line, but it's showing me 8,814 additions, 8,815 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
, so I'm creating this issue guessing that you might have better way to fix it ๐
)
If configured label already exists in a different color from the one configured, the color of the label is not updated. One must edit the list of labels and delete the label in the different color for the label to be recreated with the configured color. Also, as a side note, color such as Red1
or red
don't seem to work. The hex color such as ff0000
or FF0000
must be used to work.
I know that the "pr-title-checker" needs the GitHub token in order to add labels to a PR when the PR title doesn't match the pattern but is the token needed for something else too? Because it would be nice if you wouldn't have to give it a token.
In our CI setup we sometimes have the problem that the context for the token is unavailable and then our ci fails with the error message "GITHUB_TOKEN
variable is not set". I am fine with not having a label but I don't want that the build then fails.
Hi ! I'm about to setup your action in our repo (https://github.com/python/python-docs-fr) and I would like to know if it would be possible to add a config where you could specify one or more labels to be ignored by your check. For example, in our case it would be meta
Cheers !
Seeing this on warning in GitHub when using this action:
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: thehanimo/pr-title-checker
According to that link, looks like the deadline is "Summer 2023".
I got a warning message from github action: Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: thehanimo/[email protected]
. I wonder if there is any plan to upgrade to node20?
Hi there,
Potentially not understanding usage properly here but to replicate.
name: PR Title check
runs-on: ubuntu-latest
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Is there a way to re-run the title checker without having to add to the PR?
Hi Team,
I am using your Action/Workflow, Thanks for the great effort,
I need your help, I want to use
https://www.conventionalcommits.org/en/v1.0.0/#examples
conventional-changelog/commitlint for PR title check
Can we use some regex for this, or if this action support this already how to use it ?
Please guide. I am sharing my json and yml code below. Thanks.
JSON file -
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["build: ", "chore: ", "ci: ", "docs: ", "feat: ", "fix: ", "perf: ", "refactor: ", "revert: ", "test: "],
"regexp": "docs\\(v[0-9]\\): ",
"regexpFlags": "i",
"ignoreLabels": ["dont-check-PRs-with-this-label", "meta"]
},
"MESSAGES": {
"success": "All OK",
"failure": "Failing CI test",
"notice": ""
}
}
YML file -
# This workflow/action checks if PR titles conform to the Contribution Guidelines
# For more information see: https://github.com/webex/pr-title-checker
name: pr-title-checker
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
branches:
- main
- dev
- beta
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check PR title
uses: webex/pr-title-checker@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: .github/pr-title-checker-config.json
prefixes
in JSON is totally working fine for commits title, but there could be some other examples like fix(parser):, feat(feature-name):, breaking change, !, etc. Can we use regexp for commitlint for PR title or something.
I don't want to switch to another action, so I am asking for solution.
If the pull request is coming from a fork, it may trigger the error HttpError: Resource not accessible by integration
when attempting to add a label.
May same to the error: actions/labeler#12
Currently this action only says "you got something wrong" and it leaves it up to you to figure out what. It would nice if it would report what part of the spec it's complaining about.
Like if the PR title is disable a flaky test
it would be nice if the action somewhere listed that it's in violation because it's missing the <type>:
prefix instead of leaving it up to the user to guess about what's not right.
We would like to use this action on many different repos with the same configuration, so it would be nice to define the configuration in a common location and reuse it.
An example is this action: https://github.com/release-drafter/release-drafter#configuration-options (look at the paragraph after the table of options that mentions Probot config).
In that case, we are able to put configuration files in a separate repo, and each repo using the action can get its config from there.
Perhaps a simple way could be to allow the configuration_path
to accept a URL returning the configuration, or for private repos, providing the repo and filepath in that repo, an appropriate access token, and using the GitHub API to extract file contents.
If you would accept a PR, I might have a go.
i have been trying to use this tool but I receive this issue all the time
this is my JSON
file
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["fix: ", "feat: ", "docs: ", "chore: ", "style: ", "refactor: ", "perf: ", "test: ", "revert: "],
"regexp": "docs\\(v[0-9]\\): ",
"regexpFlags": "i",
"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"]
},
"MESSAGES": {
"success": "All OK",
"failure": "Please fix the following issues:",
"notice": ""
}
}
and this is my yml
file
name: "PR Title Checker"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: "./pr-title-checker-config.json"
Hey, thanks for this great tool!
I just integrated it into my project and I am playing with it a bit.
I noticed that for each run in the GitHub CI, it returns a deprecation warning for Buffer()
method.
Full output below:
(node:1568) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
The only place in the codebase when it is used is probably here. Would be great to fix it and make the warning disappear.
Regards!
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.