Skip to content

Commit 670ca6e

Browse files
authored
Merge pull request #10 from aspicas/fix/cicd
Fix/cicd
2 parents c3da06e + b52cfa7 commit 670ca6e

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Flutter Tests & Coverage
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Flutter
18+
uses: subosito/flutter-action@v2
19+
with:
20+
flutter-version: "3.29.3"
21+
architecture: "x64"
22+
23+
- name: Install dependencies
24+
run: flutter pub get
25+
26+
- name: Verify formatting
27+
run: dart format --set-exit-if-changed .
28+
29+
- name: Analyze project source
30+
run: flutter analyze
31+
32+
- name: Run tests with coverage
33+
run: flutter test --coverage
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Validate merge source
2+
on:
3+
pull_request:
4+
branches: [main]
5+
6+
jobs:
7+
validate:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check source branch
11+
run: |
12+
if [ "${{ github.head_ref }}" != "develop" ]; then
13+
echo "Error: Only develop branch can merge to main"
14+
exit 1
15+
fi

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,31 @@ The setup script will:
3131
- Initialize Husky for git hooks (if present)
3232
- Add `.fvm/` to `.gitignore` if needed
3333

34+
## Testing
35+
36+
### Local Testing
37+
38+
Run tests with coverage locally:
39+
40+
```bash
41+
# Using the provided script (recommended)
42+
./scripts/test_with_coverage.sh
43+
44+
# Or manually
45+
fvm flutter test --coverage
46+
lcov --summary coverage/lcov.info
47+
genhtml coverage/lcov.info -o coverage/html
48+
open coverage/html/index.html
49+
```
50+
3451
## Contributing
3552

3653
Contributions are welcome! Please:
3754

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

4361
## License

scripts/test_with_coverage.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Flutter Policy Engine - Test with Coverage Script
4+
# This script runs all tests and generates coverage reports
5+
6+
set -e # Exit on any error
7+
8+
echo "🧪 Running Flutter tests with coverage..."
9+
10+
# Run tests with coverage
11+
fvm flutter test --coverage
12+
13+
echo "📊 Generating coverage summary..."
14+
lcov --summary coverage/lcov.info
15+
16+
echo "🌐 Generating HTML coverage report..."
17+
genhtml coverage/lcov.info -o coverage/html
18+
19+
echo "✅ Coverage report generated successfully!"
20+
echo "📁 HTML report available at: coverage/html/index.html"
21+
22+
# Open the coverage report in browser (macOS)
23+
if [[ "$OSTYPE" == "darwin"* ]]; then
24+
echo "🔗 Opening coverage report in browser..."
25+
open coverage/html/index.html
26+
else
27+
echo "📖 To view the coverage report, open: coverage/html/index.html"
28+
fi
29+
30+
echo "🎉 Test coverage process completed!"

0 commit comments

Comments
 (0)