diff --git a/.circleci/config.yml b/.circleci/config.yml index bfadb1139..d3bc4a068 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -287,9 +287,15 @@ jobs: - image: buildpack-deps:disco steps: - checkout + - run: + name: Install shellcheck + command: apt -q update && apt install -y shellcheck - run: name: Check for C++ coding style command: ./scripts/check_style.sh + - run: + name: checking shell scripts + command: ./scripts/chk_shellscripts/chk_shellscripts.sh chk_pylint: docker: diff --git a/scripts/chk_shellscripts/chk_shellscripts.sh b/scripts/chk_shellscripts/chk_shellscripts.sh new file mode 100755 index 000000000..8eccc5517 --- /dev/null +++ b/scripts/chk_shellscripts/chk_shellscripts.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +REPO_ROOT="$(dirname "$0")"/../.. +REPO_ROOT=$(realpath "${REPO_ROOT}") +IGNORE_FILENAME="ignore.txt" +IGNORE_FILE="${REPO_ROOT}/scripts/chk_shellscripts/${IGNORE_FILENAME}" + +FOUND_FILES_TMP=$(mktemp) +IGNORE_FILES_TMP=$(mktemp) +trap 'rm -f ${FOUND_FILES_TMP} ; rm -f ${IGNORE_FILES_TMP}' EXIT + +sort < "${IGNORE_FILE}" >"${IGNORE_FILES_TMP}" +cd "${REPO_ROOT}" +find . -type f -name "*.sh" | sort >"${FOUND_FILES_TMP}" + +SHELLCHECK=${SHELLCHECK:-"$(command -v -- shellcheck)"} +if [ ! -f "${SHELLCHECK}" ]; then + echo "error: shellcheck '${SHELLCHECK}' not found." + exit 1 +fi + +FILES=$(join -v2 "${IGNORE_FILES_TMP}" "${FOUND_FILES_TMP}") + +# shellcheck disable=SC2086 +"${SHELLCHECK}" ${FILES[*]} diff --git a/scripts/chk_shellscripts/ignore.txt b/scripts/chk_shellscripts/ignore.txt new file mode 100644 index 000000000..098607764 --- /dev/null +++ b/scripts/chk_shellscripts/ignore.txt @@ -0,0 +1,50 @@ +./test/docsCodeStyle.sh +./test/cmdlineTests.sh +./test/externalTests.sh +./test/externalTests/common.sh +./test/externalTests/gnosis.sh +./test/externalTests/zeppelin.sh +./test/externalTests/colony.sh +./test/externalTests/solc-js/solc-js.sh +./scripts/common.sh +./scripts/isoltest.sh +./scripts/get_version.sh +./scripts/soltest.sh +./scripts/test_emscripten.sh +./scripts/wasm-rebuild/docker-scripts/rebuild_tags.sh +./scripts/wasm-rebuild/docker-scripts/rebuild_current.sh +./scripts/wasm-rebuild/docker-scripts/genbytecode.sh +./scripts/wasm-rebuild/docker-scripts/patch.sh +./scripts/wasm-rebuild/rebuild.sh +./scripts/build_emscripten.sh +./scripts/travis-emscripten/build_emscripten.sh +./scripts/travis-emscripten/install_deps.sh +./scripts/travis-emscripten/publish_binary.sh +./scripts/docker_build.sh +./scripts/docs_version_pragma_check.sh +./scripts/uniqueErrors.sh +./scripts/report_errors.sh +./scripts/tests.sh +./scripts/docker_deploy.sh +./scripts/bytecodecompare/storebytecode.sh +./scripts/deps-ppa/static_z3.sh +./scripts/ASTImportTest.sh +./scripts/install_static_z3.sh +./scripts/install_obsolete_jsoncpp_1_7_4.sh +./scripts/install_deps.sh +./scripts/build.sh +./scripts/check_style.sh +./scripts/run_proofs.sh +./scripts/common_cmdline.sh +./scripts/docker_deploy_manual.sh +./scripts/endToEndExtraction/create_traces.sh +./scripts/release.sh +./scripts/download_ossfuzz_corpus.sh +./scripts/release_ppa.sh +./scripts/install_cmake.sh +./scripts/release_emscripten.sh +./scripts/create_source_tarball.sh +./scripts/docs.sh +./.circleci/soltest.sh +./.circleci/osx_install_dependencies.sh +./.circleci/soltest_all.sh