Skip to content

Commit

Permalink
fix_: many fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Aug 27, 2024
1 parent 47dc28a commit ce419d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
ref: ${{ env.GITHUB_HEAD_REF }}
fetch-tags: true

- name: Checkout branch
- name: Fetch tags
run: |
git fetch --tags --quiet
git checkout origin/${GITHUB_HEAD_REF}
Expand All @@ -38,15 +38,16 @@ jobs:
output=$(./_assets/scripts/commit_check.sh 2>&1)
exit_code=$?
error_message=$(echo "$output" | sed -n '2p')
has_breaking_changes=$(echo "$output" | sed -n '3p')
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT
echo "error_message=$error_message" >> $GITHUB_OUTPUT
echo "has_breaking_changes=$has_breaking_changes" >> $GITHUB_OUTPUT
if [[ $exit_code -ne 0 ]]; then
echo "error_message=$output" >> $GITHUB_OUTPUT
else
has_breaking_changes=$(echo "$output" | sed -n '2p')
echo "has_breaking_changes=$has_breaking_changes" >> $GITHUB_OUTPUT
fi
echo "OUTPUT: $output"
echo "RESULT: EXIT_CODE: $exit_code ERROR_MESSAGE: $error_message HAS_BREAKING_CHANGES: $has_breaking_changes"
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
Expand All @@ -57,18 +58,28 @@ jobs:
message: |
Thank you for opening this pull request!
We require pull request titles and commits to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/), but with `_` for non-breaking changes.
We require commits to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), but with `_` for non-breaking changes.
And it looks like your PR needs to be adjusted.
Details:
```
${{ steps.check_commit_message.outputs.exit_code }}
${{ steps.check_commit_message.outputs.error_message }}
${{ steps.check_commit_message.outputs.has_breaking_changes }}
```
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'true')
with:
header: commit-message-lint-error
message: |
Thank you for opening this pull request!
Looks like you have BREAKING CHANGES in your PR.
Please make sure to update [status-desktop](https://github.com/status-im/status-desktop) and [status-mobile](https://github.com/status-im/status-mobile) clients accordingly.
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.check_commit_message.outputs.exit_code == 0}}
- if: ${{ steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'false' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: commit-message-lint-error
Expand Down
13 changes: 8 additions & 5 deletions _assets/scripts/commit_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parse_commits() {
start_commit=${1:-origin/${BASE_BRANCH}}
end_commit=${2:-HEAD}
is_breaking_change=false
exit_code=0

echo "checking commits between: $start_commit $end_commit"
# Run the loop in the current shell using process substitution
Expand All @@ -18,16 +19,18 @@ parse_commits() {
# Check for breaking changes
if [[ ${BASH_REMATCH[3]} == *'!'* ]]; then
is_breaking_change=true
break
break # FIXME: This break shouldn't be here
fi
else
echo "Commit message \"$message\" is not well-formed. Aborting merge. We use https://www.conventionalcommits.org/en/v1.0.0/ but with _ for non-breaking changes"
echo "-"
exit 1
echo "Commit message \"$message\" is not well-formed"
exit_code=1
fi
done < <(git log --format=%s "$start_commit".."$end_commit")

echo "Commit messages are ok, thank you"
if [[ $exit_code -ne 0 ]]; then
exit ${exit_code}
fi

echo "$is_breaking_change"
}

Expand Down

0 comments on commit ce419d1

Please sign in to comment.