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
101 changes: 35 additions & 66 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ coverage:
project:
default:
target: auto
threshold: 0.5
threshold: 1.0 # Reduced threshold to be less strict
if_ci_failed: error
flag_coverage_not_uploaded_behavior: include
if_not_found: success # Don't fail if coverage not found
patch:
default:
target: 80%
threshold: 0.5
target: 70% # Reduced from 80% to be more achievable
threshold: 1.0
if_ci_failed: error
if_not_found: success
branches:
- "!main" # Don't require patch coverage on main branch
- "!main"
- "!master"
changes: false

# Flags for different parts of the codebase
Expand All @@ -32,82 +34,49 @@ flag_management:
statuses:
- type: project
target: auto
threshold: 0.5
branches:
- "!main"
threshold: 1.0
if_not_found: success
- type: patch
target: 80%
threshold: 0.5
target: 70%
threshold: 1.0
if_not_found: success

# Components for modular coverage tracking
component_management:
default_rules:
statuses:
- type: project
target: auto
threshold: 0.5
branches:
- "!main"
threshold: 1.0
if_not_found: success
- type: patch
target: 80%
threshold: 0.5
target: 70%
threshold: 1.0
if_not_found: success
individual_components:
- component_id: backend-auth
name: "Authentication System"
paths:
- backend/app/auth/**
flag_regexes:
- backend
- "backend/app/auth/**"
- component_id: backend-expenses
name: "Expense Management"
paths:
- backend/app/expenses/**
flag_regexes:
- backend
- "backend/app/expenses/**"
- component_id: backend-groups
name: "Group Management"
paths:
- backend/app/groups/**
flag_regexes:
- backend
- "backend/app/groups/**"
- component_id: backend-user
name: "User Management"
paths:
- backend/app/user/**
flag_regexes:
- backend
- "backend/app/user/**"
- component_id: backend-core
name: "Backend Core"
paths:
- backend/app/config.py
- backend/app/database.py
- backend/app/dependencies.py
- backend/main.py
flag_regexes:
- backend
- component_id: frontend-auth
name: "Frontend Authentication"
paths:
- frontend/contexts/AuthContext.tsx
- frontend/screens/LoginScreen.tsx
flag_regexes:
- frontend
- component_id: frontend-screens
name: "Frontend Screens"
paths:
- frontend/screens/**
flag_regexes:
- frontend
- component_id: frontend-core
name: "Frontend Core"
paths:
- frontend/App.tsx
- frontend/contexts/**
flag_regexes:
- frontend

# Test Analytics configuration (removed - not supported in codecov.yml)
# Use test-results-action in GitHub Actions instead
- "backend/app/config.py"
- "backend/app/database.py"
- "backend/app/dependencies.py"
- "backend/main.py"

# Ignore files that don't need coverage
ignore:
Expand All @@ -122,23 +91,23 @@ ignore:
- "setup*.sh"
- "setup*.bat"
- "*.json"
- "ui-poc/**" # Ignore POC frontend since we have main frontend

- "ui-poc/**"
- "frontend/**" # Ignore entire frontend directory
- "**/node_modules/**"
- "**/dist/**"
- "**/build/**"
- "**/*.config.js"
- "**/*.config.ts"

# Comments on PRs
comment:
layout: "header, diff, flags, components"
layout: "header, diff, components"
behavior: default
require_changes: false
require_base: false
require_head: true
require_head: false # Don't require head report to show comment
show_carryforward_flags: false

# Make codecov less strict for Dependabot PRs
github_checks:
annotations: true

# Prevent coverage drops due to removed code
fixes:
- "backend/app/::" # Strip backend/app/ prefix from paths
- "frontend/::" # Strip frontend/ prefix from paths
annotations: true
77 changes: 77 additions & 0 deletions .github/workflows/bundle-analysis.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# DISABLED: Frontend bundle analysis - no frontend tests currently
# This workflow is disabled because we don't have frontend tests
# and don't plan to implement them. Can be re-enabled if needed in the future.

# name: Bundle Analysis

# on:
# pull_request:
# paths:
# - 'frontend/**'
# branches: [ main, master ]
# push:
# paths:
# - 'frontend/**'
# branches: [ main, master ]

# jobs:
# bundle-analysis:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '18'
# cache: 'npm'
# cache-dependency-path: frontend/package-lock.json
#
# - name: Install Dependencies
# run: |
# cd frontend
# npm ci
#
# - name: Build for Bundle Analysis
# run: |
# cd frontend
# # Create a production build for analysis
# if npm run build --dry-run 2>/dev/null; then
# npm run build
# else
# # Use Expo's build process
# npx expo export:web
# fi
#
# - name: Analyze Bundle Size
# run: |
# cd frontend
# # Install bundle analyzer
# npm install --no-save webpack-bundle-analyzer
#
# # Generate bundle stats (adjust path based on your build output)
# if [ -d "web-build" ]; then
# # Expo web build
# npx webpack-bundle-analyzer web-build/static/js/*.js --report --mode static --report-filename bundle-report.html
# elif [ -d "dist" ]; then
# # Standard React build
# npx webpack-bundle-analyzer dist/static/js/*.js --report --mode static --report-filename bundle-report.html
# else
# echo "No build output found for bundle analysis"
# fi
#
# - name: Upload Bundle Analysis to Codecov
# uses: codecov/codecov-action@v5
# if: github.actor != 'dependabot[bot]'
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# flags: bundle,frontend,javascript
# name: "Bundle Analysis"
# fail_ci_if_error: false
#
# - name: Bundle Analysis Skipped
# if: github.actor == 'dependabot[bot]'
# run: echo "📦 Bundle analysis skipped for Dependabot PR"
78 changes: 20 additions & 58 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests & Analytics
name: Run Backend Tests & Analytics

on:
pull_request:
Expand Down Expand Up @@ -28,85 +28,47 @@ jobs:

- name: Run Backend Tests with Coverage
run: |
cd $GITHUB_WORKSPACE
export PYTHONPATH=$GITHUB_WORKSPACE:$GITHUB_WORKSPACE/backend
# Generate coverage with detailed flags
cd backend
export PYTHONPATH=$GITHUB_WORKSPACE/backend:$GITHUB_WORKSPACE
# Generate coverage with proper paths
pytest \
--cov=./backend \
--cov=app \
--cov-report=xml:coverage.xml \
--cov-report=json:coverage.json \
--cov-report=lcov:coverage.lcov \
--cov-report=term-missing \
--junit-xml=test-results.xml \
--tb=short \
-v \
backend/tests/
tests/

- name: List coverage files for debugging
run: |
echo "Coverage files generated:"
find . -name "coverage.*" -type f | head -10
ls -la backend/ | grep -E "(coverage|test-results)"

- name: Run Test Analytics Upload
uses: codecov/test-results-action@v1
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: test-results.xml
files: backend/test-results.xml
flags: backend,test-analytics
name: "Backend Test Results"

- name: Upload Coverage to Codecov with Flags
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v4
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml,./coverage.json,./coverage.lcov
file: backend/coverage.xml
flags: backend,python,api
name: "Backend Coverage"
name: backend-coverage
fail_ci_if_error: false
Comment on lines +59 to 66
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Incorrect input name for Codecov action v4

codecov/codecov-action@v4 accepts files: (plural), not file:.
Using the wrong key causes the coverage upload to be skipped.

-        file: backend/coverage.xml
+        files: backend/coverage.xml
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: codecov/codecov-action@v4
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml,./coverage.json,./coverage.lcov
file: backend/coverage.xml
flags: backend,python,api
name: "Backend Coverage"
name: backend-coverage
fail_ci_if_error: false
uses: codecov/codecov-action@v4
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: backend/coverage.xml
flags: backend,python,api
name: backend-coverage
fail_ci_if_error: false
🤖 Prompt for AI Agents
In .github/workflows/run-tests.yml around lines 59 to 66, the Codecov action
uses the incorrect input key 'file:' which should be 'files:' to properly upload
coverage reports. Change the key from 'file:' to 'files:' to ensure the coverage
upload is executed correctly.

verbose: true
working-directory: ./
override_branch: ${{ github.head_ref }}
override_commit: ${{ github.event.pull_request.head.sha }}
Comment on lines +68 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

working-directory is not a recognised input for codecov/codecov-action@v4
This key is ignored. If you want to scope the search, use the supported directory input or move the key outside of with: as a step-level working-directory.

-        working-directory: ./
+        directory: backend
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
working-directory: ./
override_branch: ${{ github.head_ref }}
override_commit: ${{ github.event.pull_request.head.sha }}
directory: backend
override_branch: ${{ github.head_ref }}
override_commit: ${{ github.event.pull_request.head.sha }}
🤖 Prompt for AI Agents
In .github/workflows/run-tests.yml around lines 68 to 70, the
`working-directory` key is incorrectly used as an input for the
`codecov/codecov-action@v4` action, but it is not a recognized input and will be
ignored. To fix this, remove `working-directory` from the `with:` section and
either use the supported `directory` input to scope the search or move
`working-directory` to be a step-level key outside of `with:`.


- name: Codecov upload skipped for Dependabot
if: github.actor == 'dependabot[bot]'
run: echo "📊 Codecov upload skipped for Dependabot PR - tests still run and pass!"

test-frontend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install Frontend Dependencies
run: |
cd frontend
npm ci

- name: Run Frontend Tests (if available)
run: |
cd frontend
# Check if test script exists
if npm run test --dry-run 2>/dev/null; then
npm run test -- --coverage --watchAll=false --testResultsProcessor=jest-junit
else
echo "No frontend tests configured yet"
# Create a placeholder test result for analytics
mkdir -p test-results
echo '<?xml version="1.0"?><testsuites><testsuite name="frontend-placeholder" tests="1" failures="0" errors="0"><testcase name="placeholder" /></testsuite></testsuites>' > test-results/frontend-results.xml
fi

- name: Upload Frontend Test Analytics
uses: codecov/test-results-action@v1
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: frontend/test-results/frontend-results.xml
flags: frontend,javascript,react-native
name: "Frontend Test Results"

- name: Frontend Analytics Upload Skipped
if: github.actor == 'dependabot[bot]'
run: echo "📊 Frontend test analytics skipped for Dependabot PR"
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ repos:
hooks:
- id: isort
args: [--profile, black]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2 # Use the latest stable version of autopep8

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: autopep8
- id: flake8
Loading