From 4ba7a2b9f9e0c7f8aac5c753cc43b5a5895fc2d5 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 7 May 2024 23:40:23 +0200 Subject: [PATCH] Switched from custom pre-commit script to using the pre-commit tool --- .git-hooks/pre-commit | 15 --------------- .gitea/workflows/build.yml | 17 +++++++++++++---- .pre-commit-config.yaml | 32 ++++++++++++++++++++++++++++++++ README.md | 9 +++++---- 4 files changed, 50 insertions(+), 23 deletions(-) delete mode 100755 .git-hooks/pre-commit create mode 100644 .pre-commit-config.yaml diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit deleted file mode 100755 index 0111726..0000000 --- a/.git-hooks/pre-commit +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -set -o nounset # Fail on use of unset variable. -set -o errexit # Exit on command failure. -set -o pipefail # Exit on failure of any command in a pipeline. -set -o errtrace # Trap errors in functions and subshells. -set -o noglob # Disable filename expansion (globbing), - # since it could otherwise happen during - # path splitting. -shopt -s inherit_errexit # Inherit the errexit option status in subshells. - -set -x - -git update-index --refresh -cargo clippy --all-targets --all -- -D warnings -cargo fmt -- --check diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index b3f225a..b175d64 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -20,11 +20,20 @@ jobs: with: rustflags: "" - - name: Formatting - uses: actions-rust-lang/rustfmt@v1 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" - - name: Clippy - run: cargo clippy --all-targets --all -- -D warnings + - name: "DEBUG" + run: | + sleep 2 + echo "::error::Hello" + echo "::error::pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}" + echo "::error::Hello?" + ls ${{ gitea.workspace }} + sleep 2 + + - uses: pre-commit/action@v3.0.1 - name: Build run: cargo build --release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..dc58741 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-added-large-files + - id: check-merge-conflict + + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: clippy + - id: fmt + + - repo: https://github.com/JohnnyMorganz/StyLua + rev: v0.20.0 + hooks: + - id: stylua + + - repo: https://github.com/crate-ci/typos + rev: v1.21.0 + hooks: + - id: typos + args: ["--force-exclude"] + + - repo: https://github.com/pryorda/dockerfilelint-precommit-hooks + rev: v0.1.0 + hooks: + - id: dockerfilelint diff --git a/README.md b/README.md index d3fead5..56ea14b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # automation_rs -Custom home automation solution with google-home integration +Custom home automation solution with Google Home integration and lua scripting. ## Development -Make sure to setup git hooks by running +This repository uses [pre-commit](https://pre-commit.com) to make sure everything is ready to go when committing. +Install the pre-commit hooks by running the following command: -```sh -git config --local core.hooksPath .git-hooks/ +```bash +pre-commit install ```