Skip to content

Commit 6b3e50b

Browse files
committed
add shellcheck + fixes
1 parent 3fc4b73 commit 6b3e50b

File tree

6 files changed

+43
-35
lines changed

6 files changed

+43
-35
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ mypy: $(filter-out setup.py gittagger.py,${PYSOURCES})
171171
mypyc: ${PYSOURCES}
172172
MYPYPATH=typeshed/2and3/:typeshed/3 CWLTOOL_USE_MYPYC=1 pip install --verbose -e . && pytest --ignore cwltool/schemas --basetemp ./tmp
173173

174+
shellcheck: FORCE
175+
shellcheck build-cwl-docker.sh cwl-docker.sh release-test.sh travis.bash \
176+
cwltool-in-docker.sh
177+
174178
release-test: FORCE
175179
git diff-index --quiet HEAD -- || ( echo You have uncommited changes, please commit them and try again; false )
176180
./release-test.sh

build-cwl-docker.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ docker build --file=cwltool.Dockerfile --tag=commonworkflowlanguage/cwltool_modu
44
docker build --file=cwltool.Dockerfile --tag=commonworkflowlanguage/cwltool .
55

66
version=$(git describe --tags)
7-
echo $version | grep -vq '\-' >& /dev/null
8-
if [ $? -eq 0 ];then
9-
docker tag commonworkflowlanguage/cwltool_module commonworkflowlanguage/cwltool_module:$version
10-
docker tag commonworkflowlanguage/cwltool commonworkflowlanguage/cwltool:$version
7+
if echo "$version" | grep -vq '\-' >& /dev/null ; then
8+
docker tag commonworkflowlanguage/cwltool_module commonworkflowlanguage/cwltool_module:"$version"
9+
docker tag commonworkflowlanguage/cwltool commonworkflowlanguage/cwltool:"$version"
1110
fi

cwltool-in-docker.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
#!/usr/bin/env sh
2-
if [ \( ! -S /var/run/docker.sock \) -a \( -z "$DOCKER_HOST" \) ]; then
1+
#!/bin/sh
2+
if [ -S /var/run/docker.sock ] && [ -z "$DOCKER_HOST" ]; then
33
>&2 echo 'ERROR: cwltool cannot work inside a container without access to docker'
44
>&2 echo 'Launch the container with the option -v /var/run/docker.sock:/var/run/docker.sock'
5+
# shellcheck disable=SC2016
56
>&2 echo 'or launch the container with the option to set $DOCKER_HOST'
67
exit 1
78
elif [ "$PWD" = '/error' ]; then
89
>&2 echo 'ERROR: cwltool cannot work without access to the current path'
10+
# shellcheck disable=SC2016
911
>&2 echo 'Launch the container with the options -v "$PWD":"$PWD" -w="$PWD"'
1012
exit 1
1113
else

release-test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ run_tests() {
1414
local mod_loc
1515
mod_loc=$(pip show ${package} |
1616
grep ^Location | awk '{print $2}')/${module}
17-
${test_prefix}bin/py.test "--ignore=${mod_loc}/schemas/" \
17+
"${test_prefix}"bin/py.test "--ignore=${mod_loc}/schemas/" \
1818
--pyargs -x ${module} -n auto --dist=loadfile
1919
}
2020
pipver=7.0.2 # minimum required version of pip
@@ -81,9 +81,9 @@ source bin/activate
8181
rm lib/python-wheels/setuptools* \
8282
&& pip install --force-reinstall -U pip==${pipver} \
8383
&& pip install setuptools==${setuptoolsver} wheel
84-
package_tar=${package}*tar.gz
84+
package_tar=$(find . -name "${package}*tar.gz")
8585
pip install "-r${DIR}/test-requirements.txt"
86-
pip install ${package_tar} # [deps]
86+
pip install "${package_tar}" # [deps]
8787
mkdir out
8888
tar --extract --directory=out -z -f ${package}*.tar.gz
8989
cd out/${package}*

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ envlist =
55
py{36,37,38,39}-bandit,
66
py{36,37,38}-mypy,
77
py38-lint-readme,
8+
py38-shellcheck,
89
py38-pydocstyle
910

1011
skipsdist = True
@@ -24,14 +25,15 @@ description =
2425
py{36,37,38,39}-bandit: Search for common security issues
2526
py{36,37,38}-mypy: Check for type safety
2627
py38-pydocstyle: docstring style checker
28+
py38-shellcheck: syntax check for shell scripts
2729

2830
passenv =
2931
CI
3032
TRAVIS
3133
TRAVIS_*
3234
PROOT_NO_SECCOMP
3335
deps =
34-
-rrequirements.txt
36+
py{36,37,38,39}-{unit,lint,bandit,mypy}: -rrequirements.txt
3537
py{36,37,38,39}-unit: codecov
3638
py{36,37,38,39}-unit: pytest-xdist
3739
py{36,37,38,39}-unit: pytest-cov
@@ -58,11 +60,13 @@ commands =
5860
py{36,37,38,39}-lint: flake8 cwltool setup.py
5961
py{36,37,38}-mypy: make mypy
6062
py{36,37,38}-mypy: make mypyc
63+
py38-shellcheck: make shellcheck
6164

6265
whitelist_externals =
6366
py{36,37,38,39}-lint: flake8
6467
py{36,37,38,39}-lint: black
65-
py{36,37,38}-mypy: make
68+
py{36,37,38}-{mypy,shellcheck}: make
69+
py38-shellcheck: shellcheck
6670

6771
[testenv:py38-pydocstyle]
6872
whitelist_externals = make

travis.bash

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
#!/bin/bash
22
venv() {
33
if ! test -d "$1" ; then
4-
virtualenv -p python"${PYTHON_VERSION}" "$1"
4+
virtualenv -p python3 "$1"
55
fi
66
# shellcheck source=/dev/null
77
source "$1"/bin/activate
88
}
9-
9+
version=${version:-v1.0}
1010
if [[ "$version" = "v1.0" ]] ; then
1111
wget https://github.com/common-workflow-language/common-workflow-language/archive/main.tar.gz
1212
tar xzf main.tar.gz && rm main.tar.gz
1313
else
14-
repo=$(echo $version | sed 's/\(v[0-9]*\.\)\([0-9]*\).*/\1\2/')
15-
wget https://github.com/common-workflow-language/cwl-${repo}/archive/main.tar.gz
14+
# shellcheck disable=SC2001
15+
repo=$(echo "$version" | sed 's/\(v[0-9]*\.\)\([0-9]*\).*/\1\2/')
16+
wget https://github.com/common-workflow-language/cwl-"${repo}"/archive/main.tar.gz
1617
tar xzf main.tar.gz && rm main.tar.gz
1718
fi
1819

1920
docker pull node:slim
2021

21-
for PYTHON_VERSION in 3
22-
do
22+
# shellcheck disable=SC2043
2323
for CONTAINER in docker
2424
# for CONTAINER in docker singularity
2525
# singularity having issues on ci.commonwl.org; tests pass with https://gist.github.com/mr-c/0ec90d717617d074017c0cb38b72d1a4
2626
do
27-
venv cwltool-venv${PYTHON_VERSION}
28-
# use pip2.7 and pip3 in separate loop runs
29-
pip${PYTHON_VERSION} install -U setuptools wheel pip
30-
pip${PYTHON_VERSION} uninstall -y cwltool
31-
pip${PYTHON_VERSION} install -e .
32-
pip${PYTHON_VERSION} install "cwltest>=1.0.20180518074130" codecov
27+
venv cwltool-venv3
28+
pip3 install -U setuptools wheel pip
29+
pip3 uninstall -y cwltool
30+
pip3 install -e .
31+
pip3 install "cwltest>=1.0.20180518074130" codecov
3332
if [[ "$version" = "v1.0" ]]
3433
then
3534
DRAFT="DRAFT=v1.0"
3635
pushd common-workflow-language-main || exit 1
3736
else
38-
pushd cwl-${repo}-main || exit 1
37+
pushd cwl-"${repo}"-main || exit 1
3938
fi
4039
rm -f .coverage* coverage.xml
4140
source=$(realpath ../cwltool)
@@ -55,7 +54,7 @@ ignore_errors = True
5554
omit =
5655
tests/*
5756
EOF
58-
CWLTOOL_WITH_COV=${PWD}/cwltool_with_cov${PYTHON_VERSION}
57+
CWLTOOL_WITH_COV=${PWD}/cwltool_with_cov3
5958
cat > "${CWLTOOL_WITH_COV}" <<EOF
6059
#!/bin/bash
6160
coverage run --parallel-mode --rcfile=${COVERAGE_RC} \
@@ -76,17 +75,18 @@ EOF
7675
then
7776
EXTRA="EXTRA=${EXTRA}"
7877
fi
79-
if [ "$GIT_BRANCH" = "origin/main" ] && [[ "$version" = "v1.0" ]] && [[ "$CONTAINER" = "docker" ]] && [ $PYTHON_VERSION -eq 3 ]
78+
if [ "$GIT_BRANCH" = "origin/main" ] && [[ "$version" = "v1.0" ]] && [[ "$CONTAINER" = "docker" ]]
8079
then
8180
rm -Rf conformance
81+
# shellcheck disable=SC2154
8282
git clone http://"${jenkins_cwl_conformance}"@github.com/common-workflow-language/conformance.git
8383

8484
git -C conformance config user.email "[email protected]"
8585
git -C conformance config user.name "CWL Jenkins build bot"
8686
CONFORMANCE_MSG=$(cat << EOM
8787
Conformance test of cwltool ${tool_ver} for CWL ${version}
8888
Commit: ${GIT_COMMIT}
89-
Python version: ${PYTHON_VERSION}
89+
Python version: 3
9090
Container: ${CONTAINER}
9191
EOM
9292
)
@@ -98,28 +98,27 @@ EOM
9898
BADGE=" --badgedir=${badgedir}"
9999
fi
100100
# shellcheck disable=SC2086
101-
LC_ALL=C.UTF-8 ./run_test.sh --junit-xml=result${PYTHON_VERSION}.xml \
101+
LC_ALL=C.UTF-8 ./run_test.sh --junit-xml=result3.xml \
102102
RUNNER=${CWLTOOL_WITH_COV} "-j$(nproc)" ${BADGE} \
103103
${DRAFT} "${EXTRA}" \
104-
"--classname=py${PYTHON_VERSION}_${CONTAINER}"
104+
"--classname=py3_${CONTAINER}"
105105
# LC_ALL=C is to work around junit-xml ASCII only bug
106106
CODE=$((CODE+$?)) # capture return code of ./run_test.sh
107-
coverage combine "--rcfile=${COVERAGE_RC}" $(find . -name '.coverage.*')
107+
coverage combine "--rcfile=${COVERAGE_RC}" "$(find . -name '.coverage.*')"
108108
coverage xml "--rcfile=${COVERAGE_RC}"
109109
codecov --file coverage.xml
110110

111111
if [ -d conformance ]
112112
then
113-
rm -rf conformance/cwltool/cwl_${version}/cwltool_latest
114-
cp -r conformance/cwltool/cwl_${version}/cwltool_${tool_ver} conformance/cwltool/cwl_${version}/cwltool_latest
113+
rm -rf conformance/cwltool/cwl_"${version}"/cwltool_latest
114+
cp -r conformance/cwltool/cwl_"${version}"/cwltool_"${tool_ver}" conformance/cwltool/cwl_"${version}"/cwltool_latest
115115
git -C conformance add --all
116116
git -C conformance diff-index --quiet HEAD || git -C conformance commit -m "${CONFORMANCE_MSG}"
117-
git -C conformance push http://${jenkins_cwl_conformance}:[email protected]/common-workflow-language/conformance.git
117+
git -C conformance push http://"${jenkins_cwl_conformance}":[email protected]/common-workflow-language/conformance.git
118118
fi
119119

120120
deactivate
121-
popd
122-
done
121+
popd || exit
123122
done
124123
# build new docker container
125124
if [ "$GIT_BRANCH" = "origin/main" ] && [[ "$version" = "v1.0" ]]

0 commit comments

Comments
 (0)