-
Notifications
You must be signed in to change notification settings - Fork 10
/
run-tests.sh
executable file
·49 lines (43 loc) · 1.02 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
#
# This file is part of REANA.
# Copyright (C) 2024 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
set -o errexit
set -o nounset
check_commitlint () {
from=${2:-master}
to=${3:-HEAD}
npx commitlint --from="$from" --to="$to"
found=0
while IFS= read -r line; do
if echo "$line" | grep -qP "\(\#[0-9]+\)$"; then
true
else
echo "✖ PR number missing in $line"
found=1
fi
done < <(git log "$from..$to" --format="%s")
if [ $found -gt 0 ]; then
exit 1
fi
}
check_shellcheck () {
find . -name "*.sh" -exec shellcheck {} \;
}
check_all () {
check_commitlint
check_shellcheck
}
if [ $# -eq 0 ]; then
check_all
exit 0
fi
arg="$1"
case $arg in
--check-commitlint) check_commitlint "$@";;
--check-shellcheck) check_shellcheck;;
*) echo "[ERROR] Invalid argument '$arg'. Exiting." && exit 1;;
esac