From 9df60f62ce38f712eadd9484848f74d10b7fdfac Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Tue, 23 Feb 2021 11:03:14 +0100 Subject: [PATCH] linting: use local scripts to remove sudo need install linting tools locally to remove the need for sudo curling scripts and installing them for all users --- .gitignore | 7 +++++++ Makefile | 19 ++++++++++--------- test/linting/lint.sh | 6 +++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 827c2548..71cc9fed 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,13 @@ config/opendkim/ .idea .vscode + +################################################# +### Linting Tools ############################# +################################################# + +tools/ + ################################################# ### Tests ##################################### ################################################# diff --git a/Makefile b/Makefile index bc409642..dd8bb0d2 100644 --- a/Makefile +++ b/Makefile @@ -62,14 +62,15 @@ eclint: @ ./test/linting/lint.sh eclint install_linters: - @ sudo curl -S -L \ - "https://github.com/hadolint/hadolint/releases/download/v$(HADOLINT_VERSION)/hadolint-$(shell uname -s)-$(shell uname -m)" -o /usr/local/bin/hadolint - @ sudo curl -S -L \ + @ mkdir -p tools + @ curl -S -L \ + "https://github.com/hadolint/hadolint/releases/download/v$(HADOLINT_VERSION)/hadolint-$(shell uname -s)-$(shell uname -m)" -o tools/hadolint + @ curl -S -L \ "https://github.com/koalaman/shellcheck/releases/download/v$(SHELLCHECK_VERSION)/shellcheck-v$(SHELLCHECK_VERSION).linux.x86_64.tar.xz" | tar -xJ - @ sudo curl -S -L \ + @ curl -S -L \ "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(ECLINT_VERSION)/ec-linux-amd64.tar.gz" | tar -xaz - @ sudo chmod +rx /usr/local/bin/hadolint - @ sudo mv "shellcheck-v$(SHELLCHECK_VERSION)/shellcheck" /usr/bin/ - @ sudo mv bin/ec-linux-amd64 /usr/bin/eclint - @ sudo chmod +x /usr/bin/eclint - @ sudo rm -rf "shellcheck-v$(SHELLCHECK_VERSION)" bin + @ chmod +rx tools/hadolint + @ mv "shellcheck-v$(SHELLCHECK_VERSION)/shellcheck" tools/ + @ mv bin/ec-linux-amd64 tools/eclint + @ chmod +x tools/eclint + @ rm -rf "shellcheck-v$(SHELLCHECK_VERSION)" bin diff --git a/test/linting/lint.sh b/test/linting/lint.sh index 35eb3892..d9801d24 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -116,7 +116,7 @@ function _shellcheck { local SCRIPT='SHELLCHECK' local ERR=0 - local LINT=(/usr/bin/shellcheck -x -S style -Cauto -o all -e SC2154 -W 50) + local LINT=(shellcheck -x -S style -Cauto -o all -e SC2154 -W 50) if ! __in_path "${LINT[0]}" then @@ -200,4 +200,8 @@ function _main esac } +# prefer linters installed in tools +PATH="$(pwd)/tools:${PATH}" +export PATH + _main "${@}" || exit ${?}