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

Ci upd - Add APK in assets #9

Closed
wants to merge 8 commits into from
Closed
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
62 changes: 41 additions & 21 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ on:
branches: [ "main" ]

jobs:
integration-test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: '3.22.2'
- run: flutter pub get
- run: flutter config --enable-web
- run: sudo apt-get -y install xvfb xorg gtk2-engines-pixbuf
- name: test
env:
TEST_INSTANCE_URL: ${{ secrets.TEST_INSTANCE_URL }}
run: |
chromedriver --port=4444 &
flutter drive \
[email protected] \
--dart-define=ELN_PASSWORD=@complat \
--dart-define=ELN_URL=$TEST_INSTANCE_URL \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d web-server --browser-name=chrome --web-browser-flag "--disable-web-security --headless" --headless

build:
runs-on: ubuntu-latest

Expand All @@ -30,38 +55,33 @@ jobs:
echo flutter.targetSdkVersion=33 >> ./android/local.properties
echo flutter.compileSdkVersion=33 >> ./android/local.properties

- name: test
env:
TEST_INSTANCE_URL: ${{ secrets.TEST_INSTANCE_URL }}
run: |
echo "no testing"

# flutter packages pub run build_runner build
# flutter drive \
# [email protected] \
# --dart-define=ELN_PASSWORD=@complat \
# --dart-define=ELN_URL=$TEST_INSTANCE_URL
# --driver=test_driver/integration_test.dart \
# --target=integration_test/app_test.dart

- name: set key properties
# keyPassword="${{ secrets.KEY_PASSWORD }}"
# storePassword="${{ secrets.STORE_PASSWORD }}"
# keyAlias="${{ secrets.KEY_ALIAS }}
# storeFile=keystore.jks
run: |
echo keyPassword="${{ secrets.KEY_PASSWORD }}" > ./android/key.properties
echo storePassword="${{ secrets.STORE_PASSWORD }}" >> ./android/key.properties
echo keyAlias="${{ secrets.KEY_ALIAS }}" >> ./android/key.properties
echo storeFile=keystore.jks >> ./android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" > ./android/key.properties
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> ./android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> ./android/key.properties
echo "storeFile=keystore.jks" >> ./android/key.properties
echo "${{ secrets.KEY_JKS }}" | base64 --decode > ./android/app/keystore.jks
echo

# - run: flutter build apk


- run: flutter build appbundle
- run: flutter build apk --release

- name: Upload artefact
- name: Upload aab artefact
uses: actions/upload-artifact@v4
with:
name: appbundle
path: build/app/outputs/bundle/release/app-release.aab

# Add APk to assets
- name: Push to Releases
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/app-release.apk"
tag: v1.0.${{ github.run_number }}
token: ${{ secrets.TOKEN_SECRET }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols
Expand Down
14 changes: 12 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ samples, guidance on mobile development, and a full API reference.

```
flutter.minSdkVersion=21
flutter.targetSdkVersion=30
flutter.compileSdkVersion=30
flutter.targetSdkVersion=33
flutter.compileSdkVersion=33
```

## Editor Config for Sublime Text
Expand Down Expand Up @@ -111,3 +111,13 @@ flutter drive \
--target=integration_test/app_test.dart \
-d emu
```

## Run chrome device

Starts the app on chrome on a fixed port:


```
flutter run -d chrome --web-port=$DEF_PORT --web-browser-flag "--disable-web-security"
```

2 changes: 1 addition & 1 deletion integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void main() {
userIdentifier: userIdentifier,
password: password,
elnUrl: elnUrl,
validationUser: 'User1 Complat');
validationUser: 'User6 Complat');

devPrint('open task list');
await menuScreenRobot.openTaskList();
Expand Down
6 changes: 3 additions & 3 deletions integration_test/robots/archive_robot.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:chemobile/components/weighted_sample_archive_entry.dart';
import 'package:chemobile/components/archive_entry.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';

Expand All @@ -11,11 +11,11 @@ class ArchiveRobot {
await tester.pumpAndSettle();
await _validateArchiveScreen();

expect(find.byType(WeightedSampleArchiveEntry), findsNWidgets(count));
expect(find.byType(ArchiveEntry), findsNWidgets(count));
}

Future<void> openFirstScan() async {
await tester.tap(find.byType(WeightedSampleArchiveEntry).first);
await tester.tap(find.byType(ArchiveEntry).first);
}

Future<void> _validateArchiveScreen() async {
Expand Down
4 changes: 2 additions & 2 deletions integration_test/robots/menu_screen_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class MenuScreenRobot {

Future<void> openTaskList() async {
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ListTile, 'Weighted samples'));
await tester.tap(find.widgetWithText(ListTile, 'Unfinished tasks'));
}

Future<void> openArchive() async {
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ListTile, 'Previous Scans'));
await tester.tap(find.widgetWithText(ListTile, 'Finished tasks'));
}
}
4 changes: 2 additions & 2 deletions integration_test/robots/task_list_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TaskListRobot {
await tester.pumpAndSettle();
_validateTaskList();

await tester.tap(find.widgetWithIcon(FloatingActionButton, Icons.settings_overscan));
await tester.tap(find.widgetWithText(BottomNavigationBar, 'Start single scan'));
}

Future<void> backToMenuScreen() async {
Expand All @@ -21,6 +21,6 @@ class TaskListRobot {
}

void _validateTaskList() async {
expect(find.widgetWithText(AppBar, 'Weighted sample tasks'), findsOneWidget);
expect(find.widgetWithText(AppBar, 'Finished tasks'), findsOneWidget);
}
}
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:camera/camera.dart';
import 'package:chemobile/app.dart';
import 'package:flutter/material.dart';
Expand All @@ -12,7 +13,9 @@ void main() async {
cameras = await availableCameras();

final storage = await HydratedStorage.build(
storageDirectory: await getApplicationDocumentsDirectory(),
storageDirectory: kIsWeb
? HydratedStorage.webStorageDirectory
: await getApplicationDocumentsDirectory(),
);

HydratedBloc.storage = storage;
Expand Down
6 changes: 3 additions & 3 deletions lib/models/sample_task.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/models/scan_result.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/screens/init_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class _InitScreenState extends State<InitScreen> {
return Scaffold(
body: Container(
padding: const EdgeInsets.all(8.0),
child: Column(
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const <Widget>[
children: <Widget>[
Text('Init app...'),
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class _LoginScreenState extends State<LoginScreen> {
),
body: Container(
padding: const EdgeInsets.all(16.0),
child: Column(
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const <Widget>[
children: <Widget>[
LoginForm(),
],
),
Expand Down
5 changes: 2 additions & 3 deletions lib/screens/menu_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:chemobile/screens/scan_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../helpers/dev_print.dart';

class MenuScreen extends StatefulWidget {
const MenuScreen({Key? key}) : super(key: key);
Expand Down Expand Up @@ -102,9 +101,9 @@ class _MenuScreenState extends State<MenuScreen> {
}

Widget doubleScanIcon() {
return Row(
return const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [Icon(Icons.science), Icon(Icons.science)],
children: [Icon(Icons.science), Icon(Icons.science)],
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/screens/sample_tasks_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class _SampleTasksScreenState extends State<SampleTasksScreen> {
}

Widget doubleScanIcon() {
return Row(
return const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [Icon(Icons.science), Icon(Icons.science)],
children: [Icon(Icons.science), Icon(Icons.science)],
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/scan_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _ScanScreenState extends State<ScanScreen> {
String fallback = getCurrentUser(context).fullName;
SampleTask? currentTask = _sampleTasksCubit(context).currentSampleTask;

if (currentTask != null && currentTask!.targetAmountValue != null) {
if (currentTask != null && currentTask.targetAmountValue != null) {
return "Target amount value: ${currentTask.targetAmountValue} ${currentTask.targetAmountUnit}";
} else {
return fallback;
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/user_switcher_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class UserSwitcherScreen extends StatelessWidget {
),
body: Container(
padding: const EdgeInsets.all(16.0),
child: Column(
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const <Widget>[
children: <Widget>[
UserSwitcher(),
],
),
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
sha256: "644dc98a0f179b872f612d3eb627924b578897c629788e858157fa5e704ca0c7"
url: "https://pub.dev"
source: hosted
version: "2.4.9"
version: "2.4.11"
build_runner_core:
dependency: transitive
description:
Expand Down Expand Up @@ -981,5 +981,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
64 changes: 1 addition & 63 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,7 @@
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
return;
}
scriptLoaded = true;
var scriptTag = document.createElement('script');
scriptTag.src = 'main.dart.js';
scriptTag.type = 'application/javascript';
document.body.append(scriptTag);
}
<script src="flutter_bootstrap.js" async></script>

if ('serviceWorker' in navigator) {
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') {
console.log('Installed new service worker.');
loadMainDartJs();
}
});
}
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing || reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
reg.update();
waitForActivation(reg.installing);
} else {
// Existing service worker is still good.
console.log('Loading app from service worker.');
loadMainDartJs();
}
});

// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint <script> tag.
setTimeout(() => {
if (!scriptLoaded) {
console.warn(
'Failed to load app from service worker. Falling back to plain <script> tag.',
);
loadMainDartJs();
}
}, 4000);
});
} else {
// Service workers not supported. Just drop the <script> tag.
loadMainDartJs();
}
</script>
</body>
</html>
Loading