diff --git a/Makefile b/Makefile index cd43482..65b8e83 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ install: $(if $(value CI),,install-hooks) ## run hooks on default snapshot test: snapshots - cd snapshots/default && git init && git add . && make hooks + cd snapshots/default && git init && make hooks ## make the snapshots snapshots: $(shell find {{cookiecutter.repo_name}}) snapshots/*.yaml diff --git a/snapshots/default/.lefthook.yml b/snapshots/default/.lefthook.yml new file mode 100644 index 0000000..4b7ef93 --- /dev/null +++ b/snapshots/default/.lefthook.yml @@ -0,0 +1,69 @@ +# Refer for explanation to following link: +# https://lefthook.dev/configuration/ +# + +# output: +# # - meta # Print lefthook version +# - summary # Print summary block (successful and failed steps) +# - empty_summary # Print summary heading when there are no steps to run +# # - success # Print successful steps +# - failure # Print failed steps printing +# # - execution # Print any execution logs +# # - execution_out # Print execution output +# # - execution_info # Print `EXECUTE > ...` logging +# - skips # Print "skip" (i.e. no files matched) + +pre-push: + # parallel: true + jobs: + # - name: typos + # run: typos + + - name: echo + #glob: "*.md" + run: ./echo.sh {all_files} + + + - name: ruff + run: uv run ruff check --force-exclude {push_files} + tags: + - check + + - name: ruff-format + glob: "*.py" + run: uv run ruff format {push_files} + + tags: + - check + + - name: pyright + run: uv run pyright + tags: + - check + + - name: test + run: uv run pytest +# +# pre-commit: +# parallel: true +# jobs: +# - run: yarn eslint {staged_files} +# glob: "*.{js,ts,jsx,tsx}" +# +# - name: rubocop +# glob: "*.rb" +# exclude: +# - config/application.rb +# - config/routes.rb +# run: bundle exec rubocop --force-exclusion {all_files} +# +# - name: govet +# files: git ls-files -m +# glob: "*.go" +# run: go vet {files} +# +# - script: "hello.js" +# runner: node +# +# - script: "hello.go" +# runner: go run diff --git a/snapshots/default/Makefile-common.mk b/snapshots/default/Makefile-common.mk index 4d79453..11ba118 100644 --- a/snapshots/default/Makefile-common.mk +++ b/snapshots/default/Makefile-common.mk @@ -49,9 +49,9 @@ publish: ## run pre-commit git hooks on all files hooks: - uv run pre-commit run --color=always --all-files --hook-stage pre-push + uv run lefthook run pre-push --all-files --force install-hooks: .git/hooks/pre-push .git/hooks/pre-push: - uv run pre-commit install --install-hooks -t pre-push + uv run lefthook install diff --git a/snapshots/default/echo.sh b/snapshots/default/echo.sh new file mode 100755 index 0000000..f058e87 --- /dev/null +++ b/snapshots/default/echo.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + +echo "Hello, World!" +echo "$@" diff --git a/snapshots/default/pyproject.toml b/snapshots/default/pyproject.toml index f597dbf..2eafc3b 100644 --- a/snapshots/default/pyproject.toml +++ b/snapshots/default/pyproject.toml @@ -9,7 +9,7 @@ dependencies = [] [dependency-groups] dev = [ "build~=1.0", - "pre-commit~=4.0", + "lefthook~=1.11", "pyright==1.1.409", "pytest~=9.0", "ruff~=0.15.4", diff --git a/{{cookiecutter.repo_name}}/.lefthook.yml b/{{cookiecutter.repo_name}}/.lefthook.yml new file mode 100644 index 0000000..f1586fc --- /dev/null +++ b/{{cookiecutter.repo_name}}/.lefthook.yml @@ -0,0 +1,47 @@ +# Refer for explanation to following link: +# https://lefthook.dev/configuration/ +# + +output: + # - meta # Print lefthook version + - summary # Print summary block (successful and failed steps) + - empty_summary # Print summary heading when there are no steps to run + # - success # Print successful steps + - failure # Print failed steps printing + # - execution # Print any execution logs + # - execution_out # Print execution output + # - execution_info # Print `EXECUTE > ...` logging + - skips # Print "skip" (i.e. no files matched) + +# pre-commit: +# # parallel: true +# jobs: +# # - name: typos +# # run: typos + +# - name: echo +# glob: "*.env" +# run: ./echo.sh {staged_files} + +pre-push: + jobs: + # - name: typos + # run: typos + + - name: ruff + glob: "*.py" + run: uv run ruff check --force-exclude {push_files} + + - name: ruff-format + glob: "*.py" + run: uv run ruff format {push_files} + + - name: pyright and test + group: + parallel: true + jobs: + - name: pyright + run: uv run pyright + + - name: test + run: uv run pytest diff --git a/{{cookiecutter.repo_name}}/Makefile-common.mk b/{{cookiecutter.repo_name}}/Makefile-common.mk index 4d79453..11ba118 100644 --- a/{{cookiecutter.repo_name}}/Makefile-common.mk +++ b/{{cookiecutter.repo_name}}/Makefile-common.mk @@ -49,9 +49,9 @@ publish: ## run pre-commit git hooks on all files hooks: - uv run pre-commit run --color=always --all-files --hook-stage pre-push + uv run lefthook run pre-push --all-files --force install-hooks: .git/hooks/pre-push .git/hooks/pre-push: - uv run pre-commit install --install-hooks -t pre-push + uv run lefthook install diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index 19f2487..f8b8957 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -9,7 +9,7 @@ dependencies = [] [dependency-groups] dev = [ "build~=1.0", - "pre-commit~=4.0", + "lefthook~=1.11", "pyright==1.1.409", "pytest~=9.0", "ruff~=0.15.4",