From 8d630ae176fe310fdf3f10941e4f4c1b4974f041 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 25 Mar 2026 18:01:59 +0100 Subject: [PATCH] feat: Add local tests --- .githooks/pre-commit | 47 ++++++++++++++++++++++++++++++++++++++++++++ .vscode/launch.json | 4 ++-- README.md | 4 ++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..bc2b1a2 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,47 @@ +#!/bin/bash + +echo "Starting pre-commit checks..." + +if ! command -v cmake &> /dev/null || ! command -v ninja &> /dev/null; then + echo "Error: cmake or ninja not found." + exit 1 +fi + +echo "Configuring project..." +cmake -S . -B build \ + -G Ninja \ + -DCMAKE_PREFIX_PATH=$(brew --prefix qt6) \ + -DCMAKE_BUILD_TYPE=Release + +if [ $? -ne 0 ]; then + echo "Configuration failed. Retrying with a clean build directory..." + rm -rf build + cmake -S . -B build \ + -G Ninja \ + -DCMAKE_PREFIX_PATH=$(brew --prefix qt6) \ + -DCMAKE_BUILD_TYPE=Release + + if [ $? -ne 0 ]; then + echo "Configuration failed again." + exit 1 + fi +fi + +echo "Building tests..." +cmake --build build --target tests --parallel $(sysctl -n hw.ncpu) + +if [ $? -ne 0 ]; then + echo "Build failed." + exit 1 +fi + +echo "Running tests..." +cd build && ./tests + +if [ $? -ne 0 ]; then + echo "Tests failed." + exit 1 +fi + +echo "Pre-commit checks passed." +exit 0 \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index fdd54d6..6ec72c8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "cwd": "${workspaceFolder}", "MIMode": "lldb", "preLaunchTask": "Build Project", - "visualizerFile": "/Users/mateuszadamowicz/Library/Application Support/Code/User/workspaceStorage/39f5990b86fcd335d48f145a08be8b3a/tonka3000.qtvsctools/qt.natvis.xml" + "visualizerFile": "/Users/mateuszadamowicz/Library/Application Support/Code/User/workspaceStorage/838ef04dbd7312a4e085a4551843a85b/tonka3000.qtvsctools/qt.natvis.xml" }, { "name": "Run Project Tests", @@ -20,7 +20,7 @@ "MIMode": "lldb", "preLaunchTask": "Build Project Tests", "externalConsole": false, - "visualizerFile": "/Users/mateuszadamowicz/Library/Application Support/Code/User/workspaceStorage/39f5990b86fcd335d48f145a08be8b3a/tonka3000.qtvsctools/qt.natvis.xml" + "visualizerFile": "/Users/mateuszadamowicz/Library/Application Support/Code/User/workspaceStorage/838ef04dbd7312a4e085a4551843a85b/tonka3000.qtvsctools/qt.natvis.xml" } ] } \ No newline at end of file diff --git a/README.md b/README.md index fc9a3db..533e117 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,10 @@ The repository supports custom Git hooks for development automation. ```bash # Enables git hooks chmod u+x .git/hooks/* + +# Setup local tests +chmod +x .githooks/pre-commit +git config core.hooksPath .githooks ``` ## 🛠 Technologies