Skip to content

Commit a7bcee1

Browse files
authored
pre-commit run -a shellcheck (#2054)
* pre-commit run -a shellcheck * Add copyright
1 parent 5ea59e7 commit a7bcee1

File tree

5 files changed

+70
-29
lines changed

5 files changed

+70
-29
lines changed
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/bin/bash
2+
# Copyright 2020 The ElasticDL Authors. All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
214

315
TOTAL_ERRORS=0
416
if [[ ! $TRAVIS_BRANCH ]]; then
@@ -7,21 +19,23 @@ if [[ ! $TRAVIS_BRANCH ]]; then
719
pip install cpplint
820
fi
921
# diff files on local machine.
10-
files=$(git diff --cached --name-status | awk 'Extra open brace or missing close brace2}')
22+
files=$(git diff --cached --name-status | \
23+
awk 'Extra open brace or missing close brace2}')
1124
else
1225
# diff files between PR and latest commit on Travis CI.
1326
branch_ref=$(git rev-parse "$TRAVIS_BRANCH")
1427
head_ref=$(git rev-parse HEAD)
15-
files=$(git diff --name-status $branch_ref $head_ref | awk 'Extra open brace or missing close brace2}')
28+
files=$(git diff --name-status "$branch_ref" "$head_ref" | \
29+
awk 'Extra open brace or missing close brace2}')
1630
fi
1731
# The trick to remove deleted files: https://stackoverflow.com/a/2413151
1832
for file in $files; do
1933
if [[ $file =~ ^(patches/.*) ]]; then
2034
continue;
2135
else
22-
cpplint --filter=-readability/fn_size $file;
23-
TOTAL_ERRORS=$(expr $TOTAL_ERRORS + $?);
36+
cpplint --filter=-readability/fn_size "$file";
37+
TOTAL_ERRORS=$(( TOTAL_ERRORS + $? ));
2438
fi
2539
done
2640

27-
exit $TOTAL_ERRORS
41+
exit "$TOTAL_ERRORS"

scripts/travis/cleanup_odps_table.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
#!/bin/bash
2+
# Copyright 2020 The ElasticDL Authors. All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
docker run --rm -it \
2-
-e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE \
3-
-e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT \
4-
-e MAXCOMPUTE_AK=$ODPS_ACCESS_ID \
5-
-e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY \
6-
-v $PWD:/work \
16+
-e MAXCOMPUTE_TABLE="$MAXCOMPUTE_TABLE" \
17+
-e MAXCOMPUTE_PROJECT="$MAXCOMPUTE_PROJECT" \
18+
-e MAXCOMPUTE_AK="$ODPS_ACCESS_ID" \
19+
-e MAXCOMPUTE_SK="$ODPS_ACCESS_KEY" \
20+
-v "$PWD":/work \
721
-w /work \
822
elasticdl:dev \
923
bash -c 'python -c '`

scripts/travis/create_odps_table.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
#!/bin/bash
2+
# Copyright 2020 The ElasticDL Authors. All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
docker run --rm -it \
2-
-e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE \
3-
-e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT \
4-
-e MAXCOMPUTE_AK=$ODPS_ACCESS_ID \
5-
-e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY \
6-
-v $PWD:/work -w /work elasticdl:dev bash \
16+
-e MAXCOMPUTE_TABLE="$MAXCOMPUTE_TABLE" \
17+
-e MAXCOMPUTE_PROJECT="$MAXCOMPUTE_PROJECT" \
18+
-e MAXCOMPUTE_AK="$ODPS_ACCESS_ID" \
19+
-e MAXCOMPUTE_SK="$ODPS_ACCESS_KEY" \
20+
-v "$PWD":/work -w /work elasticdl:dev bash \
721
-c 'python -c '`
822
`'"from elasticdl.python.tests.test_utils import *;'`
923
`'create_iris_odps_table_from_env()"'

scripts/travis/run_job.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# Copyright 2020 The ElasticDL Authors. All rights reserved.
23
# Licensed under the Apache License, Version 2.0 (the "License");
34
# you may not use this file except in compliance with the License.
@@ -12,6 +13,7 @@
1213
# limitations under the License.
1314

1415
JOB_TYPE=$1
16+
MAXCOMPUTE_TABLE="odps_integration_build_$TRAVIS_BUILD_NUMBER_$(date +%s)"
1517

1618
if [[ "$JOB_TYPE" == "odps" ]] && \
1719
{ [[ "$ODPS_ACCESS_ID" == "" ]] || \
@@ -21,26 +23,23 @@ if [[ "$JOB_TYPE" == "odps" ]] && \
2123
else
2224
echo "Running ElasticDL job: ${JOB_TYPE}"
2325
if [[ "$JOB_TYPE" == "odps" ]]; then
24-
export MAXCOMPUTE_TABLE="odps_integration_build_"`
25-
`"${TRAVIS_BUILD_NUMBER}_$(date +%s)"
26+
export MAXCOMPUTE_TABLE
2627
bash scripts/travis/create_odps_table.sh
2728
fi
2829
PS_NUM=2
2930
WORKER_NUM=1
3031
docker run --rm -it --net=host \
31-
-e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE \
32-
-e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT \
33-
-e MAXCOMPUTE_AK=$ODPS_ACCESS_ID \
34-
-e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY \
32+
-e MAXCOMPUTE_TABLE="$MAXCOMPUTE_TABLE" \
33+
-e MAXCOMPUTE_PROJECT="$MAXCOMPUTE_PROJECT" \
34+
-e MAXCOMPUTE_AK="$ODPS_ACCESS_ID" \
35+
-e MAXCOMPUTE_SK="$ODPS_ACCESS_KEY" \
3536
-v /var/run/docker.sock:/var/run/docker.sock \
36-
-v $HOME/.kube:/root/.kube \
37-
-v /home/$USER/.minikube/:/home/$USER/.minikube/ \
38-
-v $(pwd):/work \
37+
-v "$HOME"/.kube:/root/.kube \
38+
-v /home/"$USER"/.minikube/:/home/"$USER"/.minikube/ \
39+
-v "$PWD":/work \
3940
-w /work elasticdl:ci \
40-
bash -c "scripts/client_test.sh \
41-
${JOB_TYPE} ${PS_NUM} ${WORKER_NUM}"
42-
python3 scripts/validate_job_status.py \
43-
${JOB_TYPE} ${PS_NUM} ${WORKER_NUM}
41+
bash -c "scripts/client_test.sh $JOB_TYPE $PS_NUM $WORKER_NUM"
42+
python3 scripts/validate_job_status.py "$JOB_TYPE" "$PS_NUM" "$WORKER_NUM"
4443
if [[ "$JOB_TYPE" == "odps" ]]; then
4544
bash scripts/travis/cleanup_odps_table.sh
4645
fi

scripts/travis/start_minikube.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ touch "$KUBECONFIG"
4848
sudo minikube start --vm-driver=none --kubernetes-version="$K8S_VERSION"
4949
kubectl cluster-info
5050

51-
eval $(sudo minikube docker-env)
51+
eval "$(sudo minikube docker-env)"

0 commit comments

Comments
 (0)