chore: move shell tools to pre-commit (via docker) (#2207)

This commit is contained in:
Jonas L 2022-10-05 08:27:15 +02:00 committed by GitHub
parent 4a671a1b3b
commit e04ab7679a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 50 deletions

View File

@ -28,48 +28,6 @@ jobs:
- uses: pre-commit/action@v3.0.0 - uses: pre-commit/action@v3.0.0
check-shell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-project-check-shell-pip
restore-keys: |
${{ runner.os }}-project-check-shell-pip
- uses: actions/cache@v3
with:
path: |
/usr/local/bin/shellcheck*
/usr/local/bin/shfmt*
key: ${{ runner.os }}-project-check-shell-tools
restore-keys: |
${{ runner.os }}-project-check-shell-tools
- run: |
python -m venv venv && source venv/bin/activate
pip install gh-release-install
sudo venv/bin/gh-release-install \
koalaman/shellcheck \
shellcheck-{tag}.linux.x86_64.tar.xz --extract shellcheck-{tag}/shellcheck \
/usr/local/bin/shellcheck \
--version-file '{destination}.version'
sudo venv/bin/gh-release-install \
mvdan/sh \
shfmt_{tag}_linux_amd64 \
/usr/local/bin/shfmt \
--version-file '{destination}.version'
- run: SEVERITY=warning make shell-check
test-tools: test-tools:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -64,6 +64,18 @@ repos:
- repo: local - repo: local
hooks: hooks:
- id: shfmt
name: shfmt
language: docker_image
entry: mvdan/shfmt -i 2 -ci -sr -kp -w
types: [shell]
- id: shellcheck
name: shellcheck
language: docker_image
entry: koalaman/shellcheck --color=always --severity=warning
types: [shell]
- id: requirements.txt - id: requirements.txt
name: requirements.txt name: requirements.txt
description: Generate requirements.txt description: Generate requirements.txt

View File

@ -7,14 +7,6 @@ all: setup
setup: setup:
command -v pre-commit > /dev/null && pre-commit install command -v pre-commit > /dev/null && pre-commit install
# https://google.github.io/styleguide/shellguide.html
shell-format:
shfmt -f . | xargs git ls-files | xargs shfmt -i 2 -ci -sr -kp -w
shell-check:
shfmt -f . | xargs git ls-files | xargs shfmt -i 2 -ci -sr -kp -d
shfmt -f . | xargs git ls-files | xargs shellcheck --color=always --severity=$${SEVERITY:-style}
.PHONY: VERSION .PHONY: VERSION
VERSION: VERSION:
tools/version.sh tools/version.sh