Skip to content

Commit

Permalink
ci: fix PR title checker (#1661)
Browse files Browse the repository at this point in the history
Fixes #1658.
  • Loading branch information
lidavidm authored Mar 25, 2024
1 parent 4e0175f commit bc26d55
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 @@ -44,3 +44,14 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./.github/workflows/dev_pr/milestone.sh "${GITHUB_REPOSITORY}" ${{github.event.number}}
- 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 }}"
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 bc26d55

Please sign in to comment.