Skip to content

Commit b9b6f55

Browse files
committed
ci: adding Convention Commits linting
1 parent a4c1ce4 commit b9b6f55

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Conventional Commits
2+
3+
on: pull_request
4+
5+
env:
6+
# Forcing Earthly to use colours, to make reading output easier.
7+
FORCE_COLOR: 1
8+
9+
jobs:
10+
linting:
11+
name: Linting
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Download Earthly v0.8.6.
15+
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
16+
- name: Checkout code.
17+
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ github.event.pull_request.head.sha }}
20+
fetch-depth: 0
21+
- name: Check Conventional Commits linting.
22+
run: earthly --ci +check-conventional-commits-linting --from_reference "origin/${{ github.base_ref }}"

Earthfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ check-clean-git-history:
2525
RUN ./ci/check-clean-git-history.sh --from-reference "${from_reference}"
2626

2727

28+
check-conventional-commits-linting:
29+
FROM +rust-base
30+
RUN cargo install conventional_commits_linter --version 0.12.3 --locked
31+
DO +COPY_METADATA
32+
ARG from_reference="origin/HEAD"
33+
RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}"
34+
35+
2836
check-github-actions-workflows-linting:
2937
FROM golang:1.20.13
3038
RUN go install github.com/rhysd/actionlint/cmd/[email protected]

check-conventional-commits-linting.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# ARG_OPTIONAL_SINGLE([from-reference],[],[],[origin/HEAD])
4+
# ARGBASH_GO()
5+
# needed because of Argbash --> m4_ignore([
6+
### START OF CODE GENERATED BY Argbash v2.9.0 one line above ###
7+
# Argbash is a bash code generator used to get arguments parsing right.
8+
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
9+
# Generated online by https://argbash.io/generate
10+
11+
die() {
12+
local _ret="${2:-1}"
13+
test "${_PRINT_HELP:-no}" = yes && print_help >&2
14+
echo "$1" >&2
15+
exit "${_ret}"
16+
}
17+
18+
begins_with_short_option() {
19+
local first_option all_short_options=''
20+
first_option="${1:0:1}"
21+
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
22+
}
23+
24+
# THE DEFAULTS INITIALIZATION - OPTIONALS
25+
_arg_from_reference="origin/HEAD"
26+
27+
print_help() {
28+
printf 'Usage: %s [--from-reference <arg>]\n' "$0"
29+
}
30+
31+
parse_commandline() {
32+
while test $# -gt 0; do
33+
_key="$1"
34+
case "$_key" in
35+
--from-reference)
36+
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
37+
_arg_from_reference="$2"
38+
shift
39+
;;
40+
--from-reference=*)
41+
_arg_from_reference="${_key##--from-reference=}"
42+
;;
43+
*)
44+
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
45+
;;
46+
esac
47+
shift
48+
done
49+
}
50+
51+
parse_commandline "$@"
52+
53+
# OTHER STUFF GENERATED BY Argbash
54+
55+
### END OF CODE GENERATED BY Argbash (sortof) ### ])
56+
# [ <-- needed because of Argbash
57+
set -o errexit
58+
set -o xtrace
59+
60+
"${CARGO_HOME}/bin/conventional_commits_linter" --from-reference "${_arg_from_reference}" --allow-angular-type-only
61+
# ] <-- needed because of Argbash

0 commit comments

Comments
 (0)