From aeeacfc84bb10bb5f0797da0b5f73118260b2e37 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:04:47 +0000 Subject: [PATCH 1/3] Add comprehensive CI sanity checks and documentation Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com> --- .github/workflows/ci.yml | 115 +++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 20 ++++++- README.md | 17 ++++++ analysis_options.yaml | 5 ++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..68da105c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,115 @@ +name: CI - Sanity Checks + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + analyze: + name: Code Analysis + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + + - name: Cache Pub dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pub- + + - name: Install dependencies + run: flutter pub get + + - name: Verify formatting + run: | + # Find all Dart files excluding generated files + FILES=$(find lib test -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f 2>/dev/null || true) + if [ -z "$FILES" ]; then + echo "No Dart files found to format" + exit 0 + fi + echo "$FILES" | xargs dart format --output=none --set-exit-if-changed + + - name: Analyze code + run: flutter analyze + + test: + name: Unit Tests + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + + - name: Cache Pub dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pub- + + - name: Install dependencies + run: flutter pub get + + - name: Run tests + run: | + if [ -d "test" ] && [ "$(find test -name '*_test.dart' | wc -l)" -gt 0 ]; then + flutter test + else + echo "No tests found, skipping test execution" + fi + + dependency-check: + name: Dependency Validation + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + + - name: Cache Pub dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pub- + + - name: Verify dependencies + run: | + flutter pub get + flutter pub outdated diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1742ed9d..5f452b28 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,9 +10,27 @@ ## Development - Follow Dart/Flutter conventions -- Run `flutter analyze` before submitting +- Run `dart format .` to format your code +- Run `flutter analyze` before submitting to check for issues +- Run `flutter test` if tests are available - Test your changes thoroughly +### Code Quality Checks + +The project includes automated CI checks that run on all pull requests: + +1. **Code Formatting**: Ensures code follows Dart formatting standards + - Run locally: `dart format .` + - CI check excludes generated files (`.g.dart`, `.freezed.dart`) + +2. **Static Analysis**: Checks for code issues and potential bugs + - Run locally: `flutter analyze` + +3. **Tests**: Runs unit and widget tests (when available) + - Run locally: `flutter test` + +All these checks must pass before your changes can be merged. + ## Internationalization (i18n) This project uses `slang` for internationalization with JSON files. diff --git a/README.md b/README.md index e2092494..a9fff3c1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,23 @@ flutter run ## Development +### Code Quality + +Before submitting changes, ensure your code passes all quality checks: + +```bash +# Format code +dart format . + +# Analyze code for issues +flutter analyze + +# Run tests (if available) +flutter test +``` + +These checks are automatically run in CI for all pull requests. + ### Code Generation The project uses code generation for JSON serialization. After modifying model classes, run: diff --git a/analysis_options.yaml b/analysis_options.yaml index f9b30346..2e3c70e5 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1,6 @@ include: package:flutter_lints/flutter.yaml + +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" From fd64f26c5e3205af0cadf7fb8bf7573e15944b4a Mon Sep 17 00:00:00 2001 From: Doezer Date: Thu, 13 Nov 2025 23:04:06 +0100 Subject: [PATCH 2/3] Update .github/workflows/ci.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68da105c..9b9a27ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: - name: Verify formatting run: | # Find all Dart files excluding generated files - FILES=$(find lib test -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f 2>/dev/null || true) + FILES=$(find lib $([ -d test ] && echo test) -name "*.dart" ! -name "*.g.dart" ! -name "*.freezed.dart" -type f 2>/dev/null || true) if [ -z "$FILES" ]; then echo "No Dart files found to format" exit 0 From ce5e5d7f94ecd421db72a215dbf21ae15bbeaa59 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 22:07:01 +0000 Subject: [PATCH 3/3] Clarify documentation: explain generated file exclusions Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com> --- CONTRIBUTING.md | 8 +++++--- README.md | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f452b28..9ce9e5e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ ## Development - Follow Dart/Flutter conventions -- Run `dart format .` to format your code +- Run `dart format .` to format your code (note: generated files like `*.g.dart` are excluded from CI checks) - Run `flutter analyze` before submitting to check for issues - Run `flutter test` if tests are available - Test your changes thoroughly @@ -20,11 +20,13 @@ The project includes automated CI checks that run on all pull requests: 1. **Code Formatting**: Ensures code follows Dart formatting standards - - Run locally: `dart format .` - - CI check excludes generated files (`.g.dart`, `.freezed.dart`) + - Run locally: `dart format .` to format all files + - Note: CI only checks non-generated files (excludes `.g.dart`, `.freezed.dart`) + - Generated files are reformatted automatically by build tools 2. **Static Analysis**: Checks for code issues and potential bugs - Run locally: `flutter analyze` + - Note: CI excludes generated files from analysis (configured in `analysis_options.yaml`) 3. **Tests**: Runs unit and widget tests (when available) - Run locally: `flutter test` diff --git a/README.md b/README.md index a9fff3c1..b74aed11 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ flutter run Before submitting changes, ensure your code passes all quality checks: ```bash -# Format code +# Format code (including generated files) dart format . # Analyze code for issues @@ -92,6 +92,8 @@ flutter analyze flutter test ``` +**Note**: CI checks exclude generated files (`.g.dart`, `.freezed.dart`) from formatting and analysis checks. You can run `dart format .` locally to format everything, but only your hand-written code will be validated in CI. + These checks are automatically run in CI for all pull requests. ### Code Generation