From efca6f24161d82aa071dbd79196b0194df8c2150 Mon Sep 17 00:00:00 2001 From: Pawel Lipski Date: Sun, 9 Jan 2022 13:20:34 +0100 Subject: [PATCH] Run shellcheck on all scripts in the CI --- .circleci/config.yml | 15 ++++++++++----- blogs/git-machete-1/sandbox-setup-reduced.sh | 2 ++ blogs/git-machete-1/sandbox-setup.sh | 2 ++ blogs/git-machete-2/sandbox-setup-2.sh | 2 ++ ci/checks/enforce-issue-number-for-todos.sh | 4 ++-- ci/checks/ensure-completion-scripts-correct.sh | 6 +++--- ci/checks/ensure-shell-scripts-pass-shellcheck.sh | 5 +++++ ci/github-releases/ci-deploy.sh | 2 +- ci/snap/ci-run-dry-run.sh | 3 +-- ci/tox/Dockerfile | 4 ++-- 10 files changed, 30 insertions(+), 15 deletions(-) create mode 100755 ci/checks/ensure-shell-scripts-pass-shellcheck.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index fd98874f1..b395eeffa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ executors: TERM: ansi mandatory_jobs: &mandatory_jobs - - initial checks + - general checks - test against python 3_6 and git 1_8_10 - test against python 3_7 and git 2_7_6 - test against python 3_8 and git 2_25_0 with PEP8 checks @@ -17,21 +17,25 @@ mandatory_jobs: &mandatory_jobs - test against python 3_10 and git 2_33_1 jobs: - "initial checks": + "general checks": executor: ubuntu_executor steps: - checkout - run: name: Install dependencies command: | - # For ensure-completion-scripts-correct.sh sudo apt-get update + + # For ensure-completion-scripts-correct.sh sudo apt-get install zsh fish + # For ensure-shell-scripts-pass-shellcheck.sh + sudo apt-get install shellcheck + # For ensure-links-correct.sh npm install --global remark-cli remark-lint-no-dead-urls remark-validate-links - run: - name: Perform initial checks + name: Perform general checks command: | # We don't want `less` to open for `git grep` results. export GIT_PAGER=cat @@ -43,6 +47,7 @@ jobs: enforce-issue-number-for-todos.sh ensure-completion-scripts-correct.sh ensure-links-correct.sh + ensure-shell-scripts-pass-shellcheck.sh ensure-version-bumped.sh prohibit-tab-character.sh prohibit-trailing-whitespace.sh @@ -176,7 +181,7 @@ workflows: version: 2 build: jobs: - - initial checks + - general checks - test against python 3_6 and git 1_8_10 - test against python 3_7 and git 2_7_6 - test against python 3_8 and git 2_25_0 with PEP8 checks diff --git a/blogs/git-machete-1/sandbox-setup-reduced.sh b/blogs/git-machete-1/sandbox-setup-reduced.sh index a3e2d25bb..e55260981 100755 --- a/blogs/git-machete-1/sandbox-setup-reduced.sh +++ b/blogs/git-machete-1/sandbox-setup-reduced.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e -o pipefail -u + newb() { git checkout -b $1 } diff --git a/blogs/git-machete-1/sandbox-setup.sh b/blogs/git-machete-1/sandbox-setup.sh index aad2c9c97..b1a294dcd 100755 --- a/blogs/git-machete-1/sandbox-setup.sh +++ b/blogs/git-machete-1/sandbox-setup.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e -o pipefail -u + newb() { git checkout -b $1 } diff --git a/blogs/git-machete-2/sandbox-setup-2.sh b/blogs/git-machete-2/sandbox-setup-2.sh index f3c14bec7..aa120007c 100755 --- a/blogs/git-machete-2/sandbox-setup-2.sh +++ b/blogs/git-machete-2/sandbox-setup-2.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e -o pipefail -u + newb() { git checkout -b $1 } diff --git a/ci/checks/enforce-issue-number-for-todos.sh b/ci/checks/enforce-issue-number-for-todos.sh index fa896327b..77a9db82a 100755 --- a/ci/checks/enforce-issue-number-for-todos.sh +++ b/ci/checks/enforce-issue-number-for-todos.sh @@ -6,9 +6,9 @@ function error() { if [[ $# -ge 1 ]]; then if [[ -t 1 ]]; then - echo -e "${red}>>> $@ <<<${endc}" + echo -e "${red}>>> $* <<<${endc}" else - echo -e ">>> $@ <<<" + echo -e ">>> $* <<<" fi fi } diff --git a/ci/checks/ensure-completion-scripts-correct.sh b/ci/checks/ensure-completion-scripts-correct.sh index f73b80a54..bc35c711b 100755 --- a/ci/checks/ensure-completion-scripts-correct.sh +++ b/ci/checks/ensure-completion-scripts-correct.sh @@ -2,6 +2,6 @@ set -e -o pipefail -u -bash completion/git-machete.completion.bash -zsh completion/git-machete.completion.zsh -fish completion/git-machete.fish +bash completion/git-machete.completion.bash >/dev/null +zsh completion/git-machete.completion.zsh >/dev/null +fish completion/git-machete.fish >/dev/null diff --git a/ci/checks/ensure-shell-scripts-pass-shellcheck.sh b/ci/checks/ensure-shell-scripts-pass-shellcheck.sh new file mode 100755 index 000000000..4ba7d2204 --- /dev/null +++ b/ci/checks/ensure-shell-scripts-pass-shellcheck.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e -o pipefail -u + +git ls-files '*.sh' | xargs shellcheck --check-sourced --exclude=SC2090,SC2125 --severity=warning --shell=bash diff --git a/ci/github-releases/ci-deploy.sh b/ci/github-releases/ci-deploy.sh index fa48f8424..31b6edfa6 100644 --- a/ci/github-releases/ci-deploy.sh +++ b/ci/github-releases/ci-deploy.sh @@ -7,4 +7,4 @@ tag=v$(grep '__version__ = ' git_machete/__init__.py | cut -d\' -f2) # (since apparently all non-draft releases on GitHub must have a corresponding git tag). hub release create "$tag" \ --message="$tag"$'\n\n'"$(sed '4,/^$/!d; /^$/d' RELEASE_NOTES.md)" \ - --attach=$(echo dist/git-machete-*.noarch.rpm) + --attach="$(echo dist/git-machete-*.noarch.rpm)" diff --git a/ci/snap/ci-run-dry-run.sh b/ci/snap/ci-run-dry-run.sh index 28da65a5f..42afb0351 100644 --- a/ci/snap/ci-run-dry-run.sh +++ b/ci/snap/ci-run-dry-run.sh @@ -2,12 +2,11 @@ set -e -o pipefail -u -x -# `--use-lxd` applied to use a LXD container instead of a VM, to work around lack of support for KVM on CircleCI VMs. - sudo apt-get update sudo apt-get install -y snapd sudo snap install snapcraft --classic sudo lxd init --minimal +# `--use-lxd` applied to use a LXD container instead of a VM, to work around lack of support for KVM on CircleCI VMs. snapcraft --use-lxd ! command -v git-machete diff --git a/ci/tox/Dockerfile b/ci/tox/Dockerfile index ab9108360..3843e62bc 100644 --- a/ci/tox/Dockerfile +++ b/ci/tox/Dockerfile @@ -33,12 +33,12 @@ ARG check_coverage ENV CHECK_COVERAGE=${check_coverage} # Pass build argument to BUILD_DOCS environment variable that is used to -# determine where to run tox environment that builds documentation. +# determine whether to run tox environment that builds documentation. ARG build_docs ENV BUILD_DOCS=${build_docs} # Pass build argument to PEP8 environment variable that is used to -# determine where to run tox environment that runs check against PEP8 standard. +# determine whether to run tox environment that runs check against PEP8 standard. ARG pep8 ENV PEP8=${pep8}