From 74b6fb47cd40f87627f486fb73ae9e9ec230ec70 Mon Sep 17 00:00:00 2001 From: jarvis8x7b <157810922+jarvis8x7b@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:02:52 +0800 Subject: [PATCH 1/2] ci: add conventional commits CI --- .github/workflows/commit-message.yaml | 38 +++++++++++++++++++++++++++ .github/workflows/pr_title.yaml | 21 +++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/commit-message.yaml create mode 100644 .github/workflows/pr_title.yaml diff --git a/.github/workflows/commit-message.yaml b/.github/workflows/commit-message.yaml new file mode 100644 index 0000000..7b3475c --- /dev/null +++ b/.github/workflows/commit-message.yaml @@ -0,0 +1,38 @@ +name: "Lint PR Commit Messages" + +on: + pull_request: + types: [opened, reopened, ready_for_review, synchronize, edited] + branches: + - dev + - main + +jobs: + commit-lint: + name: Conventional Commit PR commit messages + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v5.1.1 + with: + python-version: 3.11 + + - name: Create uv virtualenv + run: | + python -m pip install uv + uv venv .venv + echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV + echo "$PWD/.venv/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: uv pip install commitizen + + - name: Check commit messages + run: | + cz check \ + --rev-range ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \ + --allowed-prefixes 'Merge' 'Revert' 'Pull request' 'fixup!' 'squash!' diff --git a/.github/workflows/pr_title.yaml b/.github/workflows/pr_title.yaml new file mode 100644 index 0000000..d85d30e --- /dev/null +++ b/.github/workflows/pr_title.yaml @@ -0,0 +1,21 @@ +name: "Lint PR Title" + +on: + pull_request: + types: [opened, reopened, ready_for_review, synchronize, edited] + branches: + - dev + - staging + - main + +permissions: + pull-requests: read + +jobs: + lint-pr-title: + name: Conventional Commit PR title + runs-on: self-hosted + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 61dfbc26e169977f6951d6f00e600613448ef61c Mon Sep 17 00:00:00 2001 From: jarvis8x7b <157810922+jarvis8x7b@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:55:44 +0800 Subject: [PATCH 2/2] refactor: edits from pr feedback --- .github/workflows/commit-message.yaml | 2 +- .github/workflows/docker_build.yaml | 1 - .github/workflows/linter.yaml | 1 - .github/workflows/pr_title.yaml | 1 - .github/workflows/tests.yaml | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/commit-message.yaml b/.github/workflows/commit-message.yaml index 7b3475c..1625f05 100644 --- a/.github/workflows/commit-message.yaml +++ b/.github/workflows/commit-message.yaml @@ -2,7 +2,7 @@ name: "Lint PR Commit Messages" on: pull_request: - types: [opened, reopened, ready_for_review, synchronize, edited] + types: [opened, reopened, ready_for_review, synchronize] branches: - dev - main diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index ddda3a9..593b56c 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -4,7 +4,6 @@ on: push: branches: - dev - - staging - main - simulator diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index baf3e94..3c1a6ef 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -5,7 +5,6 @@ on: types: [opened, reopened, ready_for_review, synchronize] branches: - dev - - staging - main jobs: diff --git a/.github/workflows/pr_title.yaml b/.github/workflows/pr_title.yaml index d85d30e..69619c7 100644 --- a/.github/workflows/pr_title.yaml +++ b/.github/workflows/pr_title.yaml @@ -5,7 +5,6 @@ on: types: [opened, reopened, ready_for_review, synchronize, edited] branches: - dev - - staging - main permissions: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7f7e420..562f2f2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -5,7 +5,6 @@ # types: [opened, reopened, ready_for_review, synchronize] # branches: # - dev -# - staging # - main # jobs: