Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 043b319

Browse files
Adding shellcheck to openverse-api (#922)
* adding shellcheck to openverse-api Signed-off-by: MustkimKhatik <[email protected]> * Update .pre-commit-config.yaml trailing newline * Update run_test.sh syntax correction in run_test.sh * Update run_test.sh Some corrections in run_test * Update run_test.sh some corrections in run_test * Update run_test.sh syntax correction in ingestion_sever/run_test.sh * Update update_mocks.sh syntax correction in update_mocks.sh * Update run_test.sh syntax correction in run_test.sh * Update run_test.sh * correction of SC2181 syntax correction in load_sample.sh * Fix EOL at EOF * Remove stray spaces from end of line * Remove extra fullstop * Replace `%s` with `%b` for ANSI color codes Signed-off-by: MustkimKhatik <[email protected]> Co-authored-by: Dhruv Bhanushali <[email protected]>
1 parent 0746fdd commit 043b319

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ repos:
4747
hooks:
4848
- id: prettier
4949
types: [yaml]
50+
- repo: https://github.com/koalaman/shellcheck-precommit
51+
rev: v0.8.0
52+
hooks:
53+
- id: shellcheck

api/test/run_test.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ endcol="\e[0m"
99
# $ ./test/run_test.sh test/audio_integration_test.py
1010
# ```
1111
if [ $# -ge 1 ]; then
12-
TEST_ARG="$@"
12+
TEST_ARG=( "$@" )
1313
else
14-
TEST_ARG="test/"
14+
TEST_ARG=( "test/" )
1515
fi
1616

1717
PYTHONWARNINGS="ignore:Unverified HTTPS request" \
1818
PYTHONPATH=. \
19-
pytest -s --disable-pytest-warnings $TEST_ARG
19+
pytest -s --disable-pytest-warnings "${TEST_ARG[@]}"
2020

2121
succeeded=$?
2222
if [[ $succeeded -eq 0 ]]; then
23-
printf "${green}:-) All tests passed${endcol}\n"
23+
printf "%b:-) All tests passed${endcol}\n" "${green}"
2424
else
25-
printf "\n\n${red}:'( Some tests did not pass${endcol}\n"
25+
printf "\n\n%b:'( Some tests did not pass${endcol}\n" "${red}"
2626
printf "Hint: \`just logs [service]\` will print the Docker logs and may be helpful for debugging.\n\n"
2727
fi
2828
exit $succeeded

ingestion_server/test/run_test.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ endcol="\e[0m"
99
# $ ./test/run_test.sh test/unit_test.py
1010
# ```
1111
if [ $# -ge 1 ]; then
12-
TEST_ARG="$@"
12+
TEST_ARG=( "$@" )
1313
else
14-
TEST_ARG="test/"
14+
TEST_ARG=( "test/" )
1515
fi
1616

1717
PYTHONWARNINGS="ignore:Unverified HTTPS request" \
1818
PYTHONPATH=. \
19-
pytest -sx -vv --disable-pytest-warnings $TEST_ARG
19+
pytest -sx -vv --disable-pytest-warnings "${TEST_ARG[@]}"
2020

2121
succeeded=$?
2222
if [[ $succeeded -eq 0 ]]; then
23-
printf "${green}:-) All tests passed${endcol}\n"
23+
printf "%b:-) All tests passed${endcol}\n" "${green}"
2424
else
25-
printf "${red}:'( Some tests did not pass${endcol}\n"
25+
printf "\n\n%b:'( Some tests did not pass${endcol}\n" "${red}"
2626
fi
2727
exit $succeeded

ingestion_server/test/update_mocks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ docker run \
4040

4141
green="\e[32m"
4242
endcol="\e[0m"
43-
printf "${green}:-) Exported new mock data${endcol}\n"
43+
printf "%b:-) Exported new mock data${endcol}\n" "${green}"

load_sample_data.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ just wait-for-index "audio"
112112
set +e
113113
while true; do
114114
just ingest-upstream "image" "init"
115-
just wait-for-index "image-init"
116-
if [ $? -eq 0 ]; then
115+
if just wait-for-index "image-init"
116+
then
117117
break
118118
fi
119119
((c++)) && ((c==3)) && break

0 commit comments

Comments
 (0)