From 97d1d4d6c65bbdcd8bc2ed2c6c65ae58af64d4a7 Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Thu, 23 May 2024 14:30:46 +0200 Subject: [PATCH] ci(*:skip) Fix PR title check regex (#3497) --- .github/workflows/pr_check.yml | 1 - dev/changelog_config.toml | 2 +- dev/check_pr_title.py | 29 ++++++++++++++++------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index 6b3af429bb0..47bb4b28413 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -14,7 +14,6 @@ jobs: pr_title_check: runs-on: ubuntu-22.04 name: Title format - if: ${{ github.actor != 'dependabot[bot]' }} steps: - uses: actions/checkout@v4 - name: Bootstrap diff --git a/dev/changelog_config.toml b/dev/changelog_config.toml index 892050cdb08..898f9bfdb22 100644 --- a/dev/changelog_config.toml +++ b/dev/changelog_config.toml @@ -7,7 +7,7 @@ project = ["framework", "baselines", "datasets", "examples"] scope = "skip" -pattern_template = "^({types})\\(({projects})(?::({scope}))?\\) ([A-Z][^\\.\\n]*(?:\\.(?=[^\\.\\n]))*[^\\.\\n]*)$" +pattern_template = "^({types})\\(({projects})(?::({scope}))?\\) ([A-Z][^\\n]*[^\\.\\n])$" allowed_verbs=[ "Abandon", diff --git a/dev/check_pr_title.py b/dev/check_pr_title.py index e2679b3e722..33b7a4664e9 100644 --- a/dev/check_pr_title.py +++ b/dev/check_pr_title.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -"""This module is used to check a given PR title format.""" +"""Used to check a given PR title format.""" import pathlib import re @@ -46,10 +46,13 @@ valid = True error = "it doesn't have the correct format" - if not match: + # This check is there to ignore dependabot PRs from title checks + if pr_title.startswith("chore"): + sys.exit(0) + elif not match: valid = False else: - if not match.group(4).split()[0] in allowed_verbs: + if match.group(4).split()[0] not in allowed_verbs: valid = False error = "the doesn't start with a verb in the imperative mood" elif match.group(2) == "*" and match.group(3) is None: @@ -58,16 +61,16 @@ if not valid: print( - f"PR title `{pr_title}` is invalid, {error}.\n\n" - "A PR title should be of the form:\n\n\t() " - f"\n\nOr, if the PR shouldn't appear in the changelog:\n\n\t" - f"(:skip) \n\nwith in [{types}],\n" - f" in [{'|'.join(config['project']) + '|*'}] (where '*' is used " - "when modifying multiple projects and should be used in " + f"PR title `{pr_title}` is invalid, {error}.\n\nA PR title should " + "be of the form:\n\n\t() \n\n" + f"Or, if the PR shouldn't appear in the changelog:\n\n\t" + f"(:skip) \n\nwith in [{types}],\n" + f" in [{'|'.join(config['project']) + '|*'}] " + "(where '*' is used when modifying multiple projects and should be used in " "conjunction with the ':skip' flag),\nand starting with " - "a capitalized verb in the imperative mood and without any punctuation at the end.\n\n" - "A valid example is:\n\n\t`feat(framework) Add flwr build CLI command`\n\n" - "Or, if the PR shouldn't appear in the changelog:\n\n\t" - "`feat(framework:skip) Add new option to build CLI`\n" + "a capitalized verb in the imperative mood and without any punctuation " + "at the end.\n\nA valid example is:\n\n\t`feat(framework) " + "Add flwr build CLI command`\n\nOr, if the PR shouldn't appear in " + "the changelog:\n\n\t`feat(framework:skip) Add new option to build CLI`\n" ) sys.exit(1)