mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2024-12-18 14:26:22 +00:00
Move linting out to separate actions
This commit is contained in:
parent
28deb39d86
commit
2e68b71743
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -20,10 +20,13 @@ jobs:
|
|||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
corepack yarn
|
corepack yarn
|
||||||
|
- name: Lint
|
||||||
|
run: |
|
||||||
|
corepack yarn lint
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
corepack yarn test
|
corepack yarn test
|
||||||
- name: Website Build
|
- name: Website Build
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
run: |
|
run: |
|
||||||
cp README.md website/
|
cp README.md docs/
|
||||||
|
3
.shellcheckrc
Normal file
3
.shellcheckrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
external-sources=true
|
||||||
|
shell=bash
|
||||||
|
color=always
|
16
package.json
16
package.json
@ -8,17 +8,19 @@
|
|||||||
"yarn": "3.6.0"
|
"yarn": "3.6.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "shellcheck --shell=bash $(find . -name '*.sh' -maxdepth 2)",
|
"lint:shellcheck": "SEV=info; if [ \"${CI:-false}\" = \"true\" ]; then SEV=warning; fi; shellcheck --severity=${SEV} $(find . -name '*.sh' -maxdepth 2)",
|
||||||
"release:major": "env SEMANTIC=major npm run release",
|
"lint:style": "test/style.pl $(find . -name '*.sh' -maxdepth 2)",
|
||||||
"release:minor": "env SEMANTIC=minor npm run release",
|
"lint": "npm-run-all -l 'lint:**'",
|
||||||
"release:patch": "env SEMANTIC=patch npm run release",
|
"release:major": "env SEMANTIC=major yarn 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",
|
"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: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",
|
"test": "test/acceptance.sh",
|
||||||
"upgrade:modules": "next-update --keep true --tldr",
|
"upgrade:modules": "next-update --keep true --tldr",
|
||||||
"version:current": "node -e 'console.log(require(\"./package.json\").version)'",
|
"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": {
|
"optionalDependencies": {
|
||||||
"fsevents": "*"
|
"fsevents": "*"
|
||||||
|
@ -229,64 +229,4 @@ while IFS=$'\n' read -r bash; do
|
|||||||
fi
|
fi
|
||||||
done <<< "$(which -a bash 2>/dev/null)"
|
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
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user