Skip to content

Commit ddea2b5

Browse files
Fix: Adjust Codecov thresholds and paths for backend coverage; improve frontend test handling (#112)
* Fix: Adjust Codecov thresholds and paths for backend coverage; improve frontend test handling * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Refactor: Update Codecov configuration to simplify component management and ignore frontend directory; add setup.cfg for Flake8 configuration * Refactor: Rename workflow to clarify focus on backend tests; remove frontend test steps * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix: Add TODO comment to indicate removal of Flake8 ignore rules upon PEP 8 compliance --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e3fff9a commit ddea2b5

27 files changed

+352
-523
lines changed

.codecov.yml

Lines changed: 35 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ coverage:
1313
project:
1414
default:
1515
target: auto
16-
threshold: 0.5
16+
threshold: 1.0 # Reduced threshold to be less strict
1717
if_ci_failed: error
18-
flag_coverage_not_uploaded_behavior: include
18+
if_not_found: success # Don't fail if coverage not found
1919
patch:
2020
default:
21-
target: 80%
22-
threshold: 0.5
21+
target: 70% # Reduced from 80% to be more achievable
22+
threshold: 1.0
2323
if_ci_failed: error
24+
if_not_found: success
2425
branches:
25-
- "!main" # Don't require patch coverage on main branch
26+
- "!main"
27+
- "!master"
2628
changes: false
2729

2830
# Flags for different parts of the codebase
@@ -32,82 +34,49 @@ flag_management:
3234
statuses:
3335
- type: project
3436
target: auto
35-
threshold: 0.5
36-
branches:
37-
- "!main"
37+
threshold: 1.0
38+
if_not_found: success
3839
- type: patch
39-
target: 80%
40-
threshold: 0.5
40+
target: 70%
41+
threshold: 1.0
42+
if_not_found: success
4143

4244
# Components for modular coverage tracking
4345
component_management:
4446
default_rules:
4547
statuses:
4648
- type: project
4749
target: auto
48-
threshold: 0.5
49-
branches:
50-
- "!main"
50+
threshold: 1.0
51+
if_not_found: success
5152
- type: patch
52-
target: 80%
53-
threshold: 0.5
53+
target: 70%
54+
threshold: 1.0
55+
if_not_found: success
5456
individual_components:
5557
- component_id: backend-auth
5658
name: "Authentication System"
5759
paths:
58-
- backend/app/auth/**
59-
flag_regexes:
60-
- backend
60+
- "backend/app/auth/**"
6161
- component_id: backend-expenses
6262
name: "Expense Management"
6363
paths:
64-
- backend/app/expenses/**
65-
flag_regexes:
66-
- backend
64+
- "backend/app/expenses/**"
6765
- component_id: backend-groups
6866
name: "Group Management"
6967
paths:
70-
- backend/app/groups/**
71-
flag_regexes:
72-
- backend
68+
- "backend/app/groups/**"
7369
- component_id: backend-user
7470
name: "User Management"
7571
paths:
76-
- backend/app/user/**
77-
flag_regexes:
78-
- backend
72+
- "backend/app/user/**"
7973
- component_id: backend-core
8074
name: "Backend Core"
8175
paths:
82-
- backend/app/config.py
83-
- backend/app/database.py
84-
- backend/app/dependencies.py
85-
- backend/main.py
86-
flag_regexes:
87-
- backend
88-
- component_id: frontend-auth
89-
name: "Frontend Authentication"
90-
paths:
91-
- frontend/contexts/AuthContext.tsx
92-
- frontend/screens/LoginScreen.tsx
93-
flag_regexes:
94-
- frontend
95-
- component_id: frontend-screens
96-
name: "Frontend Screens"
97-
paths:
98-
- frontend/screens/**
99-
flag_regexes:
100-
- frontend
101-
- component_id: frontend-core
102-
name: "Frontend Core"
103-
paths:
104-
- frontend/App.tsx
105-
- frontend/contexts/**
106-
flag_regexes:
107-
- frontend
108-
109-
# Test Analytics configuration (removed - not supported in codecov.yml)
110-
# Use test-results-action in GitHub Actions instead
76+
- "backend/app/config.py"
77+
- "backend/app/database.py"
78+
- "backend/app/dependencies.py"
79+
- "backend/main.py"
11180

11281
# Ignore files that don't need coverage
11382
ignore:
@@ -122,23 +91,23 @@ ignore:
12291
- "setup*.sh"
12392
- "setup*.bat"
12493
- "*.json"
125-
- "ui-poc/**" # Ignore POC frontend since we have main frontend
126-
94+
- "ui-poc/**"
95+
- "frontend/**" # Ignore entire frontend directory
96+
- "**/node_modules/**"
97+
- "**/dist/**"
98+
- "**/build/**"
99+
- "**/*.config.js"
100+
- "**/*.config.ts"
127101

128102
# Comments on PRs
129103
comment:
130-
layout: "header, diff, flags, components"
104+
layout: "header, diff, components"
131105
behavior: default
132106
require_changes: false
133107
require_base: false
134-
require_head: true
108+
require_head: false # Don't require head report to show comment
135109
show_carryforward_flags: false
136110

137111
# Make codecov less strict for Dependabot PRs
138112
github_checks:
139-
annotations: true
140-
141-
# Prevent coverage drops due to removed code
142-
fixes:
143-
- "backend/app/::" # Strip backend/app/ prefix from paths
144-
- "frontend/::" # Strip frontend/ prefix from paths
113+
annotations: true
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# DISABLED: Frontend bundle analysis - no frontend tests currently
2+
# This workflow is disabled because we don't have frontend tests
3+
# and don't plan to implement them. Can be re-enabled if needed in the future.
4+
5+
# name: Bundle Analysis
6+
7+
# on:
8+
# pull_request:
9+
# paths:
10+
# - 'frontend/**'
11+
# branches: [ main, master ]
12+
# push:
13+
# paths:
14+
# - 'frontend/**'
15+
# branches: [ main, master ]
16+
17+
# jobs:
18+
# bundle-analysis:
19+
# runs-on: ubuntu-latest
20+
#
21+
# steps:
22+
# - uses: actions/checkout@v4
23+
# with:
24+
# fetch-depth: 0
25+
#
26+
# - name: Set up Node.js
27+
# uses: actions/setup-node@v4
28+
# with:
29+
# node-version: '18'
30+
# cache: 'npm'
31+
# cache-dependency-path: frontend/package-lock.json
32+
#
33+
# - name: Install Dependencies
34+
# run: |
35+
# cd frontend
36+
# npm ci
37+
#
38+
# - name: Build for Bundle Analysis
39+
# run: |
40+
# cd frontend
41+
# # Create a production build for analysis
42+
# if npm run build --dry-run 2>/dev/null; then
43+
# npm run build
44+
# else
45+
# # Use Expo's build process
46+
# npx expo export:web
47+
# fi
48+
#
49+
# - name: Analyze Bundle Size
50+
# run: |
51+
# cd frontend
52+
# # Install bundle analyzer
53+
# npm install --no-save webpack-bundle-analyzer
54+
#
55+
# # Generate bundle stats (adjust path based on your build output)
56+
# if [ -d "web-build" ]; then
57+
# # Expo web build
58+
# npx webpack-bundle-analyzer web-build/static/js/*.js --report --mode static --report-filename bundle-report.html
59+
# elif [ -d "dist" ]; then
60+
# # Standard React build
61+
# npx webpack-bundle-analyzer dist/static/js/*.js --report --mode static --report-filename bundle-report.html
62+
# else
63+
# echo "No build output found for bundle analysis"
64+
# fi
65+
#
66+
# - name: Upload Bundle Analysis to Codecov
67+
# uses: codecov/codecov-action@v5
68+
# if: github.actor != 'dependabot[bot]'
69+
# with:
70+
# token: ${{ secrets.CODECOV_TOKEN }}
71+
# flags: bundle,frontend,javascript
72+
# name: "Bundle Analysis"
73+
# fail_ci_if_error: false
74+
#
75+
# - name: Bundle Analysis Skipped
76+
# if: github.actor == 'dependabot[bot]'
77+
# run: echo "📦 Bundle analysis skipped for Dependabot PR"

.github/workflows/run-tests.yml

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests & Analytics
1+
name: Run Backend Tests & Analytics
22

33
on:
44
pull_request:
@@ -28,85 +28,47 @@ jobs:
2828
2929
- name: Run Backend Tests with Coverage
3030
run: |
31-
cd $GITHUB_WORKSPACE
32-
export PYTHONPATH=$GITHUB_WORKSPACE:$GITHUB_WORKSPACE/backend
33-
# Generate coverage with detailed flags
31+
cd backend
32+
export PYTHONPATH=$GITHUB_WORKSPACE/backend:$GITHUB_WORKSPACE
33+
# Generate coverage with proper paths
3434
pytest \
35-
--cov=./backend \
35+
--cov=app \
3636
--cov-report=xml:coverage.xml \
37-
--cov-report=json:coverage.json \
38-
--cov-report=lcov:coverage.lcov \
37+
--cov-report=term-missing \
3938
--junit-xml=test-results.xml \
4039
--tb=short \
4140
-v \
42-
backend/tests/
41+
tests/
4342
43+
- name: List coverage files for debugging
44+
run: |
45+
echo "Coverage files generated:"
46+
find . -name "coverage.*" -type f | head -10
47+
ls -la backend/ | grep -E "(coverage|test-results)"
48+
4449
- name: Run Test Analytics Upload
4550
uses: codecov/test-results-action@v1
4651
if: github.actor != 'dependabot[bot]'
4752
with:
4853
token: ${{ secrets.CODECOV_TOKEN }}
49-
files: test-results.xml
54+
files: backend/test-results.xml
5055
flags: backend,test-analytics
5156
name: "Backend Test Results"
5257

5358
- name: Upload Coverage to Codecov with Flags
54-
uses: codecov/codecov-action@v5
59+
uses: codecov/codecov-action@v4
5560
if: github.actor != 'dependabot[bot]'
5661
with:
5762
token: ${{ secrets.CODECOV_TOKEN }}
58-
files: ./coverage.xml,./coverage.json,./coverage.lcov
63+
file: backend/coverage.xml
5964
flags: backend,python,api
60-
name: "Backend Coverage"
65+
name: backend-coverage
6166
fail_ci_if_error: false
6267
verbose: true
68+
working-directory: ./
69+
override_branch: ${{ github.head_ref }}
70+
override_commit: ${{ github.event.pull_request.head.sha }}
6371

6472
- name: Codecov upload skipped for Dependabot
6573
if: github.actor == 'dependabot[bot]'
6674
run: echo "📊 Codecov upload skipped for Dependabot PR - tests still run and pass!"
67-
68-
test-frontend:
69-
runs-on: ubuntu-latest
70-
71-
steps:
72-
- uses: actions/checkout@v4
73-
with:
74-
fetch-depth: 0
75-
76-
- name: Set up Node.js
77-
uses: actions/setup-node@v4
78-
with:
79-
node-version: '18'
80-
cache: 'npm'
81-
cache-dependency-path: frontend/package-lock.json
82-
83-
- name: Install Frontend Dependencies
84-
run: |
85-
cd frontend
86-
npm ci
87-
88-
- name: Run Frontend Tests (if available)
89-
run: |
90-
cd frontend
91-
# Check if test script exists
92-
if npm run test --dry-run 2>/dev/null; then
93-
npm run test -- --coverage --watchAll=false --testResultsProcessor=jest-junit
94-
else
95-
echo "No frontend tests configured yet"
96-
# Create a placeholder test result for analytics
97-
mkdir -p test-results
98-
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
99-
fi
100-
101-
- name: Upload Frontend Test Analytics
102-
uses: codecov/test-results-action@v1
103-
if: github.actor != 'dependabot[bot]'
104-
with:
105-
token: ${{ secrets.CODECOV_TOKEN }}
106-
files: frontend/test-results/frontend-results.xml
107-
flags: frontend,javascript,react-native
108-
name: "Frontend Test Results"
109-
110-
- name: Frontend Analytics Upload Skipped
111-
if: github.actor == 'dependabot[bot]'
112-
run: echo "📊 Frontend test analytics skipped for Dependabot PR"

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ repos:
99
hooks:
1010
- id: isort
1111
args: [--profile, black]
12-
- repo: https://github.com/hhatto/autopep8
13-
rev: v2.3.2 # Use the latest stable version of autopep8
12+
13+
- repo: https://github.com/pycqa/flake8
14+
rev: 7.1.1
1415
hooks:
15-
- id: autopep8
16+
- id: flake8

0 commit comments

Comments
 (0)