Skip to content

Commit 1dce3ec

Browse files
authored
ci: real conventional commits (#6838)
* ci: use real conventional commits * ci: fix actions by commit hash * chore_: delete empty unused file
1 parent 4c3f116 commit 1dce3ec

File tree

4 files changed

+23
-116
lines changed

4 files changed

+23
-116
lines changed

.custom-gcl.yml

Whitespace-only changes.

.github/workflows/commit-check.yml

Lines changed: 22 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,112 +4,40 @@ on:
44
pull_request:
55
types:
66
- opened
7-
- reopened
7+
- edited
88
- synchronize
9-
- labeled
10-
- unlabeled
119
jobs:
12-
lint_pr_commits:
13-
name: Validate commit messages
10+
main:
11+
name: Validate format
1412
runs-on: ubuntu-latest
1513
permissions:
1614
pull-requests: write
1715
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
21-
ref: ${{github.event.pull_request.head.ref}}
22-
repository: ${{github.event.pull_request.head.repo.full_name}}
23-
24-
- name: Check commit message
25-
id: check_commit_message
26-
if: always()
27-
run: |
28-
set +e
29-
30-
base_sha=${{ github.event.pull_request.base.sha }}
31-
head_sha=${{ github.event.pull_request.head.sha }}
32-
33-
output=$(./_assets/scripts/commit_check.sh "${base_sha}" "${head_sha}" 2>&1)
34-
exit_code=$?
35-
36-
echo "${output}" | sed '$d'
37-
echo "has_breaking_changes=${has_breaking_changes}"
38-
39-
echo "exit_code=${exit_code}" >> $GITHUB_OUTPUT
40-
41-
has_breaking_changes=$(echo "${output}" | tail -n 1)
42-
echo "has_breaking_changes=${has_breaking_changes}" >> $GITHUB_OUTPUT
43-
44-
invalid_commit_messages=$(echo "${output}" | sed '1d;$d')
45-
invalid_commit_messages=$(echo "${output}" | sed '1d;$d')
46-
invalid_commit_messages=$(echo "${invalid_commit_messages}" | sed 's/\x1b\[[0-9;]*m//g') # Remove color codes
47-
invalid_commit_messages=$(echo "${invalid_commit_messages}" | sed 's/^Commit message is ill-formed: //') # Remove prefix
48-
49-
if [[ $exit_code -ne 0 ]]; then
50-
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
51-
echo "error_message<<$EOF" >> "$GITHUB_ENV"
52-
echo "${invalid_commit_messages}" >> "$GITHUB_ENV"
53-
echo "$EOF" >> "$GITHUB_ENV"
54-
fi
55-
56-
- name: "Publish failed commit messages"
57-
uses: marocchino/sticky-pull-request-comment@v2
58-
# When the previous steps fails, the workflow would stop. By adding this
59-
# condition you can continue the execution with the populated error message.
60-
if: always() && (steps.check_commit_message.outputs.exit_code != 0)
61-
with:
62-
header: commit-message-lint-error
63-
message: |
64-
We require commits to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), but with `_` for non-breaking changes.
65-
Please fix these commit messages:
66-
```
67-
${{ env.error_message }}
68-
```
69-
70-
- name: "Publish breaking changes message"
71-
uses: marocchino/sticky-pull-request-comment@v2
16+
- uses: amannn/action-semantic-pull-request@fdd4d3ddf614fbcd8c29e4b106d3bbe0cb2c605d
17+
id: lint_pr_title
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
- uses: richard-ramos/[email protected]
21+
id: lint_pr_commits
22+
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
7223
# When the previous steps fails, the workflow would stop. By adding this
7324
# condition you can continue the execution with the populated error message.
74-
if: always() && (steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'true')
25+
if: always() && (steps.lint_pr_title.outputs.error_message != null || steps.lint_pr_commits.outputs.error_message != null )
7526
with:
76-
header: commit-message-lint-error
27+
header: pr-title-lint-error
7728
message: |
78-
Looks like you have BREAKING CHANGES in your PR.
79-
Please make sure to follow [💔How to introduce breaking changes](https://www.notion.so/How-to-introduce-breaking-changes-ded9ec2d91464a46a2593c0d8de62fbe?pvs=4) guide:
80-
81-
### Check-list
29+
Thank you for opening this pull request!
8230
83-
- [ ] Tried to avoid this breaking change
84-
- [ ] Updated [status-desktop](https://github.com/status-im/status-desktop)
85-
- [ ] Updated [status-mobile](https://github.com/status-im/status-mobile)
31+
We require pull request titles and commits to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your PR needs to be adjusted.
32+
33+
Details:
34+
35+
> ${{ steps.lint_pr_title.outputs.error_message }}
36+
> ${{ steps.lint_pr_commits.outputs.error_message }}
8637
8738
# Delete a previous comment when the issue has been resolved
88-
- name: "Delete previous comment"
89-
if: ${{ steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'false' }}
90-
uses: marocchino/sticky-pull-request-comment@v2
39+
- if: ${{ steps.lint_pr_title.outputs.error_message == null && steps.lint_pr_commits.outputs.error_message == null }}
40+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
9141
with:
92-
header: commit-message-lint-error
42+
header: pr-title-lint-error
9343
delete: true
94-
95-
- name: "Mark as failed"
96-
if: steps.check_commit_message.outputs.exit_code != 0
97-
uses: actions/github-script@v7
98-
with:
99-
script: |
100-
core.setFailed("Some commit messages are ill-formed")
101-
102-
- name: "Update breaking changes label"
103-
if: always()
104-
run: |
105-
if [[ $ADD_LABEL == 'true' ]]; then
106-
command="--add-label"
107-
else
108-
command="--remove-label"
109-
fi
110-
gh issue edit "$NUMBER" $command "breaking change"
111-
env:
112-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113-
GH_REPO: ${{ github.repository }}
114-
NUMBER: ${{ github.event.pull_request.number }}
115-
ADD_LABEL: ${{ steps.check_commit_message.outputs.has_breaking_changes == 'true' }}

.github/workflows/pr-lint.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

_assets/scripts/parse_commits.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ parse_commits() {
2222
# Run the loop in the current shell using process substitution
2323
while IFS= read -r message || [ -n "$message" ]; do
2424
# Check if commit message follows conventional commits format
25-
if [[ $message =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(\_|!):.*$ ]]; then
25+
if [[ $message =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(!)?:.*$ ]]; then
2626
# Check for breaking changes
2727
if [[ ${BASH_REMATCH[3]} == *'!'* ]]; then
2828
is_breaking_change=true

0 commit comments

Comments
 (0)