Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for mobile #4

Merged
merged 2 commits into from
Apr 29, 2024
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
44 changes: 44 additions & 0 deletions .github/workflows/lint-mobile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Linting Mobile

on:
pull_request:
branches:
- '**'
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- "mobile/**"
- ".github/workflows/lint-mobile.yml"

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint-mobile:
name: Lint Mobile
runs-on: ubuntu-latest
defaults:
run:
working-directory: mobile
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: mobile/pubspec.yaml

- name: Install dependencies
run: flutter pub get

- name: Run lint
run: flutter analyze --suppress-analytics
44 changes: 44 additions & 0 deletions .github/workflows/test-mobile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Testing Mobile

on:
pull_request:
branches:
- '**'
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- "mobile/**"
- ".github/workflows/test-mobile.yml"

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-mobile:
name: Test Mobile
runs-on: ubuntu-latest
defaults:
run:
working-directory: mobile
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: mobile/pubspec.yaml

- name: Install dependencies
run: flutter pub get

- name: Run tests
run: flutter test
3 changes: 2 additions & 1 deletion mobile/lib/widgets/layout/main_bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class _MainBottomNavigationBarState extends State<MainBottomNavigationBar> {
context.go(route);
},
indicatorColor: ThemeColors.primary,
selectedIndex: routeIndexMapping[routerState.matchedLocation] ?? 0,
selectedIndex: routeIndexMapping[routerState.matchedLocation] ??
routeIndexMapping.values.first,
destinations: <Widget>[
NavigationDestination(
selectedIcon: const Icon(Icons.home),
Expand Down
2 changes: 1 addition & 1 deletion mobile/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ packages:
version: "13.0.0"
sdks:
dart: ">=3.3.1 <4.0.0"
flutter: ">=3.16.0"
flutter: ">=3.19.3"
3 changes: 2 additions & 1 deletion mobile/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mobile
description: "A new Flutter project."
description: "The mobile app for the project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
Expand All @@ -20,6 +20,7 @@ version: 1.0.0+1

environment:
sdk: '>=3.3.1 <4.0.0'
flutter: 3.19.3

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
14 changes: 14 additions & 0 deletions mobile/test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:mobile/main.dart';

void main() {
group('App', () {
testWidgets('App loads correctly', (WidgetTester tester) async {
await tester.pumpWidget(const ForDemocracyApp());

// Screen + Bottom Navigation Bar
expect(find.text('Planets'), findsExactly(2));
});
});
}
30 changes: 0 additions & 30 deletions mobile/test/widget_test.dart

This file was deleted.