thehanimo / pr-title-checker

An action to automatically check if pull request titles conform to Contribution Guidelines
MIT License
109 stars 36 forks source link

Checker won't check updated PR #41

Closed oleksandr-kinship closed 1 year ago

oleksandr-kinship commented 1 year ago

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/pr-title-checker@v1.4.0
        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)

oleksandr-kinship commented 1 year ago

Looks find out the reason - is because manual re-run isn't change github context, so context.pull_request.title remains the same.., so this is Github special see some opened issues.. as solution add triggering by type before have used by path, will check how it will affect current CI process. I thinks this details can be added to README as note, to other be aware about this or if you have some comment would glad to hear it otherwise this Issue can be closed.

thehanimo commented 1 year ago

Can I see the triggers on your yaml? I'm not entirely sure if the context remains the same or not but ideally this action should just be triggered by PR changes; not by re-runs. A note about that in the README might be a good idea, thanks!

oleksandr-kinship commented 1 year ago

Can I see the triggers on your yaml? I'm not entirely sure if the context remains the same or not but ideally this action should just be triggered by PR changes; not by re-runs. A note about that in the README might be a good idea, thanks!

Yep, as I mention in my reply issue was in triggers, most github specific.. it's works fine with types: [opened, edited, synchronize]. With this there no reason to re-run it manually in the case, it will be automatically run with edited event.