diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 3ac088d3c8..8ec5a3c2db 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -30,7 +30,7 @@ permissions: jobs: pre-commit: - name: "pre-commit and title check" + name: "pre-commit" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,11 +38,6 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Check PR title for conventional commit format - if: github.event_name == 'pull_request' - run: | - python .github/workflows/dev_pr/title_check.py $(pwd) "${{ github.event.pull_request.title }}" - - uses: actions/setup-go@v5 with: go-version-file: 'go/adbc/go.mod' diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml index 65f352e076..ba33678b4c 100644 --- a/.github/workflows/dev_pr.yml +++ b/.github/workflows/dev_pr.yml @@ -38,6 +38,17 @@ jobs: with: persist-credentials: false + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: pr_checkout + persist-credentials: false + ref: "${{ github.event.pull_request.merge_commit_sha }}" + + - name: Check PR title for conventional commit format + run: | + python .github/workflows/dev_pr/title_check.py $(pwd)/pr_checkout "${{ github.event.pull_request.title }}" + - name: Assign milestone if: always() env: diff --git a/.github/workflows/dev_pr/title_check.py b/.github/workflows/dev_pr/title_check.py index 9297b96f69..e06164b6df 100644 --- a/.github/workflows/dev_pr/title_check.py +++ b/.github/workflows/dev_pr/title_check.py @@ -63,25 +63,26 @@ def matches_commit_format(root: Path, title: str) -> typing.List[str]: reasons.append(f"Invalid commit type: {commit_type}") components = m.group(2) - if not components.strip(): - reasons.append("Invalid components: must not be empty") - - components = components.split(",") - for component in components: - if component != component.strip(): - reasons.append( - f"Invalid component: must have no trailing space: {component}" - ) - elif not valid_component.match(component): - reasons.append( - "Invalid component: must be alphanumeric with " - f"dashes, slashes, and underscores: {component}" - ) - elif component != "format" and not Path(component).exists(): - reasons.append( - "Invalid component: must reference a file " - f"or directory in the repo: {component}" - ) + if components is not None: + if not components.strip(): + reasons.append("Invalid components: must not be empty") + else: + components = components.split(",") + for component in components: + if component != component.strip(): + reasons.append( + f"Invalid component: must have no trailing space: {component}" + ) + elif not valid_component.match(component): + reasons.append( + "Invalid component: must be alphanumeric with " + f"dashes, slashes, and underscores: {component}" + ) + elif component != "format" and not Path(component).exists(): + reasons.append( + "Invalid component: must reference a file " + f"or directory in the repo: {component}" + ) subject = m.group(3) if subject.strip() != subject: