From 35d0797b826727d239eae974a9f2ad425a05a4d6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 2 Jul 2020 16:49:00 +0200 Subject: [PATCH] ci: Run shellcheck via tox --- scripts/dev/ci/install.sh | 2 +- scripts/dev/ci/run.sh | 10 ---------- scripts/dev/run_shellcheck.sh | 32 ++++++++++++++++++++++++++++++++ tox.ini | 6 ++++++ 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 scripts/dev/run_shellcheck.sh diff --git a/scripts/dev/ci/install.sh b/scripts/dev/ci/install.sh index 2f7f15984..05bbae2c0 100644 --- a/scripts/dev/ci/install.sh +++ b/scripts/dev/ci/install.sh @@ -26,7 +26,7 @@ pip_install() { testenv=$1 -[[ -n $DOCKER || $testenv == shellcheck ]] && exit 0 +[[ -n $DOCKER ]] && exit 0 [[ $testenv == eslint ]] && npm install -g eslint diff --git a/scripts/dev/ci/run.sh b/scripts/dev/ci/run.sh index ff1cdd0d7..2131263af 100644 --- a/scripts/dev/ci/run.sh +++ b/scripts/dev/ci/run.sh @@ -29,16 +29,6 @@ if [[ -n $DOCKER ]]; then -e "DOCKER=$DOCKER" \ -e "CI=$CI" \ "qutebrowser/ci:$DOCKER" -elif [[ $testenv == shellcheck ]]; then - script_list=$(mktemp) - find scripts/dev/ -name '*.sh' > "$script_list" - find misc/userscripts/ -type f -exec grep -lE '[/ ][bd]ash$|[/ ]sh$|[/ ]ksh$' {} + >> "$script_list" - mapfile -t scripts < "$script_list" - rm -f "$script_list" - docker run \ - -v "$PWD:/outside" \ - -w /outside \ - koalaman/shellcheck:stable "${scripts[@]}" else args=() # We only run unit tests on macOS because it's quite slow. diff --git a/scripts/dev/run_shellcheck.sh b/scripts/dev/run_shellcheck.sh new file mode 100644 index 000000000..86c6c2755 --- /dev/null +++ b/scripts/dev/run_shellcheck.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# vim: ft=sh fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2020 Florian Bruhin (The Compiler) + +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +set -e + +script_list=$(mktemp) +find scripts/dev/ -name '*.sh' > "$script_list" +find misc/userscripts/ -type f -exec grep -lE '[/ ][bd]ash$|[/ ]sh$|[/ ]ksh$' {} + >> "$script_list" +mapfile -t scripts < "$script_list" +rm -f "$script_list" + +docker run \ + -v "$PWD:/outside" \ + -w /outside \ + koalaman/shellcheck:stable "$@" "${scripts[@]}" diff --git a/tox.ini b/tox.ini index ba8499bac..9142dd49a 100644 --- a/tox.ini +++ b/tox.ini @@ -187,6 +187,12 @@ whitelist_externals = eslint changedir = {toxinidir}/qutebrowser/javascript commands = eslint --report-unused-disable-directives . +[testenv:shellcheck] +basepython = python3 +deps = +whitelist_externals = bash +commands = bash scripts/dev/run_shellcheck.sh {posargs} + [testenv:mypy] basepython = {env:PYTHON:python3} pip_version = pip