Skip to content

Commit

Permalink
ci: fix PR title checker
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Mar 25, 2024
1 parent 4e0175f commit 16fe2be
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ permissions:

jobs:
pre-commit:
name: "pre-commit and title check"
name: "pre-commit"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
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'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/dev_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
39 changes: 20 additions & 19 deletions .github/workflows/dev_pr/title_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 16fe2be

Please sign in to comment.