From 66264b730126126d4581311e32956f77deab51c9 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 18 Dec 2025 11:01:00 -0600 Subject: [PATCH 1/2] chore: add pre-commit hooks and CI coverage reporting - Add pre-commit hook for JS/TS and CSS lint checks - Add setup script to install hooks - Add coverage reporting to CI workflow - Add coverage threshold warning (60%) - Update CONTRIBUTING.md with hooks setup instructions --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++++++-- CONTRIBUTING.md | 5 +++-- scripts/pre-commit | 37 +++++++++++++++++++++++++++++++++++++ scripts/setup-hooks.sh | 18 ++++++++++++++++++ 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100755 scripts/pre-commit create mode 100755 scripts/setup-hooks.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b501350e32..1515ab1436 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,10 +90,10 @@ jobs: chmod +x _tests/bin/Radarr find _tests -name "Radarr.Test.Dummy" -exec chmod a+x {} \; - - name: Test + - name: Test with coverage shell: bash continue-on-error: true - run: ./test.sh Linux Unit Test + run: ./test.sh Linux Unit Coverage - name: Report test results uses: dorny/test-reporter@v2 @@ -106,6 +106,36 @@ jobs: fail-on-error: false fail-on-empty: false + - name: Generate coverage report + uses: danielpalme/ReportGenerator-GitHub-Action@5 + if: always() + with: + reports: "**/coverage.cobertura.xml" + targetdir: CoverageReport + reporttypes: "HtmlInline;Cobertura;TextSummary" + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + if: always() + continue-on-error: true + with: + files: "**/coverage.cobertura.xml" + fail_ci_if_error: false + + - name: Check coverage threshold + if: always() + shell: bash + run: | + if [ -f CoverageReport/Summary.txt ]; then + COVERAGE=$(grep -oP 'Line coverage: \K[\d.]+' CoverageReport/Summary.txt || echo "0") + echo "Line coverage: ${COVERAGE}%" + if (( $(echo "$COVERAGE < 60" | bc -l) )); then + echo "::warning::Coverage is below 60% threshold (${COVERAGE}%)" + fi + else + echo "::warning::Coverage report not found" + fi + - name: Free disk space run: | sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a46e92a807..9e7a12a921 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,9 +31,10 @@ Aletheia is written in C# (backend) and JS (frontend). The backend is built on . 1. Clone the repository: `git clone https://github.com/cheir-mneme/aletheia.git` 1. Install dependencies and build as described below +1. (Optional) Install pre-commit hooks: `./scripts/setup-hooks.sh` -> Be sure to run lint `yarn lint --fix` on your code for any front end changes before committing. -For css changes `yarn stylelint-windows --fix` {.is-info} +> The pre-commit hooks will automatically run lint checks before each commit. +> You can also run lint manually: `yarn lint --fix` for JS/TS, `yarn stylelint-linux --fix` for CSS. ### Building the frontend diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100755 index 0000000000..67aa49b874 --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,37 @@ +#!/bin/bash +# Pre-commit hook for Aletheia + +set -e + +echo "Running pre-commit checks..." + +# Check if there are any staged frontend files +STAGED_JS=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' | grep '^frontend/' || true) + +if [ -n "$STAGED_JS" ]; then + echo "Checking JavaScript/TypeScript lint..." + yarn lint --quiet 2>/dev/null || { + echo "ESLint errors found. Run 'yarn lint-fix' to auto-fix." + exit 1 + } +fi + +# Check if there are any staged CSS files +STAGED_CSS=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.css$' | grep '^frontend/' || true) + +if [ -n "$STAGED_CSS" ]; then + echo "Checking CSS lint..." + if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then + yarn stylelint-windows --quiet 2>/dev/null || { + echo "Stylelint errors found." + exit 1 + } + else + yarn stylelint-linux --quiet 2>/dev/null || { + echo "Stylelint errors found." + exit 1 + } + fi +fi + +echo "Pre-commit checks passed." diff --git a/scripts/setup-hooks.sh b/scripts/setup-hooks.sh new file mode 100755 index 0000000000..f365933db2 --- /dev/null +++ b/scripts/setup-hooks.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Install git hooks for Aletheia development + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +HOOKS_DIR="$SCRIPT_DIR/../.git/hooks" + +echo "Installing git hooks..." + +if [ -f "$HOOKS_DIR/pre-commit" ]; then + echo "Backing up existing pre-commit hook..." + mv "$HOOKS_DIR/pre-commit" "$HOOKS_DIR/pre-commit.backup" +fi + +cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit" +chmod +x "$HOOKS_DIR/pre-commit" + +echo "Git hooks installed successfully." +echo "Run 'yarn install' to ensure lint dependencies are available." From d1a6637f08153030ebfb59e6a34cfd7018f7faf2 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 18 Dec 2025 11:34:43 -0600 Subject: [PATCH 2/2] fix(ci): copy test DLLs to expected location for test.sh --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1515ab1436..480b768aa4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,9 @@ jobs: mkdir -p _tests/bin cp _output/net8.0/linux-x64/publish/Radarr _tests/bin/ chmod +x _tests/bin/Radarr + # Copy test DLLs to where test.sh expects them + cp _tests/net8.0/linux-x64/publish/*.dll _tests/ + cp _tests/net8.0/linux-x64/publish/*.json _tests/ 2>/dev/null || true find _tests -name "Radarr.Test.Dummy" -exec chmod a+x {} \; - name: Test with coverage