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
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Flutter Tests & Coverage

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.29.3"
architecture: "x64"

- name: Install dependencies
run: flutter pub get

- name: Verify formatting
run: dart format --set-exit-if-changed .

- name: Analyze project source
run: flutter analyze

- name: Run tests with coverage
run: flutter test --coverage
15 changes: 15 additions & 0 deletions .github/workflows/validate-resource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Validate merge source
on:
pull_request:
branches: [main]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Check source branch
run: |
if [ "${{ github.head_ref }}" != "develop" ]; then
echo "Error: Only develop branch can merge to main"
exit 1
fi
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,31 @@ The setup script will:
- Initialize Husky for git hooks (if present)
- Add `.fvm/` to `.gitignore` if needed

## Testing

### Local Testing

Run tests with coverage locally:

```bash
# Using the provided script (recommended)
./scripts/test_with_coverage.sh

# Or manually
fvm flutter test --coverage
lcov --summary coverage/lcov.info
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html
```

## Contributing

Contributions are welcome! Please:

- Follow the existing code style and patterns
- Write clear commit messages (Commitlint and Husky are enabled)
- Add or update tests for new features or bug fixes
- Ensure all tests pass before submitting a pull request
- Open a pull request with a clear description

## License
Expand Down
30 changes: 30 additions & 0 deletions scripts/test_with_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Flutter Policy Engine - Test with Coverage Script
# This script runs all tests and generates coverage reports

set -e # Exit on any error

echo "🧪 Running Flutter tests with coverage..."

# Run tests with coverage
fvm flutter test --coverage

echo "📊 Generating coverage summary..."
lcov --summary coverage/lcov.info

echo "🌐 Generating HTML coverage report..."
genhtml coverage/lcov.info -o coverage/html

echo "✅ Coverage report generated successfully!"
echo "📁 HTML report available at: coverage/html/index.html"

# Open the coverage report in browser (macOS)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "🔗 Opening coverage report in browser..."
open coverage/html/index.html
else
echo "📖 To view the coverage report, open: coverage/html/index.html"
fi

echo "🎉 Test coverage process completed!"
Loading