Add support for commitizen and pre-commit

This commit is contained in:
Shrukan
2024-02-17 18:46:26 -07:00
parent 7ce1e00d56
commit e7aca940f1
4 changed files with 37 additions and 10 deletions

8
.cz.toml Normal file
View File

@ -0,0 +1,8 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "0.0.1"
version_scheme = "semver"
version = "1.0.0"
update_changelog_on_bump = true
major_version_zero = true
version_files = ["meson.build:version"]

16
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,16 @@
# 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.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.8.0
hooks:
- id: commitizen
- id: commitizen-branch
stages: [push]

View File

@ -1,26 +1,28 @@
# Set default values for variables. Justfile doesn't support dynamic defaulting in
# the same way Make does, so we have to handle it within the command executions.
# Default build prefix and type # Default build prefix and type
BUILD_PREFIX := "./build" BUILD_PREFIX := "./build"
BUILD_TYPE := "release" BUILD_TYPE := "release"
set positional-arguments set positional-arguments
# Set up the actual BUILD_PREFIX based on the presence of the directory # List all available targets
#BUILD_PREFIX := `mkdir -p {{BUILD_PREFIX}} && cd {{BUILD_PREFIX}} && pwd` default:
just --list
default: build
# Build and run the development environment
dev: dev:
docker build -t dev-container -f Dockerfile . docker build -t dev-container -f Dockerfile .
# Note: running with the volumes mounted in the same directory allows clangd to work
docker run -it --rm -v $(pwd):$(pwd) dev-container -c "cd $(pwd) && /bin/zsh" docker run -it --rm -v $(pwd):$(pwd) dev-container -c "cd $(pwd) && /bin/zsh"
# Bootstrap the project when cloning for the first time by installing git hooks and others
bootstrap:
pre-commit install --hook-type commit-msg --hook-type pre-push
# Recipe to configure the build environment # Recipe to configure the build environment
configure: configure:
@echo "\nBUILD_PREFIX: {{BUILD_PREFIX}}\n\n" @echo "\nBUILD_PREFIX: {{BUILD_PREFIX}}\n\n"
meson setup --buildtype={{BUILD_TYPE}} {{BUILD_PREFIX}} meson setup --buildtype={{BUILD_TYPE}} {{BUILD_PREFIX}}
# Default build target # Build a target, or default if none is specified
build target="": configure build target="": configure
ninja -C {{BUILD_PREFIX}} {{target}} ninja -C {{BUILD_PREFIX}} {{target}}
@ -32,7 +34,7 @@ test: build
coverage: test coverage: test
ninja -C {{BUILD_PREFIX}} coverage ninja -C {{BUILD_PREFIX}} coverage
# Debug build # Debug buildoutdated
debug: debug:
meson configure {{BUILD_PREFIX}} --buildtype=debug meson configure {{BUILD_PREFIX}} --buildtype=debug
ninja -C {{BUILD_PREFIX}} ninja -C {{BUILD_PREFIX}}
@ -46,6 +48,7 @@ release:
sanitize: sanitize:
meson configure {{BUILD_PREFIX}} -Db_sanitize=address meson configure {{BUILD_PREFIX}} -Db_sanitize=address
ninja -C {{BUILD_PREFIX}} ninja -C {{BUILD_PREFIX}}
ninja -C {{BUILD_PREFIX}} test
# Static analysis # Static analysis
check: check:

View File

@ -1,5 +1,5 @@
project('${REPO_NAME_PASCAL}', 'cpp', project('${REPO_NAME_PASCAL}', 'cpp',
version : '0.1', version : '0.0.1',
default_options : ['warning_level=3', default_options : ['warning_level=3',
'cpp_std=c++20', 'cpp_std=c++20',
'b_coverage=true']) 'b_coverage=true'])