mirror of
https://github.com/Radarr/Radarr
synced 2026-05-09 08:13:43 +02:00
Merge pull request #16 from cheir-mneme/chore/quality-gates
chore: add pre-commit hooks and CI coverage
This commit is contained in:
commit
bd832dc853
4 changed files with 93 additions and 4 deletions
37
.github/workflows/build.yml
vendored
37
.github/workflows/build.yml
vendored
|
|
@ -88,12 +88,15 @@ 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
|
||||
- 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 +109,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
37
scripts/pre-commit
Executable file
37
scripts/pre-commit
Executable file
|
|
@ -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."
|
||||
18
scripts/setup-hooks.sh
Executable file
18
scripts/setup-hooks.sh
Executable file
|
|
@ -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."
|
||||
Loading…
Reference in a new issue