Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[run]
source = fastapi_radar
omit =
*/tests/*
*/test_*.py
*/__pycache__/*
*/site-packages/*
*/dashboard/node_modules/*
*/dashboard/dist/*

[report]
precision = 2
show_missing = True
skip_covered = False
exclude_lines =
pragma: no cover
def __repr__
raise AssertionError
raise NotImplementedError
if __name__ == .__main__.:
if TYPE_CHECKING:
@abstractmethod
@abc.abstractmethod
pass

[html]
directory = htmlcov

[xml]
output = coverage.xml
52 changes: 52 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Pull Request

## Description
<!-- Provide a brief description of the changes in this PR -->

## Type of Change
<!-- Mark the relevant option with an "x" -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring
- [ ] Test coverage improvement

## Related Issue
<!-- Link to the issue this PR addresses -->
Fixes #(issue number)

## Changes Made
<!-- List the main changes made in this PR -->

-
-
-

## Testing
<!-- Describe the testing you've done -->

- [ ] All existing tests pass
- [ ] New tests added for new functionality
- [ ] Manual testing completed
- [ ] Test coverage >= 90%

## Checklist
<!-- Ensure all items are checked before submitting -->

- [ ] My code follows the project's code style
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published

## Screenshots (if applicable)
<!-- Add screenshots to help explain your changes -->

## Additional Notes
<!-- Any additional information that reviewers should know -->
114 changes: 96 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,133 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}


- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Format check with Black
run: |
black --check fastapi_radar/
black --check fastapi_radar/ tests/

- name: Lint with flake8
run: |
flake8 fastapi_radar/ --max-line-length=100

flake8 fastapi_radar/ tests/ --max-line-length=100 --extend-ignore=E203,W503

- name: Import sorting check with isort
run: |
isort --check-only --profile black fastapi_radar/ tests/

- name: Type check with mypy
run: |
mypy fastapi_radar/

- name: Test with pytest

- name: Security check with bandit
run: |
bandit -r fastapi_radar/ -c pyproject.toml

- name: Dependency security check with safety
run: |
pytest tests/
safety check --json || true
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safety check always exits successfully because of || true, so detected vulnerabilities will never block the build. Please remove the || true so the scan can fail when issues are found.

Prompt for AI agents
Address the following comment on .github/workflows/ci.yml at line 60:

<comment>`safety check` always exits successfully because of `|| true`, so detected vulnerabilities will never block the build. Please remove the `|| true` so the scan can fail when issues are found.</comment>

<file context>
@@ -10,55 +10,133 @@ jobs:
+    - name: Dependency security check with safety
       run: |
-        pytest tests/
+        safety check --json || true
+      continue-on-error: true
+
</file context>
Suggested change
safety check --json || true
safety check --json
Fix with Cubic

continue-on-error: true
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing the Safety scan step to continue on error hides failures, so critical dependency vulnerabilities will not fail CI. Remove the continue-on-error override (or set it to false) to let the job fail when Safety finds issues.

Prompt for AI agents
Address the following comment on .github/workflows/ci.yml at line 61:

<comment>Allowing the Safety scan step to continue on error hides failures, so critical dependency vulnerabilities will not fail CI. Remove the `continue-on-error` override (or set it to false) to let the job fail when Safety finds issues.</comment>

<file context>
@@ -10,55 +10,133 @@ jobs:
       run: |
-        pytest tests/
+        safety check --json || true
+      continue-on-error: true
+
+    - name: Run tests with coverage
</file context>
Suggested change
continue-on-error: true
continue-on-error: false
Fix with Cubic


- name: Run tests with coverage
run: |
pytest tests/ \
--cov=fastapi_radar \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=80 \
-v \
--tb=short

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.11'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: matrix.python-version == '3.11'
with:
name: coverage-report
path: htmlcov/

- name: Generate test report
if: always()
run: |
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Python ${{ matrix.python-version }}" >> $GITHUB_STEP_SUMMARY

build-dashboard:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'

cache: 'npm'
cache-dependency-path: fastapi_radar/dashboard/package-lock.json

- name: Build Dashboard
run: |
cd fastapi_radar/dashboard
npm ci
npm run build

- name: Verify Dashboard Build
run: |
test -f fastapi_radar/dashboard/dist/index.html

- name: Upload dashboard artifact
uses: actions/upload-artifact@v4
with:
name: dashboard-build
path: fastapi_radar/dashboard/dist/

quality-gate:
runs-on: ubuntu-latest
needs: [test, build-dashboard]
if: always()

steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" != "success" ]; then
echo "Tests failed"
exit 1
fi
if [ "${{ needs.build-dashboard.result }}" != "success" ]; then
echo "Dashboard build failed"
exit 1
fi
echo "All quality checks passed!"
72 changes: 72 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Pre-commit hooks for code quality
# Install: pre-commit install
# Run manually: pre-commit run --all-files

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-json
- id: check-toml
- id: check-merge-conflict
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3.9
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Black hook forces python3.9, so pre-commit fails anywhere that interpreter isn’t installed (e.g., Python 3.11/3.12 environments). Please use a generic interpreter like python3 so the hook works across supported runtimes.

Prompt for AI agents
Address the following comment on .pre-commit-config.yaml at line 24:

<comment>The Black hook forces `python3.9`, so pre-commit fails anywhere that interpreter isn’t installed (e.g., Python 3.11/3.12 environments). Please use a generic interpreter like `python3` so the hook works across supported runtimes.</comment>

<file context>
@@ -0,0 +1,72 @@
+    rev: 23.12.1
+    hooks:
+      - id: black
+        language_version: python3.9
+        args: [&#39;--line-length=100&#39;]
+
</file context>
Suggested change
language_version: python3.9
language_version: python3
Fix with Cubic

args: ['--line-length=100']

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '100']

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=100', '--extend-ignore=E203,W503']

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [
'types-requests',
'sqlalchemy[mypy]',
'pydantic',
]
args: ['--config-file=mypy.ini']

- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']

- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
args: [
'tests/',
'-v',
'--tb=short',
'-x', # Stop on first failure
'--maxfail=5', # Stop after 5 failures
]
stages: [push] # Only run on push, not on every commit
79 changes: 79 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.PHONY: install test coverage lint format type-check security clean help

help:
@echo "FastAPI Radar - Development Commands"
@echo ""
@echo "Setup:"
@echo " make install Install dependencies"
@echo " make install-dev Install with dev dependencies"
@echo ""
@echo "Development:"
@echo " make format Format code with black and isort"
@echo " make lint Run flake8"
@echo " make type-check Run mypy"
@echo " make security Run security checks"
@echo " make check Run all checks (format, lint, type, security)"
@echo ""
@echo "Testing:"
@echo " make test Run tests"
@echo " make test-fast Run tests in parallel"
@echo " make coverage Run tests with coverage report"
@echo " make test-unit Run unit tests only"
@echo " make test-integration Run integration tests only"
@echo ""
@echo "Maintenance:"
@echo " make clean Remove cache and build files"
@echo " make pre-commit Install pre-commit hooks"

install:
pip install -e .

install-dev:
pip install -e ".[dev]"

test:
pytest tests/ -v

test-fast:
pytest tests/ -v -n auto

coverage:
pytest tests/ --cov=fastapi_radar --cov-report=html --cov-report=term-missing --cov-fail-under=90

test-unit:
pytest tests/ -v -m unit

test-integration:
pytest tests/ -v -m integration

format:
black fastapi_radar/ tests/
isort fastapi_radar/ tests/

lint:
flake8 fastapi_radar/ tests/ --max-line-length=100 --extend-ignore=E203,W503

type-check:
mypy fastapi_radar/

security:
bandit -r fastapi_radar/ -c pyproject.toml
safety check || true
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove || true so the Safety scan fails when vulnerabilities are detected; otherwise the security check target always passes even on real issues.

Prompt for AI agents
Address the following comment on Makefile at line 61:

<comment>Remove `|| true` so the Safety scan fails when vulnerabilities are detected; otherwise the security check target always passes even on real issues.</comment>

<file context>
@@ -0,0 +1,79 @@
+
+security:
+	bandit -r fastapi_radar/ -c pyproject.toml
+	safety check || true
+
+check: format lint type-check security
</file context>
Suggested change
safety check || true
safety check
Fix with Cubic


check: format lint type-check security
@echo "All checks passed!"

pre-commit:
pre-commit install

clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf htmlcov/
rm -rf .coverage
rm -rf coverage.xml
rm -rf .pytest_cache/
rm -rf .mypy_cache/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
Loading