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
73 changes: 73 additions & 0 deletions .github/workflows/bundle-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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@v4
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"
86 changes: 77 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests
name: Run Tests & Analytics

on:
pull_request:
Expand All @@ -12,6 +12,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better diff analysis

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -24,21 +26,87 @@ jobs:
cd backend
pip install -r requirements.txt

- name: Run tests
- name: Run Backend Tests with Coverage
run: |
cd $GITHUB_WORKSPACE
export PYTHONPATH=$GITHUB_WORKSPACE:$GITHUB_WORKSPACE/backend
pytest --cov=./backend --cov-report=xml:coverage.xml backend/tests/

- name: Upload coverage to Codecov
# Generate coverage with detailed flags
pytest \
--cov=./backend \
--cov-report=xml:coverage.xml \
--cov-report=json:coverage.json \
--cov-report=lcov:coverage.lcov \
--junit-xml=test-results.xml \
--tb=short \
-v \
backend/tests/

- 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
flags: backend,test-analytics
name: "Backend Test Results"

- name: Upload Coverage to Codecov with Flags
uses: codecov/codecov-action@v4
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
files: ./coverage.xml,./coverage.json,./coverage.lcov
flags: backend,python,api
name: "Backend Coverage"
fail_ci_if_error: false
# Skip codecov upload for Dependabot PRs since they don't have access to secrets
if: github.actor != 'dependabot[bot]'

verbose: true

- 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"
22 changes: 20 additions & 2 deletions backend/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,23 @@ python_files = test_*.py tests_*.py *_test.py *_tests.py
python_classes = Test* Tests*
python_functions = test_*

# Optional: Add default command line options if desired
# addopts = --verbose
# Enhanced options for better test analytics and coverage
addopts =
--verbose
--tb=short
--strict-markers
--disable-warnings
--durations=10
--cov-branch
--cov-fail-under=0

# Test markers for categorization
markers =
unit: Unit tests
integration: Integration tests
auth: Authentication related tests
expenses: Expense management tests
groups: Group management tests
user: User management tests
slow: Slow running tests
api: API endpoint tests
84 changes: 82 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,101 @@
# Codecov configuration for SplitWiser
# Documentation: https://docs.codecov.com/docs/codecov-yaml
# Features: Test Analytics, Flags, Components, Bundle Analysis

coverage:
status:
project:
default:
target: auto
threshold: 1%
# Allow slight coverage drops for dependency updates
if_ci_failed: error
backend:
target: auto
threshold: 1%
flags:
- backend
paths:
- backend/
frontend:
target: auto
threshold: 1%
flags:
- frontend
paths:
- frontend/
patch:
default:
target: auto
threshold: 1%
# More lenient for dependency-only changes
if_ci_failed: error

# Flags for different parts of the codebase
flag_management:
default_rules:
carryforward: true
statuses:
- type: project
target: auto
threshold: 1%
- type: patch
target: auto
threshold: 1%

# Components for modular coverage tracking
component_management:
default_rules:
statuses:
- type: project
target: auto
- type: patch
target: auto
individual_components:
- component_id: backend-auth
name: "Authentication System"
paths:
- backend/app/auth/
- backend/tests/auth/
flag_regexes:
- backend
- component_id: backend-expenses
name: "Expense Management"
paths:
- backend/app/expenses/
- backend/tests/expenses/
flag_regexes:
- backend
- component_id: backend-groups
name: "Group Management"
paths:
- backend/app/groups/
- backend/tests/groups/
flag_regexes:
- backend
- component_id: backend-user
name: "User Management"
paths:
- backend/app/user/
- backend/tests/user/
flag_regexes:
- backend
- component_id: frontend-core
name: "Frontend Core"
paths:
- frontend/
flag_regexes:
- frontend

# Test Analytics configuration
test_analytics:
# Track test performance and flakiness
notify:
after_n_builds: 5
slack:
url: "https://hooks.slack.com/services/your/slack/webhook"
threshold: 5%
message: "Test suite analytics show concerning trends"
only_pulls: false

# Ignore files that don't need coverage
ignore:
- "**/__pycache__/**"
Expand Down
Loading