linear-b / gitstream

/:\ gitStream - Workflow automation for your git repo. Use YAML to auto-assign reviewers, auto-merge PRs, automatic PR labeler, and more.
https://gitstream.cm
Apache License 2.0
261 stars 30 forks source link

PR title check failing #521

Closed bartkuzio closed 4 months ago

bartkuzio commented 4 months ago

Describe the bug

PR title check stopped working correctly from today. Most likely pr.title has an issue since another check depending on it is also not running.

To Reproduce

I have the following action in cm repo:

  label_missing_jira_info:
    if:
      - {{ not (has.jira_ticket_in_title or has.no_ref_in_title) }}
    run:
      - action: add-label@v1
        args:
          label: "missing jira"
          color: {{ colors.red }}
      - action: request-changes@v1
        args:
          comment: |
            This PR is missing a Jira ticket reference in the title.
            Please add a Jira ticket reference to the title of this PR or use `NO-REF`.

has:
  jira_ticket_in_title: {{ pr.title | includes(regex=jira.pattern) }}
  no_ref_in_title: {{ pr.title | includes(regex=r/NO-REF/) }}

jira:
  pattern: 'r/\b[A-Za-z]+-\d+\b/'

Now each time this action runs it executes the action and requests changes, even if PR title is correct, like 'ABC-123 some title'. We didn't change the action, it worked correctly last week.

Expected behavior

Action should not execute if PR title matches the regex.

Screenshots

image

korya commented 4 months ago

We have a similar issue: a rule using regexp matching in PR title and PR description started to fail. It used to work just fine last week.

The config is below:

  label_missing_jira_info:
    if:
      - {{ not is.dependabot }}
      - {{ not is.publicRepo }}
      - {{ not (crossref.jiraInTitle and crossref.jiraInDescription) }}
    run:
      - action: add-label@v1
        args:
          label: 'cm: missing-jira'
          color: {{ colors.danger }}
      - action: request-changes@v1
        args:
          comment: |
            This PR is missing a reference to Jira ticket

...

is:
  publicRepo: {{ repo.visibility | match(term='public') }}
  dependabot: {{ (branch.name | includes(term="dependabot")) and (branch.author | includes(term="dependabot")) }}

...

crossref:
  jiraInTitle: {{ pr.title | includes(regex=pattern.jira_ticket_id) }}
  jiraInDescription: {{ pr.description | includes(regex=pattern.jira_ticket_url) }}

pattern:
  jira_ticket_id:     r/\[\s*\w{1,}-\d{1,}(\s+\w{1,}-\d{1,})*\s*\]\s*$/
  jira_ticket_url:    r/-\s+https:\/\/org\.atlassian\.net\/browse\/\w{1,}-\d{1,}\b/
PavelLinearB commented 4 months ago

Hi @korya and @bartkuzio, thanks for reporting this bug We are looking into it. It seems like there is a problem with the regex interpreter and the team is working to fix it. I will update here when it is resolved

korya commented 4 months ago

@PavelLinearB Thanks for the update! Great to hear that you are on top of it!

PavelLinearB commented 4 months ago

Hi @bartkuzio ,@korya This issue is now fixed. I apologize for the inconvenience. Please reach out or re-open this issue if the problem continues.

bartkuzio commented 4 months ago

It works now, thanks for quickly fixing the issue!