diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..64a6868 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,102 @@ +name: Main + +on: push + +jobs: + linting: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Run analysis + run: flutter analyze + + formatting: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Check formatting + run: dart format --set-exit-if-changed . + + testing: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Run tests + run: flutter test + + integration-testing: + runs-on: macos-latest + environment: Main + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Create env file + env: + ENV_FILE: ${{ secrets.ENV_FILE }} + run: printenv ENV_FILE > env.json + - name: Set up simulator + uses: futureware-tech/simulator-action@v3 + with: + model: "iPhone 15" + os: iOS + - name: Run tests + run: flutter test integration_test --dart-define-from-file=env.json + + building-android: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Generates appbundle + run: flutter build appbundle + - name: Uploads appbundle + uses: actions/upload-artifact@v4 + with: + name: appbundle + path: build/app/outputs/bundle/release/app-release.aab + + building-ios: + runs-on: macos-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.19.4 + - name: Generates ipa + run: flutter build ipa --no-codesign + - name: Uploads ipa + uses: actions/upload-artifact@v4 + with: + name: ipa + path: build/ios/archive/Runner.xcarchive/ diff --git a/README.md b/README.md index 6563dfd..ee3aab6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Contains some goodies such as: - Offline-first - Caching - API keys via environment variables +- CI with [GitHub Actions](https://docs.github.com/en/actions) https://github.com/Ascenio/nasa_potday/assets/7662016/079d3cba-9222-4d96-b690-bb01a0bb32a9 diff --git a/integration_test/picture_of_the_day_test.dart b/integration_test/picture_of_the_day_test.dart index 3d5b3d1..5aae602 100644 --- a/integration_test/picture_of_the_day_test.dart +++ b/integration_test/picture_of_the_day_test.dart @@ -36,7 +36,7 @@ void main() { testWidgets('should display 7 pictures per page', (tester) async { await tester.pumpWidget(const MainApp()); await tester.pumpAndSettle(); - expectListViewHasNItems(tester: tester, itemCount: 7); + expectListViewSeparatedHasNItems(tester: tester, itemCount: 7); }); testWidgets('should search by date', (tester) async { @@ -50,7 +50,7 @@ void main() { expect(find.byType(PictureWidget), findsOne); await tester.tap(find.byIcon(Icons.chevron_left)); await tester.pumpAndSettle(); - expectListViewHasNItems(tester: tester, itemCount: 7); + expectListViewSeparatedHasNItems(tester: tester, itemCount: 7); }); testWidgets( diff --git a/integration_test/scroll_helpers.dart b/integration_test/scroll_helpers.dart index 9f63960..c5388e6 100644 --- a/integration_test/scroll_helpers.dart +++ b/integration_test/scroll_helpers.dart @@ -15,7 +15,7 @@ int listViewChildCount({ return listView.childrenDelegate.estimatedChildCount!; } -void expectListViewHasNItems({ +void expectListViewSeparatedHasNItems({ required WidgetTester tester, required int itemCount, }) { diff --git a/integration_test/scroll_test.dart b/integration_test/scroll_test.dart index 300f873..11bf34f 100644 --- a/integration_test/scroll_test.dart +++ b/integration_test/scroll_test.dart @@ -16,6 +16,6 @@ void main() { scrollable: find.byType(Scrollable), ); await tester.pumpAndSettle(); - expectListViewHasNItems(tester: tester, itemCount: 14); + expectListViewSeparatedHasNItems(tester: tester, itemCount: 14); }); } diff --git a/lib/features/picture_of_the_day/presentation/widgets/image_or_video_widget.dart b/lib/features/picture_of_the_day/presentation/widgets/image_or_video_widget.dart index a405f25..69ebfc1 100644 --- a/lib/features/picture_of_the_day/presentation/widgets/image_or_video_widget.dart +++ b/lib/features/picture_of_the_day/presentation/widgets/image_or_video_widget.dart @@ -34,15 +34,16 @@ class ImageOrVideoWidget extends StatelessWidget { fit: BoxFit.cover, errorWidget: (context, url, error) => ColoredBox( color: surfaceColor, - child: const Column( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.error_outline, size: 64, + color: isVideo ? Colors.transparent : null, ), - SizedBox(height: 16), - Text( + const SizedBox(height: 16), + const Text( 'Could not show the image', ) ],