mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
ci: add commit message check
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# check whether there was a change to libs that need to be built
|
||||
|
||||
for path in "packages/components" "packages/blockchain-link" "packages/suite-storage"
|
||||
do
|
||||
diff="$(git diff HEAD^ --name-only --diff-filter=ACMR "$path")"
|
||||
if [ ! -z "$diff" ]
|
||||
then
|
||||
yarn build:libs
|
||||
fi
|
||||
done
|
||||
|
||||
# check whether yarn.lock changed and if yes call yarn install
|
||||
|
||||
for path in "yarn.lock"
|
||||
do
|
||||
diff="$(git diff HEAD^ --name-only --diff-filter=ACMR "$path")"
|
||||
if [ ! -z "$diff" ]
|
||||
then
|
||||
yarn
|
||||
fi
|
||||
done
|
||||
12
.github/workflows/commit-messages-check.yml
vendored
Normal file
12
.github/workflows/commit-messages-check.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: "[Check]: Commit messages"
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
commit-message-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check commit messages
|
||||
run: ./scripts/check-commit-messages.sh
|
||||
@@ -1,6 +1,6 @@
|
||||
# Commits
|
||||
|
||||
Using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) is strongly recommended and might be enforced in future.
|
||||
Using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) is enforced by a CI check.
|
||||
|
||||
### Examples
|
||||
|
||||
@@ -12,7 +12,7 @@ feat(lang): added polish language
|
||||
|
||||
### Git hook
|
||||
|
||||
Use this git hook to auto-check your commit messages. Save the following snippet into `.git/hooks/commit-msg`
|
||||
Use this git hook to auto-check your commit messages. Save the following snippet into `.git/hooks/commit-msg`. This way, the check will run locally and can avoid some unnecessary CI runs.
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
@@ -23,7 +23,7 @@ if echo "$commit_msg" | grep -qE "^(Revert|fixup! )"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! grep -qE "^(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)(\([a-z\-]+\))?: " "$1" ; then
|
||||
if ! grep -qE "^(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)(\([a-z, -]+\))?: " "$1" ; then
|
||||
echo "Conventional Commits validation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -51,7 +51,7 @@ Run a dev build:
|
||||
|
||||
Inspired by [GitLab Contributing Guide](https://docs.gitlab.com/ee/development/contributing/)
|
||||
|
||||
Using [Conventional Commits](COMMITS.md) is strongly recommended.
|
||||
Using [Conventional Commits](COMMITS.md) is required.
|
||||
|
||||
## Security vulnerability disclosure
|
||||
|
||||
|
||||
15
scripts/check-commit-messages.sh
Executable file
15
scripts/check-commit-messages.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
for commit in $(git rev-list origin/HEAD..HEAD); do
|
||||
|
||||
commit_msg=$(git log --format=%B -n 1 "$commit")
|
||||
|
||||
# Skip validation in case of fixup and revert commits
|
||||
if echo "$commit_msg" | grep -qE "^(Revert|fixup! )"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! echo "$commit_msg" | grep -qE "^(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)(\([a-z, -]+\))?: "; then
|
||||
echo "Conventional Commits validation failed for commit $commit: $commit_msg"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user