Skip to content

Commit

Permalink
Merge pull request #252 from mobusoperandi/ci-commit-msg-lint-action
Browse files Browse the repository at this point in the history
build: lint commit messages in ci using an action
  • Loading branch information
mightyiam authored Aug 25, 2023
2 parents 3f25057 + c29d324 commit 3e5637d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
with:
fetch-depth: 0 # for commit linting and semantic-release
persist-credentials: false
- uses: webiny/[email protected]
- run: rustup update
- uses: actions/cache@v3
with:
Expand Down
21 changes: 2 additions & 19 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ default_to_workspace = false

[env]
CARGO_TERM_COLOR = "always"
LINT_COMMIT_MSG_FROM_STDIN = "cargo bin conventional_commits_linter --allow-angular-type-only --from-stdin"

[tasks.pre-commit]
run_task = { name = ["test", "clippy", "doc", "check_fmt"], parallel = true }

[tasks.ci_main]
run_task = { name = ["test", "clippy", "doc", "check_fmt", "lint_pr_commit_msgs"], parallel = true }
run_task = { name = ["test", "clippy", "doc", "check_fmt"], parallel = true }

[tasks.ci_post]
run_task = { name = ["no_untracked", "no_modified", "release"] }
Expand Down Expand Up @@ -37,23 +36,7 @@ args = ["fmt", "--check"]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
$LINT_COMMIT_MSG_FROM_STDIN
'''

[tasks.lint_pr_commit_msgs]
condition = { env_true = ["GITHUB_BASE_REF"] }
script = '''
#!/usr/bin/env bash
set -euxo pipefail
# workaround for https://gitlab.com/DeveloperC/conventional_commits_linter/-/issues/1
commits=$(git rev-list --skip=1 origin/$GITHUB_BASE_REF..HEAD)
exit_code=0
for commit in $commits; do
git show --no-patch --format=%B $commit | \
$LINT_COMMIT_MSG_FROM_STDIN || \
exit_code=1
done
exit $exit_code
cargo bin conventional_commits_linter --allow-angular-type-only --from-stdin
'''

[tasks.table_of_contents]
Expand Down

0 comments on commit 3e5637d

Please sign in to comment.