]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
.github/workflows: Add commit and PR format checks 1139/head
authorCezar Craciunoiu <cezar.craciunoiu@gmail.com>
Mon, 16 Oct 2023 12:50:53 +0000 (15:50 +0300)
committerCezar Craciunoiu <cezar.craciunoiu@gmail.com>
Thu, 2 Nov 2023 15:28:20 +0000 (17:28 +0200)
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
.github/workflows/commit-format-check.yaml [new file with mode: 0644]

diff --git a/.github/workflows/commit-format-check.yaml b/.github/workflows/commit-format-check.yaml
new file mode 100644 (file)
index 0000000..6d50fa2
--- /dev/null
@@ -0,0 +1,72 @@
+name: Commits Formatting Check
+
+on:
+  push:
+    branches: [staging, stable]
+  pull_request:
+    types: [opened, synchronize, reopened]
+    branches: [staging]
+
+jobs:
+  commit:
+    name: Commit and PR Format Check
+    runs-on: ubuntu-latest
+    steps:
+      - name: Commit Lines Length Check
+        if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }}
+        uses: gsactions/commit-message-checker@v2
+        with:
+          pattern: '((^(?=(?:.|\n)*(?:^|\n)\[\d\]: .{69,}(?:$|\n)(?:.|\n)*)(?:.|\n)*$)|(^(?!(?:.|\n)*(?:^|\n).{74,}(?:$|\n)(?:.|\n)*)(?:.|\n)*$))'
+          flags: ''
+          error: 'The maximum line length of 74 characters is exceeded.'
+          excludeDescription: 'true'
+          excludeTitle: 'true'
+          checkAllCommitMessages: 'true'
+          accessToken: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Signed-off-by Check
+        if: always()
+        uses: gsactions/commit-message-checker@v2
+        with:
+          pattern: '^Signed-off-by: .+ \<.+\@.+\..+\>$'
+          error: 'Signed-off-by line is missing.'
+          excludeDescription: 'true'
+          excludeTitle: 'true'
+          checkAllCommitMessages: 'true'
+          accessToken: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: PR Title Check
+        if: always()
+        uses: gsactions/commit-message-checker@v2
+        with:
+          pattern: '^((([a-z0-9\/\.\-\_\*])+)|(\{([a-z0-9\/\.\-\_\*]+, )+[a-z0-9\/\.\-\_\*]+\})){1}: [A-Z0-9].*'
+          error: 'The PR title must follow the conventional commits format.'
+          excludeDescription: 'true'
+          excludeTitle: 'false'
+          checkAllCommitMessages: 'false'
+          accessToken: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: PR Title Check Length
+        if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }}
+        uses: gsactions/commit-message-checker@v2
+        with:
+          pattern: '^(?!.{75,}).*'
+          flags: ''
+          error: 'The maximum line length of 75 characters is exceeded.'
+          excludeDescription: 'true'
+          excludeTitle: 'false'
+          checkAllCommitMessages: 'false'
+          accessToken: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: PR Description Check
+        if: ${{ github.actor != 'dependabot' && github.actor != 'dependabot[bot]' }}
+        uses: gsactions/commit-message-checker@v2
+        with:
+          pattern: '^\S+( \S+)*$'
+          error: 'The PR description must not be empty.'
+          flags: 'gm'
+          excludeDescription: 'false'
+          excludeTitle: 'true'
+          checkAllCommitMessages: 'false'
+          accessToken: ${{ secrets.GITHUB_TOKEN }}
+