Skip to content

Commit daaf9a2

Browse files
authored
[TECHNICAL] Reusable workflow to validate conventional commits (#4832)
* refactor: use reusable workflow to validate conventional commits * chore: add calens file
1 parent 9163566 commit daaf9a2

2 files changed

Lines changed: 6 additions & 60 deletions

File tree

.github/workflows/conventional-commits.yml

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,4 @@ permissions:
1111

1212
jobs:
1313
validate-commit-names:
14-
name: Check Commit Names
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
# Checkout the repository
19-
- name: Checkout repository
20-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
21-
with:
22-
# Limit of validation to skip fetching all existing commits
23-
fetch-depth: 100
24-
25-
# Validate commit messages
26-
- name: Validate all commit messages
27-
run: |
28-
echo "Validating all commit names in PR #${{ github.event.pull_request.number }}"
29-
30-
# Get the base branch and the PR branch
31-
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
32-
33-
# Fetch the base branch with no verbosity
34-
git fetch --quiet origin "$BASE_BRANCH"
35-
36-
# Get all commits in the PR (not the base branch ones)
37-
# --pretty=format:"%s" gets only the commit message
38-
mapfile -t commits_array < <(git log origin/$BASE_BRANCH..HEAD --pretty=format:'%s')
39-
40-
# Regex pattern for valid Conventional Commit
41-
regex='^(docs|fix|feat|chore|refactor|test|style|build|ci): [a-z].{9,}$'
42-
43-
# Variable to count errors
44-
fail=0
45-
46-
echo "Commit list and validation:"
47-
48-
# Print and validate
49-
for commitmsg in "${commits_array[@]}"; do
50-
echo "$commitmsg"
51-
52-
# Skip merge and [tx] commits
53-
if [[ "$commitmsg" =~ ^Merge ]] || [[ "$commitmsg" =~ ^\[tx\] ]] || [[ "$commitmsg" =~ SBOM\ updated ]]; then
54-
echo " 🚫 Ignored commit"
55-
continue
56-
fi
57-
58-
# Validate Conventional Commit
59-
if ! [[ "$commitmsg" =~ $regex ]]; then
60-
echo " ❌ Invalid commit"
61-
fail=$((fail+1))
62-
else
63-
echo " ✅ Valid commit"
64-
fi
65-
done
66-
67-
# Fail the job if there are any invalid commits
68-
if [[ $fail -gt 0 ]]; then
69-
echo "❌ $fail commit(s) do(es) not follow the Conventional Commits convention"
70-
exit 1
71-
else
72-
echo "✅ All commits follow the Conventional Commits convention"
73-
fi
14+
uses: owncloud/reusable-workflows/.github/workflows/semantic-git-message.yml@main

changelog/unreleased/4832

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Change: Use reusable workflow for Conventional commits
2+
3+
A new reusable workflow to validate Conventional commits has been added to the current workflow in order to be used by all clients
4+
5+
https://github.com/owncloud/android/pull/4832

0 commit comments

Comments
 (0)