Giter Club home page Giter Club logo

pr-title-checker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pr-title-checker's Issues

Couldn't retrieve the config file specified - HttpError: Not Found

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"

Adding output with action result

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.

Configuration file outside the repo

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.

having ignoreLabels still adding label

I have the current present you described on your README file
I have
"ignoreLabels" : ["๐Ÿ‘ dependencies"]

A label is created for PRs that has the ignore label above.
the action succeed

I do see in github log:
image

Workflow is not triggered when changes are made to the PR

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

Color is not set if label already exists in a different color

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.

Would be nice to know what violations are found.

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.

Failed to add label to PR in v1.4.0

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 +"
  }
}

Ignore PRs label

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 !

Checker won't check updated PR

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:

  1. a developer open PR with incorrect title
  2. checks failed
  3. label created and added to PR
  4. the developer change the PR title to match the regex
  5. the developer open Actions and restart failed jobs
  6. Checks passed as point 4 , label removed from PR

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

image
image

and this is second PR with same title but from the start
image

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)

After title error and once properly formatted, title checker doesn't re-run and pass.

Hi there,

Potentially not understanding usage properly here but to replicate.

  1. Using
    name: PR Title check
    runs-on: ubuntu-latest
    steps:
      - uses: thehanimo/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  1. Create a PR with a poorly formatted title.
  2. Title checker correctly identifies issue with title.
    image
  3. Fix title to pass Regex
  4. Pipeline does NOT automatically re-run title checker.

Is there a way to re-run the title checker without having to add to the PR?

Getting the output of the pr title check to use in the next step

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.

local_configuration_path insert current working directory before absolute path

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

Any plan to upgrade to node20?

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?

How I can exclude special characters

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 [<>'"/;%]`

Deprecation warning in GitHub CI

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!

ignoreLabels is removing labels

I'm experiencing a strange behavior from the bot, as shown in the screenshot below.
image

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 ๐Ÿ˜… )

I want to use conventional-changelog/commitlint for PR title check

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.

@thehanimo, @feychenie, @jcw-

GITHUB_TOKEN variable is not set

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.