From e1afab8ec72d15eece9ae0b7cd6537edada7cda5 Mon Sep 17 00:00:00 2001 From: Joke de Buhr Date: Sat, 19 Feb 2022 11:53:54 +0100 Subject: [PATCH] chore: pre-commit support --- .github/workflows/lint.yml | 35 -------------------------------- .github/workflows/pre-commit.yml | 16 +++++++++++++++ .pre-commit-config.yaml | 22 ++++++++++++++++++++ scripts/shellcheck.bash | 4 ---- scripts/shfmt.bash | 3 --- 5 files changed, 38 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml delete mode 100755 scripts/shellcheck.bash delete mode 100755 scripts/shfmt.bash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 423a263..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - -jobs: - shellcheck: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install asdf dependencies - uses: asdf-vm/actions/install@v1 - - - name: Run ShellCheck - run: scripts/shellcheck.bash - - shellfmt: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install asdf dependencies - uses: asdf-vm/actions/install@v1 - - - name: List file to shfmt - run: shfmt -f . - - - name: Run shfmt - run: scripts/shfmt.bash diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..cf13f16 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,16 @@ +name: pre-commit + +on: + pull_request: + push: + branches: + - master + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: asdf-vm/actions/install@v1 + - uses: pre-commit/action@v2.0.3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..83f7f8d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/syntaqx/git-hooks + rev: v0.0.17 + hooks: + - id: shellcheck + - id: shfmt +- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.3.0 + hooks: + - id: pretty-format-yaml + args: + - --autofix + - --indent + - '2' diff --git a/scripts/shellcheck.bash b/scripts/shellcheck.bash deleted file mode 100755 index 6d28a72..0000000 --- a/scripts/shellcheck.bash +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -exec shellcheck -s bash -x \ - bin/* -P lib/ diff --git a/scripts/shfmt.bash b/scripts/shfmt.bash deleted file mode 100755 index 534f8a6..0000000 --- a/scripts/shfmt.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -exec shfmt -d .