diff --git a/.github/workflows/lint-pull-request-title.yml b/.github/workflows/lint-pull-request-title.yml new file mode 100644 index 00000000..03883814 --- /dev/null +++ b/.github/workflows/lint-pull-request-title.yml @@ -0,0 +1,19 @@ +jobs: + lint-title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title for Conventional Commit Format + run: | + if ! echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + echo "The title does not conform to the Conventional Commit." + echo "Please refer to 'https://www.conventionalcommits.org/'" + exit 1 + fi +name: Lint pull request title +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab35337d..cbb4d442 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,18 @@ stages: - build_release default: image: python:3.11 +lint_title: + interruptible: true + only: + - merge_requests + script: + - | + if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + echo "The title does not conform to the Conventional Commit." + echo "Please refer to 'https://www.conventionalcommits.org/'" + exit 1 + fi + stage: lint_test lint: image: python:$PYTHON_VERSION interruptible: true diff --git a/.vscode/settings.json b/.vscode/settings.json index 739028ba..e4d6489f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -95,6 +95,7 @@ "choices", "stages", "default", + "lint_title", "lint", "test", "package", diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index 739028ba..e4d6489f 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -95,6 +95,7 @@ "choices", "stages", "default", + "lint_title", "lint", "test", "package", diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/lint-pull-request-title.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/lint-pull-request-title.yml new file mode 100644 index 00000000..03883814 --- /dev/null +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/lint-pull-request-title.yml @@ -0,0 +1,19 @@ +jobs: + lint-title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title for Conventional Commit Format + run: | + if ! echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + echo "The title does not conform to the Conventional Commit." + echo "Please refer to 'https://www.conventionalcommits.org/'" + exit 1 + fi +name: Lint pull request title +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja index 515ee7b6..235602c6 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja @@ -4,6 +4,18 @@ stages: - build_release default: image: python:{{ default_py }} +lint_title: + interruptible: true + only: + - merge_requests + script: + - | + if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + echo "The title does not conform to the Conventional Commit." + echo "Please refer to 'https://www.conventionalcommits.org/'" + exit 1 + fi + stage: lint_test lint: image: python:$PYTHON_VERSION interruptible: true