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."