From 866b5df41b5d59c64bddfd9b5751ef99a848946a Mon Sep 17 00:00:00 2001 From: Alejandro Angulo <5242883+alejandro-angulo@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:18:39 -0800 Subject: [PATCH] Added pre-commit job (#1) --- .cspell.json | 1 + .github/workflows/build.yml | 21 ++++++++++++++++++++- .pre-commit-config.yaml | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.cspell.json b/.cspell.json index afb86b7..a37c09a 100644 --- a/.cspell.json +++ b/.cspell.json @@ -15,6 +15,7 @@ "latexindent", "latexmk", "PHONENUMBER", + "shellcheck", "texlab", "toolset" ], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea12155..e560937 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ name: "Build" on: pull_request: - push: jobs: build: runs-on: ubuntu-latest @@ -11,3 +10,23 @@ jobs: - run: nix build - run: nix flake check - run: nix run + + pre-commit-hooks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: cachix/install-nix-action@v19 + + - run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + + - name: Cache pre-commit environment + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ env.PY }}-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Run pre-commit hooks + run: nix develop --command -- pre-commit run --show-diff-on-failure --color=always --from-ref origin/main --to-ref "$GITHUB_SHA" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca9d876..2829108 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,3 +21,8 @@ repos: entry: chktex language: system types: [tex] + - id: shellcheck + name: shellcheck + entry: shellcheck + language: system + types: [shell]