99set -o errexit
1010set -o nounset
1111
12- check_commitlint () {
12+ check_commitlint () {
1313 from=${2:- master}
1414 to=${3:- HEAD}
1515 pr=${4:- [0-9]+}
@@ -31,7 +31,7 @@ check_commitlint () {
3131 # (iii) check absence of merge commits in feature branches
3232 if [ " $commit_number_of_parents " -gt 1 ]; then
3333 if echo " $commit_title " | grep -qE " ^chore\(.*\): merge " ; then
34- break # skip checking maint-to-master merge commits
34+ break # skip checking maint-to-master merge commits
3535 else
3636 echo " ✖ Merge commits are not allowed in feature branches: $commit_title "
3737 found=1
@@ -43,43 +43,47 @@ check_commitlint () {
4343 fi
4444}
4545
46- check_shellcheck () {
46+ check_shellcheck () {
4747 find . -name " *.sh" -exec shellcheck {} \+
4848}
4949
50- check_pydocstyle () {
50+ check_pydocstyle () {
5151 pydocstyle reana_workflow_engine_cwl
5252}
5353
54- check_black () {
54+ check_black () {
5555 black --check .
5656}
5757
58- check_flake8 () {
58+ check_flake8 () {
5959 flake8 .
6060}
6161
62- check_manifest () {
62+ check_manifest () {
6363 check-manifest
6464}
6565
66- check_sphinx () {
66+ check_sphinx () {
6767 sphinx-build -qnNW docs docs/_build/html
6868}
6969
70- check_pytest () {
70+ check_pytest () {
7171 pytest
7272}
7373
74- check_dockerfile () {
75- docker run -i --rm docker.io/hadolint/hadolint:v2.12.0 < Dockerfile
74+ check_dockerfile () {
75+ docker run -i --rm docker.io/hadolint/hadolint:v2.12.0 < Dockerfile
7676}
7777
78- check_docker_build () {
78+ check_docker_build () {
7979 docker build -t docker.io/reanahub/reana-workflow-engine-cwl .
8080}
8181
82- check_all () {
82+ check_shfmt () {
83+ shfmt -d .
84+ }
85+
86+ check_all () {
8387 check_commitlint
8488 check_shellcheck
8589 check_pydocstyle
@@ -90,6 +94,7 @@ check_all () {
9094 check_pytest
9195 check_dockerfile
9296 check_docker_build
97+ check_shfmt
9398}
9499
95100if [ $# -eq 0 ]; then
99104
100105arg=" $1 "
101106case $arg in
102- --check-commitlint) check_commitlint " $@ " ;;
103- --check-shellcheck) check_shellcheck;;
104- --check-pydocstyle) check_pydocstyle;;
105- --check-black) check_black;;
106- --check-flake8) check_flake8;;
107- --check-manifest) check_manifest;;
108- --check-sphinx) check_sphinx;;
109- --check-pytest) check_pytest;;
110- --check-dockerfile) check_dockerfile;;
111- --check-docker-build) check_docker_build;;
112- * ) echo " [ERROR] Invalid argument '$arg '. Exiting." && exit 1;;
107+ --check-commitlint) check_commitlint " $@ " ;;
108+ --check-shellcheck) check_shellcheck ;;
109+ --check-pydocstyle) check_pydocstyle ;;
110+ --check-black) check_black ;;
111+ --check-flake8) check_flake8 ;;
112+ --check-manifest) check_manifest ;;
113+ --check-sphinx) check_sphinx ;;
114+ --check-pytest) check_pytest ;;
115+ --check-dockerfile) check_dockerfile ;;
116+ --check-docker-build) check_docker_build ;;
117+ --check-shfmt) check_shfmt ;;
118+ --check-all) check_all ;;
119+ * ) echo " [ERROR] Invalid argument '$arg '. Exiting." && exit 1 ;;
113120esac
0 commit comments