From ecda3644c72be6d2faeeff417bce3719224f43e7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:01:45 +0000 Subject: [PATCH 1/6] chore: Lint pull request title. --- .github/workflows/pull-request-title-lint.yml | 14 ++++++++++++++ .../workflows/pull-request-title-lint.yml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .github/workflows/pull-request-title-lint.yml create mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml diff --git a/.github/workflows/pull-request-title-lint.yml b/.github/workflows/pull-request-title-lint.yml new file mode 100644 index 00000000..3de1c70f --- /dev/null +++ b/.github/workflows/pull-request-title-lint.yml @@ -0,0 +1,14 @@ +jobs: + check-title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title for Conventional Commit Format + run: echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*" || exit 1 +name: Lint pull request title +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml new file mode 100644 index 00000000..3de1c70f --- /dev/null +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml @@ -0,0 +1,14 @@ +jobs: + check-title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title for Conventional Commit Format + run: echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*" || exit 1 +name: Lint pull request title +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited From c6952978f93b08bb1cab1151f9913a60cea58f95 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:15:35 +0000 Subject: [PATCH 2/6] Minor. --- .github/workflows/lint-pull-request-title.yml | 19 +++++++++++++++++++ .github/workflows/pull-request-title-lint.yml | 14 -------------- .../workflows/lint-pull-request-title.yml | 19 +++++++++++++++++++ .../workflows/pull-request-title-lint.yml | 14 -------------- 4 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/lint-pull-request-title.yml delete mode 100644 .github/workflows/pull-request-title-lint.yml create mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/lint-pull-request-title.yml delete mode 100644 template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml diff --git a/.github/workflows/lint-pull-request-title.yml b/.github/workflows/lint-pull-request-title.yml new file mode 100644 index 00000000..30992403 --- /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/.github/workflows/pull-request-title-lint.yml b/.github/workflows/pull-request-title-lint.yml deleted file mode 100644 index 3de1c70f..00000000 --- a/.github/workflows/pull-request-title-lint.yml +++ /dev/null @@ -1,14 +0,0 @@ -jobs: - check-title: - runs-on: ubuntu-latest - steps: - - name: Check PR Title for Conventional Commit Format - run: echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*" || exit 1 -name: Lint pull request title -on: - pull_request: - types: - - opened - - synchronize - - reopened - - edited 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..30992403 --- /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 == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml deleted file mode 100644 index 3de1c70f..00000000 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/pull-request-title-lint.yml +++ /dev/null @@ -1,14 +0,0 @@ -jobs: - check-title: - runs-on: ubuntu-latest - steps: - - name: Check PR Title for Conventional Commit Format - run: echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*" || exit 1 -name: Lint pull request title -on: - pull_request: - types: - - opened - - synchronize - - reopened - - edited From df07abe7436ba4a1959be2b848cc26064ede9776 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:30:24 +0000 Subject: [PATCH 3/6] Change for gitlab ci. --- .gitlab-ci.yml | 11 +++++++++++ .vscode/settings.json | 1 + template/.vscode/settings.json | 1 + ...ab-self-managed' %].gitlab-ci.yml[% endif %].jinja | 11 +++++++++++ 4 files changed, 24 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab35337d..3a13e7d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,17 @@ stages: - build_release default: image: python:3.11 +lint_title: + interruptible: true + only: + - merge_requests + script: + - | + 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 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 == '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..9c9b9ad0 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,17 @@ stages: - build_release default: image: python:{{ default_py }} +lint_title: + interruptible: true + only: + - merge_requests + script: + - | + 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 lint: image: python:$PYTHON_VERSION interruptible: true From 916affe1a13571e1637a6c4389ea5c5bd16f9659 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:32:03 +0000 Subject: [PATCH 4/6] Fix. --- .gitlab-ci.yml | 1 + ...pe == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a13e7d9..44bb1553 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ lint_title: echo "Please refer to `https://www.conventionalcommits.org/`" exit 1 fi + stage: lint_test lint: image: python:$PYTHON_VERSION interruptible: true 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 9c9b9ad0..c90ff029 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 @@ -15,6 +15,7 @@ lint_title: echo "Please refer to `https://www.conventionalcommits.org/`" exit 1 fi + stage: lint_test lint: image: python:$PYTHON_VERSION interruptible: true From 56c26a8db81fa0829091eaf7e2c33edabfc206aa Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:33:47 +0000 Subject: [PATCH 5/6] Fix. --- .github/workflows/lint-pull-request-title.yml | 2 +- .gitlab-ci.yml | 2 +- .../workflows/lint-pull-request-title.yml | 2 +- ...e == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-pull-request-title.yml b/.github/workflows/lint-pull-request-title.yml index 30992403..03883814 100644 --- a/.github/workflows/lint-pull-request-title.yml +++ b/.github/workflows/lint-pull-request-title.yml @@ -6,7 +6,7 @@ jobs: 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/`" + echo "Please refer to 'https://www.conventionalcommits.org/'" exit 1 fi name: Lint pull request title diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 44bb1553..3a445803 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ lint_title: - | 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/`" + echo "Please refer to 'https://www.conventionalcommits.org/'" exit 1 fi stage: lint_test 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 index 30992403..03883814 100644 --- 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 @@ -6,7 +6,7 @@ jobs: 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/`" + echo "Please refer to 'https://www.conventionalcommits.org/'" exit 1 fi name: Lint pull request title 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 c90ff029..73701544 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 @@ -12,7 +12,7 @@ lint_title: - | 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/`" + echo "Please refer to 'https://www.conventionalcommits.org/'" exit 1 fi stage: lint_test From ccd0f053778729c06c6bb0a444a2e8d9e359fcd0 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 31 Aug 2023 09:37:25 +0000 Subject: [PATCH 6/6] Fix variable. --- .gitlab-ci.yml | 2 +- ...e == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a445803..cbb4d442 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ lint_title: - merge_requests script: - | - if ! echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + 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 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 73701544..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 @@ -10,7 +10,7 @@ lint_title: - merge_requests script: - | - if ! echo "${{ github.event.pull_request.title }}" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then + 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