diff --git a/.github/workflows/conventional-pr-title.yml b/.github/workflows/conventional-pr-title.yml new file mode 100644 index 000000000..bfaca785e --- /dev/null +++ b/.github/workflows/conventional-pr-title.yml @@ -0,0 +1,41 @@ +name: Conventional PR Title + +# The PR title becomes the squash commit and the release notes line, so it +# has to follow Conventional Commits: `type(scope)!: description`. + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: {} + +jobs: + check-title: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Check the PR title + env: + # Read from env, never interpolated into the script, since the title is untrusted. + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + types="feat|fix|perf|refactor|revert|docs|style|test|build|ci|chore" + pattern="^(${types})(\([a-z0-9][a-z0-9._/, -]*\))?!?: [^ ].*$" + + if [[ "$PR_TITLE" =~ $pattern ]]; then + echo "PR title follows Conventional Commits." + exit 0 + fi + + echo "::error::PR title must follow Conventional Commits: type(scope)!: description" + # Line breaks would let the title start a workflow command line. + echo "Got: ${PR_TITLE//[$'\r\n']/ }" + echo "Allowed types: ${types//|/, }" + echo "Examples:" + echo " feat(saves): favorite and label saves and states" + echo " fix: serialize single-file ROM promotion across gunicorn workers" + exit 1 diff --git a/.github/workflows/update-hltb-api-url.yml b/.github/workflows/update-hltb-api-url.yml index 8def04ba2..14dacb6f0 100644 --- a/.github/workflows/update-hltb-api-url.yml +++ b/.github/workflows/update-hltb-api-url.yml @@ -40,10 +40,10 @@ jobs: with: add-paths: | backend/handler/metadata/fixtures/hltb_api_url - commit-message: "Update HLTB API URL [skip CI]" + commit-message: "chore(hltb): update HLTB API URL [skip CI]" branch: update-hltb-api-url sign-commits: true - title: "Update HLTB API URL [skip CI]" + title: "chore(hltb): update HLTB API URL [skip CI]" reviewers: | gantoine diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1b9c492c..f54b832c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,7 @@ If you would like to translate the project into another language, create a new f - Update the documentation if necessary. - Ensure all existing tests pass, and add new tests for new functionality. - Use clear and descriptive titles and descriptions for your pull requests. +- Write the PR title as a [Conventional Commit](https://www.conventionalcommits.org/), such as `fix(scan): keep partial bytes out of the fallback hash`. Allowed types are `feat`, `fix`, `perf`, `refactor`, `revert`, `docs`, `style`, `test`, `build`, `ci` and `chore`, and CI checks the title. ## Code Style