Skip to content

Commit 2e674c2

Browse files
ci(shfmt): fix shfmt test not passing (reanahub#491)
1 parent cbdd7ab commit 2e674c2

1 file changed

Lines changed: 66 additions & 66 deletions

File tree

run-tests.sh

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,93 +9,93 @@
99
set -o errexit
1010
set -o nounset
1111

12-
check_commitlint () {
13-
from=${2:-master}
14-
to=${3:-HEAD}
15-
pr=${4:-[0-9]+}
16-
npx commitlint --from="$from" --to="$to"
17-
found=0
18-
while IFS= read -r line; do
19-
commit_hash=$(echo "$line" | cut -d ' ' -f 1)
20-
commit_title=$(echo "$line" | cut -d ' ' -f 2-)
21-
commit_number_of_parents=$(git rev-list --parents "$commit_hash" -n1 | awk '{print NF-1}')
22-
# (i) skip checking release commits generated by Release Please
23-
if [ "$commit_number_of_parents" -le 1 ] && echo "$commit_title" | grep -qE "^chore\(.*\): release"; then
24-
continue
25-
fi
26-
# (ii) check presence of PR number
27-
if ! echo "$commit_title" | grep -qE "\(#$pr\)$"; then
28-
echo "✖ Headline does not end by '(#$pr)' PR number: $commit_title"
29-
found=1
30-
fi
31-
# (iii) check absence of merge commits in feature branches
32-
if [ "$commit_number_of_parents" -gt 1 ]; then
33-
if echo "$commit_title" | grep -qE "^chore\(.*\): merge "; then
34-
break # skip checking maint-to-master merge commits
35-
else
36-
echo "✖ Merge commits are not allowed in feature branches: $commit_title"
37-
found=1
38-
fi
39-
fi
40-
done < <(git log "$from..$to" --format="%H %s")
41-
if [ $found -gt 0 ]; then
42-
exit 1
43-
fi
12+
check_commitlint() {
13+
from=${2:-master}
14+
to=${3:-HEAD}
15+
pr=${4:-[0-9]+}
16+
npx commitlint --from="$from" --to="$to"
17+
found=0
18+
while IFS= read -r line; do
19+
commit_hash=$(echo "$line" | cut -d ' ' -f 1)
20+
commit_title=$(echo "$line" | cut -d ' ' -f 2-)
21+
commit_number_of_parents=$(git rev-list --parents "$commit_hash" -n1 | awk '{print NF-1}')
22+
# (i) skip checking release commits generated by Release Please
23+
if [ "$commit_number_of_parents" -le 1 ] && echo "$commit_title" | grep -qE "^chore\(.*\): release"; then
24+
continue
25+
fi
26+
# (ii) check presence of PR number
27+
if ! echo "$commit_title" | grep -qE "\(#$pr\)$"; then
28+
echo "✖ Headline does not end by '(#$pr)' PR number: $commit_title"
29+
found=1
30+
fi
31+
# (iii) check absence of merge commits in feature branches
32+
if [ "$commit_number_of_parents" -gt 1 ]; then
33+
if echo "$commit_title" | grep -qE "^chore\(.*\): merge "; then
34+
break # skip checking maint-to-master merge commits
35+
else
36+
echo "✖ Merge commits are not allowed in feature branches: $commit_title"
37+
found=1
38+
fi
39+
fi
40+
done < <(git log "$from..$to" --format="%H %s")
41+
if [ $found -gt 0 ]; then
42+
exit 1
43+
fi
4444
}
4545

46-
check_shellcheck () {
47-
find . -name "*.sh" -exec shellcheck {} \+
46+
check_shellcheck() {
47+
find . -name "*.sh" -exec shellcheck {} \+
4848
}
4949

50-
check_pydocstyle () {
51-
pydocstyle reana_commons
50+
check_pydocstyle() {
51+
pydocstyle reana_commons
5252
}
5353

54-
check_black () {
55-
black --check .
54+
check_black() {
55+
black --check .
5656
}
5757

58-
check_flake8 () {
59-
flake8 .
58+
check_flake8() {
59+
flake8 .
6060
}
6161

62-
check_manifest () {
63-
check-manifest
62+
check_manifest() {
63+
check-manifest
6464
}
6565

66-
check_sphinx () {
67-
sphinx-build -qnNW docs docs/_build/html
66+
check_sphinx() {
67+
sphinx-build -qnNW docs docs/_build/html
6868
}
6969

70-
check_pytest () {
71-
pytest
70+
check_pytest() {
71+
pytest
7272
}
7373

74-
check_all () {
75-
check_commitlint
76-
check_shellcheck
77-
check_pydocstyle
78-
check_black
79-
check_flake8
80-
check_manifest
81-
check_sphinx
82-
check_pytest
74+
check_all() {
75+
check_commitlint
76+
check_shellcheck
77+
check_pydocstyle
78+
check_black
79+
check_flake8
80+
check_manifest
81+
check_sphinx
82+
check_pytest
8383
}
8484

8585
if [ $# -eq 0 ]; then
86-
check_all
87-
exit 0
86+
check_all
87+
exit 0
8888
fi
8989

9090
arg="$1"
9191
case $arg in
92-
--check-commitlint) check_commitlint "$@";;
93-
--check-shellcheck) check_shellcheck;;
94-
--check-pydocstyle) check_pydocstyle;;
95-
--check-black) check_black;;
96-
--check-flake8) check_flake8;;
97-
--check-manifest) check_manifest;;
98-
--check-sphinx) check_sphinx;;
99-
--check-pytest) check_pytest;;
100-
*) echo "[ERROR] Invalid argument '$arg'. Exiting." && exit 1;;
92+
--check-commitlint) check_commitlint "$@" ;;
93+
--check-shellcheck) check_shellcheck ;;
94+
--check-pydocstyle) check_pydocstyle ;;
95+
--check-black) check_black ;;
96+
--check-flake8) check_flake8 ;;
97+
--check-manifest) check_manifest ;;
98+
--check-sphinx) check_sphinx ;;
99+
--check-pytest) check_pytest ;;
100+
*) echo "[ERROR] Invalid argument '$arg'. Exiting." && exit 1 ;;
101101
esac

0 commit comments

Comments
 (0)