Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Please provide a brief description of the changes included in this PR.
## Release

- **Changelog type**: `feat` (minor bump), `fix`, `perf` or `revert` (patch bump), or none (`chore`, `docs`, `style`, `refactor`, `test`, `build`, `ci`). See "Commit types" in the README.
- **Breaking change?**: yes / no. If yes, add `!` to the title (`feat!:`) and list what sites or other repos must change.
- **Breaking change?**: yes / no. If yes, add `!` to the title (`feat!:`). For a merge or rebase merge, also add `!` to a breaking commit subject. List what sites or other repos must change.

## Additional context

Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/commits.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Every commit on a branch must be a conventional commit: release-please builds
# versions and the changelog from commit subjects. Merge commits are skipped.
# Same check as the other UnlockEd repos (see docs/repo-standard.md in
# unlocked-core).
name: conventional commits

on:
pull_request:
types: [opened, synchronize, reopened, edited]

permissions:
contents: read

jobs:
commits:
name: conventional commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- name: Check commit subjects
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
# the loop reads git log through process substitution, so a bad range would pass silently
git rev-list "$BASE..$HEAD" > /dev/null
pattern='^(feat|fix|chore|docs|refactor|test|ci|build|perf|revert|style)(\([a-z0-9._/-]+\))?!?: .+'
bad=0
while IFS= read -r subject; do
if ! printf '%s' "$subject" | grep -Eq "$pattern"; then
echo "::error::not a conventional commit: $subject"
if [[ $subject == 'Revert "'* ]]; then
inner=${subject#Revert \"}
echo "::error::reword it to: revert: ${inner%\"}"
fi
bad=1
fi
done < <(git log --no-merges --format=%s "$BASE..$HEAD")
exit $bad
12 changes: 9 additions & 3 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: PR title

# Squash and merge lands a multi-commit PR on main under its title, so the
# title must be a conventional commit too (commits.yml checks the commits).
# title must be a conventional commit too. The "conventional commits" job in
# conventional-commits.yml checks the commits; keep the two patterns in sync. Same check as
# the other UnlockEd repos (see docs/repo-standard.md in unlocked-core).
name: pr title

on:
pull_request:
types: [opened, edited, reopened, synchronize]
Expand All @@ -22,5 +24,9 @@ jobs:
pattern='^(feat|fix|chore|docs|refactor|test|ci|build|perf|revert|style)(\([a-z0-9._/-]+\))?!?: .+'
if ! printf '%s' "$TITLE" | grep -Eq "$pattern"; then
echo "::error::PR title is not a conventional commit: $TITLE"
if [[ $TITLE == 'Revert "'* ]]; then
inner=${TITLE#Revert \"}
echo "::error::rename the PR to: revert: ${inner%\"}"
fi
exit 1
fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Postgres refuses anything else.
3. Merge that PR when you want a release. It tags `vX.Y.Z`, and CI pushes
`:X.Y.Z` to ECR.

The `conventional` and `pr title` checks allow `feat`, `fix`, `perf`,
The `conventional commits` and `pr title` checks allow `feat`, `fix`, `perf`,
`revert`, `chore`, `docs`, `style`, `refactor`, `test`, `build` and `ci`. A
`!` after the type marks a breaking change.

Expand Down
Loading