From 2e68b717435577ebd90b17a417d922758a44c41a Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Tue, 29 Aug 2023 12:25:08 +0200 Subject: [PATCH] Move linting out to separate actions --- .github/workflows/ci.yml | 5 +++- .shellcheckrc | 3 ++ package.json | 16 ++++++----- test/acceptance.sh | 60 ---------------------------------------- 4 files changed, 16 insertions(+), 68 deletions(-) create mode 100644 .shellcheckrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e56cccb..ac270ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,13 @@ jobs: - name: Install run: | corepack yarn + - name: Lint + run: | + corepack yarn lint - name: Test run: | corepack yarn test - name: Website Build if: github.ref == 'refs/heads/main' run: | - cp README.md website/ + cp README.md docs/ diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..2ebe56a --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,3 @@ +external-sources=true +shell=bash +color=always diff --git a/package.json b/package.json index 9982402..3d08f14 100644 --- a/package.json +++ b/package.json @@ -8,17 +8,19 @@ "yarn": "3.6.0" }, "scripts": { - "lint": "shellcheck --shell=bash $(find . -name '*.sh' -maxdepth 2)", - "release:major": "env SEMANTIC=major npm run release", - "release:minor": "env SEMANTIC=minor npm run release", - "release:patch": "env SEMANTIC=patch npm run release", - "release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && npm run version:replace && git commit main.sh src/*.sh -m 'Update version' && git push && git push --tags && npm publish", + "lint:shellcheck": "SEV=info; if [ \"${CI:-false}\" = \"true\" ]; then SEV=warning; fi; shellcheck --severity=${SEV} $(find . -name '*.sh' -maxdepth 2)", + "lint:style": "test/style.pl $(find . -name '*.sh' -maxdepth 2)", + "lint": "npm-run-all -l 'lint:**'", + "release:major": "env SEMANTIC=major yarn release", + "release:minor": "env SEMANTIC=minor yarn release", + "release:patch": "env SEMANTIC=patch yarn release", + "release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && yarn version:replace && git commit main.sh src/*.sh -m 'Update version' && git push && git push --tags && npm publish", "test:debug:main:repeated": "cross-env LOG_LEVEL=7 test/acceptance.sh main-repeated", - "test:update": "cross-env SAVE_FIXTURES=true npm run test", + "test:update": "cross-env SAVE_FIXTURES=true yarn test", "test": "test/acceptance.sh", "upgrade:modules": "next-update --keep true --tldr", "version:current": "node -e 'console.log(require(\"./package.json\").version)'", - "version:replace": "replace 'v\\d+\\.\\d+\\.\\d+' \"v$(npm run --silent version:current)\" main.sh src/*.sh" + "version:replace": "replace 'v\\d+\\.\\d+\\.\\d+' \"v$(yarn --silent version:current)\" main.sh src/*.sh" }, "optionalDependencies": { "fsevents": "*" diff --git a/test/acceptance.sh b/test/acceptance.sh index dc83fd3..392d675 100755 --- a/test/acceptance.sh +++ b/test/acceptance.sh @@ -229,64 +229,4 @@ while IFS=$'\n' read -r bash; do fi done <<< "$(which -a bash 2>/dev/null)" -# do some shellcheck linting -if [[ "$(command -v shellcheck)" ]]; then - echo "==> ShellCheck" - pushd "${__root}" > /dev/null - - failed="false" - - while IFS=$'\n' read -r file; do - [[ "${file}" =~ ^\./node_modules/ ]] && continue - [[ "${file}" =~ ^\./website/ ]] && continue - - echo -n " ${file}.. " - - if ! shellcheck --shell=bash --external-sources --color=always \ - "${file}" >> "${__accptstTmpDir}/shellcheck.err"; then - echo "✗" - failed="true" - continue - fi - - echo "✓" - done <<< "$(find . -type f -iname '*.sh')" - - popd > /dev/null - - if [[ "${failed}" = "true" ]]; then - cat "${__accptstTmpDir}/shellcheck.err" - exit 1 - fi -fi - -# poor man's style guide checking -echo "==> b3bp style guide" -pushd "${__root}" > /dev/null - -failed="false" - -while IFS=$'\n' read -r file; do - [[ "${file}" =~ ^\./node_modules/ ]] && continue - - echo -n " ${file}.. " - - if ! "${__root}/test/style.pl" "${file}" >> "${__accptstTmpDir}/style.err"; then - echo "✗" - failed="true" - continue - fi - - echo "✓" -done <<< "$(find . -type f -iname '*.sh')" - -popd > /dev/null - -if [[ "${failed}" = "true" ]]; then - echo - cat "${__accptstTmpDir}/style.err" - echo - exit 1 -fi - exit 0