From e2dd208d15d98b0c9d52907ac0b557e5069c37ab Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 21:33:34 +0100 Subject: [PATCH 01/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/e2e.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 00000000..1796a4cd --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,71 @@ +name: e2e + +on: + pull_request: + branches: + - main + +defaults: + run: + working-directory: example + +jobs: + test_ios: + name: ๐Ÿ“ฑ Testing on iOS + + strategy: + matrix: + device: + - 'i' + test_file: + - '' + fail-fast: true + + runs-on: macos-latest + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿฆ Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: ๐Ÿ”ง Setting Up Simulator + uses: futureware-tech/simulator-action@v2 + with: + model: 'iPhone 11' + + - name: ๐Ÿงช Testing + run: fluttium test ${{ matrix.test_file }} + + test_android: + name: ๐Ÿค– Testing on Android + + strategy: + matrix: + api_level: + - 29 + fail-fast: true + + runs-on: macos-latest + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿฆ Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - name: ๐Ÿงช Testing + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api_level }} + arch: x86_64 + profile: Nexus 6 + script: fluttium test ${{ matrix.test_file }} From b8c9febf42813b6d838d0e1534fdd04571ade4b6 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 21:56:26 +0100 Subject: [PATCH 02/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 1796a4cd..26b29185 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -11,8 +11,6 @@ defaults: jobs: test_ios: - name: ๐Ÿ“ฑ Testing on iOS - strategy: matrix: device: @@ -33,6 +31,11 @@ jobs: channel: stable cache: true + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + dart pub global activate --source path ../packages/fluttium_cli + - name: ๐Ÿ”ง Setting Up Simulator uses: futureware-tech/simulator-action@v2 with: @@ -42,8 +45,6 @@ jobs: run: fluttium test ${{ matrix.test_file }} test_android: - name: ๐Ÿค– Testing on Android - strategy: matrix: api_level: @@ -62,6 +63,11 @@ jobs: channel: stable cache: true + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + dart pub global activate --source path ../packages/fluttium_cli + - name: ๐Ÿงช Testing uses: reactivecircus/android-emulator-runner@v2 with: From 9a6413a7f28b03ab42a685919a09135d321f5b48 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 21:57:30 +0100 Subject: [PATCH 03/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 26b29185..62e67042 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -13,10 +13,8 @@ jobs: test_ios: strategy: matrix: - device: - - 'i' test_file: - - '' + - flows/text_flow.yaml fail-fast: true runs-on: macos-latest @@ -47,8 +45,8 @@ jobs: test_android: strategy: matrix: - api_level: - - 29 + test_file: + - flows/text_flow.yaml fail-fast: true runs-on: macos-latest @@ -71,7 +69,7 @@ jobs: - name: ๐Ÿงช Testing uses: reactivecircus/android-emulator-runner@v2 with: - api-level: ${{ matrix.api_level }} + api-level: 29 arch: x86_64 profile: Nexus 6 script: fluttium test ${{ matrix.test_file }} From 48a58b1ab15ad265386f18af72d04365a162485d Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:06:27 +0100 Subject: [PATCH 04/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 47 +++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 62e67042..bff6203f 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -35,14 +35,18 @@ jobs: dart pub global activate --source path ../packages/fluttium_cli - name: ๐Ÿ”ง Setting Up Simulator + id: simulator uses: futureware-tech/simulator-action@v2 with: model: 'iPhone 11' + - name: devices + run: flutter --no-version-check devices --machine + - name: ๐Ÿงช Testing - run: fluttium test ${{ matrix.test_file }} + run: fluttium test -d ${{ steps.simulator.outputs.udid }} ${{ matrix.test_file }} - test_android: + test_macos: strategy: matrix: test_file: @@ -67,9 +71,36 @@ jobs: dart pub global activate --source path ../packages/fluttium_cli - name: ๐Ÿงช Testing - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - arch: x86_64 - profile: Nexus 6 - script: fluttium test ${{ matrix.test_file }} + run: fluttium test -d macos ${{ matrix.test_file }} + + # test_android: + # strategy: + # matrix: + # test_file: + # - flows/text_flow.yaml + # fail-fast: true + + # runs-on: macos-latest + + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 + + # - name: ๐Ÿฆ Setup Flutter + # uses: subosito/flutter-action@v2 + # with: + # channel: stable + # cache: true + + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # dart pub global activate --source path ../packages/fluttium_cli + + # - name: ๐Ÿงช Testing + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # api-level: 29 + # arch: x86_64 + # profile: Nexus 6 + # script: fluttium test ${{ matrix.test_file }} From 79641a71d6ae90de1458d504c790a76e011674dc Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:19:51 +0100 Subject: [PATCH 05/43] ci: add e2e tests for user flows --- .../local_fluttium_environment/action.yaml | 16 +++++++++ .github/workflows/e2e.yaml | 33 ++++++------------- 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 .github/actions/local_fluttium_environment/action.yaml diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml new file mode 100644 index 00000000..3c94e0d8 --- /dev/null +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -0,0 +1,16 @@ +name: Local Fluttium Environment + +runs: + using: "composite" + steps: + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - shell: bash + run: dart pub global activate --source path packages/fluttium_cli + + - shell: bash + run: tools/setup_local_development.sh + diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index bff6203f..158a3efd 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: test_file: - - flows/text_flow.yaml + - text_flow fail-fast: true runs-on: macos-latest @@ -23,16 +23,11 @@ jobs: - name: ๐Ÿ“š Git Checkout uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - dart pub global activate --source path ../packages/fluttium_cli + run: flutter pub get - name: ๐Ÿ”ง Setting Up Simulator id: simulator @@ -40,17 +35,14 @@ jobs: with: model: 'iPhone 11' - - name: devices - run: flutter --no-version-check devices --machine - - name: ๐Ÿงช Testing - run: fluttium test -d ${{ steps.simulator.outputs.udid }} ${{ matrix.test_file }} + run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.test_file }}.yaml test_macos: strategy: matrix: test_file: - - flows/text_flow.yaml + - text_flow fail-fast: true runs-on: macos-latest @@ -59,19 +51,14 @@ jobs: - name: ๐Ÿ“š Git Checkout uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - dart pub global activate --source path ../packages/fluttium_cli + run: flutter pub get - name: ๐Ÿงช Testing - run: fluttium test -d macos ${{ matrix.test_file }} + run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml # test_android: # strategy: From ef011d6dc13b8f664d9b890acdf4673129592f7b Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:27:25 +0100 Subject: [PATCH 06/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 158a3efd..f76471db 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -27,7 +27,9 @@ jobs: uses: ./.github/actions/local_fluttium_environment - name: ๐Ÿ“ฆ Installing packages - run: flutter pub get + run: | + flutter pub get + cd macos && pod install && cd .. - name: ๐Ÿ”ง Setting Up Simulator id: simulator @@ -55,7 +57,9 @@ jobs: uses: ./.github/actions/local_fluttium_environment - name: ๐Ÿ“ฆ Installing packages - run: flutter pub get + run: | + flutter pub get + cd macos && pod install && cd .. - name: ๐Ÿงช Testing run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml From 10bc61cf5337c3d8dbcc01ad38340676edeadaeb Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:45:08 +0100 Subject: [PATCH 07/43] ci: add e2e tests for user flows --- .github/actions/local_fluttium_environment/action.yaml | 9 +++++++-- packages/fluttium_cli/lib/src/commands/test_command.dart | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index 3c94e0d8..2feebc8b 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -9,8 +9,13 @@ runs: cache: true - shell: bash - run: dart pub global activate --source path packages/fluttium_cli + run: tools/setup_local_development.sh - shell: bash - run: tools/setup_local_development.sh + run: dart pub global activate mason_cli + - shell: bash + run: tools/bundle_all_bricks.sh + + - shell: bash + run: dart pub global activate --source path packages/fluttium_cli diff --git a/packages/fluttium_cli/lib/src/commands/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command.dart index e5f3207f..2d99bdb9 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command.dart @@ -241,6 +241,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to target: results.wasParsed('target') ? target.path : null, flavor: _flavor, dartDefines: [...fluttium.driver.dartDefines, ..._dartDefines], + deviceId: results['device-id'] as String?, ), ); From 6f10362fa8556b392599d4f79e27b08908f11a67 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:46:39 +0100 Subject: [PATCH 08/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f76471db..daed3cb9 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -10,7 +10,7 @@ defaults: working-directory: example jobs: - test_ios: + ios: strategy: matrix: test_file: @@ -40,7 +40,7 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.test_file }}.yaml - test_macos: + macos: strategy: matrix: test_file: @@ -64,7 +64,7 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml - # test_android: + # android: # strategy: # matrix: # test_file: From 284441179d3201b3041e9e0f740254f481f50243 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 22:57:13 +0100 Subject: [PATCH 09/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- .../fluttium_cli/lib/src/commands/test_command.dart | 10 +--------- .../test/src/commands/test_command_test.dart | 5 ++--- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index daed3cb9..b3e02fd2 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -29,7 +29,7 @@ jobs: - name: ๐Ÿ“ฆ Installing packages run: | flutter pub get - cd macos && pod install && cd .. + cd ios && pod install && cd .. - name: ๐Ÿ”ง Setting Up Simulator id: simulator diff --git a/packages/fluttium_cli/lib/src/commands/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command.dart index 2d99bdb9..74be01b6 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command.dart @@ -138,15 +138,7 @@ Multiple defines can be passed by repeating "--dart-define" multiple times.''', device = devices.first; retrievingDevices.complete(); } else { - final optionalDeviceId = results['device-id'] as String?; - if (optionalDeviceId != null && optionalDeviceId.isNotEmpty) { - retrievingDevices.complete(); - device = devices.firstWhereOrNull( - (device) => device.id == optionalDeviceId.trim(), - ); - } else { - retrievingDevices.cancel(); - } + retrievingDevices.cancel(); } return device ?? diff --git a/packages/fluttium_cli/test/src/commands/test_command_test.dart b/packages/fluttium_cli/test/src/commands/test_command_test.dart index 9da58da3..03a28007 100644 --- a/packages/fluttium_cli/test/src/commands/test_command_test.dart +++ b/packages/fluttium_cli/test/src/commands/test_command_test.dart @@ -547,10 +547,9 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to expect(await future, equals(ExitCode.success.code)); - verify( + verifyNever( () => logger.progress(any(that: equals('Retrieving devices'))), - ).called(1); - verify(retrievingDevices.complete).called(1); + ); verifyNever(retrievingDevices.cancel); verifyNever( () => logger.chooseOne( From 3cad7bfc2b0701a57ea017a285b60e7670992d59 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 23:39:22 +0100 Subject: [PATCH 10/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 68 ++++++--- .../lib/src/commands/test_command.dart | 131 +++++++++++++----- 2 files changed, 142 insertions(+), 57 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index b3e02fd2..2757acb0 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -10,11 +10,38 @@ defaults: working-directory: example jobs: + flows: + runs-on: ubuntu-latest + + outputs: + flows: ${{ steps.flows.outputs.flows }} + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿ“ฆ Finding a package to publish + id: package + run: | + flows="[" + for flow in ./flows/*.yaml; do + flows="$flows\"$(basename $flow .yaml)\"," + done + + # Remove last "," and add the closing bracket + if [[ $flows == *, ]]; then + flows="${flows%?}" + fi + flows="$flows]" + + echo "flows=$( echo "$flows" )" >> $GITHUB_OUTPUT + ios: + needs: flows + strategy: matrix: - test_file: - - text_flow + package: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true runs-on: macos-latest @@ -40,29 +67,30 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.test_file }}.yaml - macos: - strategy: - matrix: - test_file: - - text_flow - fail-fast: true + # macos: + # needs: flows - runs-on: macos-latest + # strategy: + # matrix: + # package: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # runs-on: macos-latest - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - cd macos && pod install && cd .. + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: ๐Ÿงช Testing - run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # cd macos && pod install && cd .. + + # - name: ๐Ÿงช Testing + # run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml # android: # strategy: diff --git a/packages/fluttium_cli/lib/src/commands/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command.dart index 74be01b6..8fa0eb51 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command.dart @@ -260,49 +260,18 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to ); final stepStates = []; + final printer = + (stdin.hasTerminal ? PrettyPrinter.new : SimplePrinter.new)(_logger); + driver.steps.listen( (steps) { stepStates ..clear() ..addAll(steps); - // Reset the cursor to the top of the screen and clear the screen. - _logger.info(''' -\u001b[0;0H\u001b[0J - ${styleBold.wrap(driver.userFlow.description)} -'''); - - // Render the steps. - for (final step in steps) { - switch (step.status) { - case StepStatus.initial: - _logger.info(' ๐Ÿ”ฒ ${step.description}'); - break; - case StepStatus.running: - _logger.info(' โณ ${step.description}'); - break; - case StepStatus.done: - _logger.info(' โœ… ${step.description}'); - for (final file in step.files.entries) { - _logger.detail('Writing ${file.value.length} bytes to $file'); - File(file.key) - ..createSync(recursive: true) - ..writeAsBytesSync(file.value); - } - break; - case StepStatus.failed: - _logger.info(' โŒ ${step.description}'); - break; - } - } - - _logger.info(''); - if (watch) { - _logger.info(''' - ${styleDim.wrap('Press')} r ${styleDim.wrap('to restart the test.')} - ${styleDim.wrap('Press')} q ${styleDim.wrap('to quit.')}'''); - } + printer.print(steps, driver.userFlow, watch); }, + onDone: printer.done, onError: (Object err) { if (err is FatalDriverException) { _logger.err(' Fatal driver exception occurred: ${err.reason}'); @@ -313,6 +282,9 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to ); if (watch) { + if (!stdin.hasTerminal) { + throw UnsupportedError('Watch provided but no terminal was attached'); + } stdin ..echoMode = false ..lineMode = false @@ -328,7 +300,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to await driver.run(watch: watch); - if (watch) { + if (watch && stdin.hasTerminal) { stdin ..lineMode = true ..echoMode = true; @@ -342,3 +314,88 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to return ExitCode.success.code; } } + +abstract class Printer { + Printer(this.logger); + + final Logger logger; + + void print(List steps, UserFlowYaml userFlow, bool watch); + + void done(); +} + +class SimplePrinter extends Printer { + SimplePrinter(super.logger); + + Progress? _progress; + + @override + void print(List steps, UserFlowYaml userFlow, bool watch) { + final currentStep = steps.firstWhere( + (step) => + step.status == StepStatus.running || step.status == StepStatus.failed, + orElse: () => steps.first, + ); + _progress ??= logger.progress(''); + + final index = steps.indexOf(currentStep) + 1; + _progress?.update('$index/${steps.length} ${currentStep.description}'); + + if (currentStep.status == StepStatus.failed) { + _progress?.fail(); + } + } + + @override + void done() { + _progress?.complete(); + } +} + +class PrettyPrinter extends Printer { + PrettyPrinter(super.logger); + + @override + void print(List steps, UserFlowYaml userFlow, bool watch) { + // Reset the cursor to the top of the screen and clear the screen. + logger.info(''' +\u001b[0;0H\u001b[0J + ${styleBold.wrap(userFlow.description)} +'''); + + // Render the steps. + for (final step in steps) { + switch (step.status) { + case StepStatus.initial: + logger.info(' ๐Ÿ”ฒ ${step.description}'); + break; + case StepStatus.running: + logger.info(' โณ ${step.description}'); + break; + case StepStatus.done: + logger.info(' โœ… ${step.description}'); + for (final file in step.files.entries) { + logger.detail('Writing ${file.value.length} bytes to $file'); + File(file.key) + ..createSync(recursive: true) + ..writeAsBytesSync(file.value); + } + break; + case StepStatus.failed: + logger.info(' โŒ ${step.description}'); + break; + } + } + + logger.info(''); + if (watch) { + logger.info(''' + ${styleDim.wrap('Press')} r ${styleDim.wrap('to restart the test.')} + ${styleDim.wrap('Press')} q ${styleDim.wrap('to quit.')}'''); + } + } + + @override + void done() {} +} From b775440a142f92dafdad4249e3c865842c253d0f Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 23:40:56 +0100 Subject: [PATCH 11/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2757acb0..73a8d126 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -20,8 +20,8 @@ jobs: - name: ๐Ÿ“š Git Checkout uses: actions/checkout@v3 - - name: ๐Ÿ“ฆ Finding a package to publish - id: package + - name: ๐Ÿ•ต๏ธ Finding User Flows + id: flows run: | flows="[" for flow in ./flows/*.yaml; do From ae48f190ec76dfdf6c03d7e6588b259b8df3b69d Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 23:44:53 +0100 Subject: [PATCH 12/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 73a8d126..0a9edcb6 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -41,7 +41,7 @@ jobs: strategy: matrix: - package: ${{ fromJSON(needs.flows.outputs.flows) }} + flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true runs-on: macos-latest @@ -65,7 +65,7 @@ jobs: model: 'iPhone 11' - name: ๐Ÿงช Testing - run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.test_file }}.yaml + run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml # macos: # needs: flows From 3c90b4bf192ce74d00f1aaaad2ae638e1a681267 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Mon, 27 Feb 2023 23:59:26 +0100 Subject: [PATCH 13/43] ci: add e2e tests for user flows --- packages/fluttium_cli/lib/src/commands/test_command.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fluttium_cli/lib/src/commands/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command.dart index 8fa0eb51..091a6178 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command.dart @@ -332,11 +332,11 @@ class SimplePrinter extends Printer { @override void print(List steps, UserFlowYaml userFlow, bool watch) { - final currentStep = steps.firstWhere( - (step) => - step.status == StepStatus.running || step.status == StepStatus.failed, + final currentStep = steps.lastWhere( + (step) => step.status != StepStatus.initial, orElse: () => steps.first, ); + if (steps.every((e) => e.status == StepStatus.done)) return; _progress ??= logger.progress(''); final index = steps.indexOf(currentStep) + 1; From e0cf65840f002d7927e38ed3547ca3ee485c577b Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 17:38:20 +0100 Subject: [PATCH 14/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 0a9edcb6..5a1e31e7 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -46,6 +46,8 @@ jobs: runs-on: macos-latest + timeout-minutes: 30 + steps: - name: ๐Ÿ“š Git Checkout uses: actions/checkout@v3 @@ -77,6 +79,8 @@ jobs: # runs-on: macos-latest + # timeout-minutes: 30 + # steps: # - name: ๐Ÿ“š Git Checkout # uses: actions/checkout@v3 @@ -105,16 +109,11 @@ jobs: # - name: ๐Ÿ“š Git Checkout # uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Flutter - # uses: subosito/flutter-action@v2 - # with: - # channel: stable - # cache: true + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # dart pub global activate --source path ../packages/fluttium_cli + # run: flutter pub get # - name: ๐Ÿงช Testing # uses: reactivecircus/android-emulator-runner@v2 @@ -123,3 +122,31 @@ jobs: # arch: x86_64 # profile: Nexus 6 # script: fluttium test ${{ matrix.test_file }} + + linux: + needs: flows + + strategy: + matrix: + package: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true + + runs-on: ubuntu-latest + + timeout-minutes: 30 + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment + + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + sudo apt-get update -y + sudo apt-get install -y ninja-build libgtk-3-dev + + - name: ๐Ÿงช Testing + run: fluttium test -d linux flows/${{ matrix.test_file }}.yaml From b52e36502d21eddbe02e79cbbca8472eb28b4b18 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 17:50:51 +0100 Subject: [PATCH 15/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 5a1e31e7..3d25b759 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -74,7 +74,7 @@ jobs: # strategy: # matrix: - # package: ${{ fromJSON(needs.flows.outputs.flows) }} + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} # fail-fast: true # runs-on: macos-latest @@ -97,10 +97,11 @@ jobs: # run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml # android: + # needs: flows + # strategy: # matrix: - # test_file: - # - flows/text_flow.yaml + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} # fail-fast: true # runs-on: macos-latest @@ -121,14 +122,14 @@ jobs: # api-level: 29 # arch: x86_64 # profile: Nexus 6 - # script: fluttium test ${{ matrix.test_file }} + # script: fluttium test ${{ matrix.flow }} linux: needs: flows strategy: matrix: - package: ${{ fromJSON(needs.flows.outputs.flows) }} + flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true runs-on: ubuntu-latest From b2758c6c72eb4bf9fa7fd44e350c1c66b075d3d7 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 17:54:45 +0100 Subject: [PATCH 16/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 3d25b759..18bbf06a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -150,4 +150,4 @@ jobs: sudo apt-get install -y ninja-build libgtk-3-dev - name: ๐Ÿงช Testing - run: fluttium test -d linux flows/${{ matrix.test_file }}.yaml + run: fluttium test -d linux flows/${{ matrix.flow }}.yaml From c37fc75ae3c198a0fa1657a314f265117fbac826 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 17:58:40 +0100 Subject: [PATCH 17/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 18bbf06a..22545e45 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -147,7 +147,7 @@ jobs: run: | flutter pub get sudo apt-get update -y - sudo apt-get install -y ninja-build libgtk-3-dev + sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - name: ๐Ÿงช Testing run: fluttium test -d linux flows/${{ matrix.flow }}.yaml From e96113c1536cfd9e3eb877d3bac7b1b2e992eb16 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 21:22:44 +0100 Subject: [PATCH 18/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 95 ++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 22545e45..a91bb613 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -69,33 +69,6 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml - # macos: - # needs: flows - - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true - - # runs-on: macos-latest - - # timeout-minutes: 30 - - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 - - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment - - # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # cd macos && pod install && cd .. - - # - name: ๐Ÿงช Testing - # run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml - # android: # needs: flows @@ -122,9 +95,9 @@ jobs: # api-level: 29 # arch: x86_64 # profile: Nexus 6 - # script: fluttium test ${{ matrix.flow }} + # script: fluttium test -d ??? flows/${{ matrix.test_file }}.yaml - linux: + web: needs: flows strategy: @@ -132,7 +105,7 @@ jobs: flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true - runs-on: ubuntu-latest + runs-on: macos-latest timeout-minutes: 30 @@ -144,10 +117,62 @@ jobs: uses: ./.github/actions/local_fluttium_environment - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - sudo apt-get update -y - sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + run: flutter pub get - name: ๐Ÿงช Testing - run: fluttium test -d linux flows/${{ matrix.flow }}.yaml + run: fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.test_file }}.yaml + + # macos: + # needs: flows + + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true + + # runs-on: macos-latest + + # timeout-minutes: 30 + + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 + + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment + + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # cd macos && pod install && cd .. + + # - name: ๐Ÿงช Testing + # run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml + + # linux: + # needs: flows + + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true + + # runs-on: ubuntu-latest + + # timeout-minutes: 30 + + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 + + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment + + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # sudo apt-get update -y + # sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + + # - name: ๐Ÿงช Testing + # run: fluttium test -d linux flows/${{ matrix.flow }}.yaml From 06dda58a326fe9fae51ad5566caabbab484af3d3 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 21:58:59 +0100 Subject: [PATCH 19/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a91bb613..fc33bf57 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -95,7 +95,7 @@ jobs: # api-level: 29 # arch: x86_64 # profile: Nexus 6 - # script: fluttium test -d ??? flows/${{ matrix.test_file }}.yaml + # script: fluttium test -d ??? flows/${{ matrix.flow }}.yaml web: needs: flows @@ -120,7 +120,7 @@ jobs: run: flutter pub get - name: ๐Ÿงช Testing - run: fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.test_file }}.yaml + run: fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml # macos: # needs: flows @@ -147,7 +147,7 @@ jobs: # cd macos && pod install && cd .. # - name: ๐Ÿงช Testing - # run: fluttium test -d macos flows/${{ matrix.test_file }}.yaml + # run: fluttium test -d macos flows/${{ matrix.flow }}.yaml # linux: # needs: flows From b733e5a9769de282374d494366a131c9846c9f58 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 22:22:49 +0100 Subject: [PATCH 20/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index fc33bf57..957a3679 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -105,7 +105,7 @@ jobs: flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true - runs-on: macos-latest + runs-on: ubuntu-latest timeout-minutes: 30 From e0cdc0a65f52854a72a171bec47dbee70890c8a8 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 23:04:56 +0100 Subject: [PATCH 21/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 67 ++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 957a3679..9dc073f5 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -105,7 +105,7 @@ jobs: flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true - runs-on: ubuntu-latest + runs-on: macos-latest timeout-minutes: 30 @@ -149,30 +149,55 @@ jobs: # - name: ๐Ÿงช Testing # run: fluttium test -d macos flows/${{ matrix.flow }}.yaml - # linux: - # needs: flows + linux: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: ubuntu-latest + runs-on: ubuntu-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # sudo apt-get update -y - # sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + sudo apt-get update -y + sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - # - name: ๐Ÿงช Testing - # run: fluttium test -d linux flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml + + windows: + needs: flows + + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true + + runs-on: windows-latest + + timeout-minutes: 30 + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment + + - name: ๐Ÿ“ฆ Installing packages + run: flutter pub get + + - name: ๐Ÿงช Testing + run: fluttium test -d windows flows/${{ matrix.flow }}.yaml From 70926bf9a68323bd89861db1bbb2f90255e81728 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Tue, 28 Feb 2023 23:25:26 +0100 Subject: [PATCH 22/43] ci: add e2e tests for user flows --- .github/actions/local_fluttium_environment/action.yaml | 3 +++ .github/workflows/e2e.yaml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index 2feebc8b..a003728e 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -7,6 +7,9 @@ runs: with: channel: stable cache: true + + - shell: bash + run: export PATH="$PATH":"$HOME/.pub-cache/bin" - shell: bash run: tools/setup_local_development.sh diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 9dc073f5..75a3dd66 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -105,7 +105,7 @@ jobs: flow: ${{ fromJSON(needs.flows.outputs.flows) }} fail-fast: true - runs-on: macos-latest + runs-on: ubuntu-latest timeout-minutes: 30 @@ -120,7 +120,7 @@ jobs: run: flutter pub get - name: ๐Ÿงช Testing - run: fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml + run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml # macos: # needs: flows From f56a7f388cf96ae5da19d080c3e35e7bb1751aea Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 00:10:52 +0100 Subject: [PATCH 23/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 66 +++++++++++++------ .../lib/src/commands/test_command.dart | 4 ++ tools/setup_local_development.sh | 1 - 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 75a3dd66..65318678 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -69,33 +69,57 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml - # android: - # needs: flows + android: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: macos-latest + runs-on: macos-latest - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "11" - # - name: ๐Ÿ“ฆ Installing packages - # run: flutter pub get + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿงช Testing - # uses: reactivecircus/android-emulator-runner@v2 - # with: - # api-level: 29 - # arch: x86_64 - # profile: Nexus 6 - # script: fluttium test -d ??? flows/${{ matrix.flow }}.yaml + - name: ๐Ÿ“ฆ Installing packages + run: flutter pub get + + - name: AVD Cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-29 + + - name: Cache AVD Snapshot + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + avd-name: android + script: echo "Generated AVD snapshot for caching." + + - name: ๐Ÿงช Testing + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + avd-name: android + script: fluttium test -d android flows/${{ matrix.flow }}.yaml web: needs: flows diff --git a/packages/fluttium_cli/lib/src/commands/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command.dart index 091a6178..ee75adc1 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command.dart @@ -330,6 +330,8 @@ class SimplePrinter extends Printer { Progress? _progress; + bool failed = false; + @override void print(List steps, UserFlowYaml userFlow, bool watch) { final currentStep = steps.lastWhere( @@ -343,12 +345,14 @@ class SimplePrinter extends Printer { _progress?.update('$index/${steps.length} ${currentStep.description}'); if (currentStep.status == StepStatus.failed) { + failed = true; _progress?.fail(); } } @override void done() { + if (failed) return; _progress?.complete(); } } diff --git a/tools/setup_local_development.sh b/tools/setup_local_development.sh index dc586e8f..84bab012 100755 --- a/tools/setup_local_development.sh +++ b/tools/setup_local_development.sh @@ -12,4 +12,3 @@ localSetup="dependency_overrides: echo "$localSetup" > example/pubspec_overrides.yaml echo "$localSetup" > bricks/fluttium_test_runner/__brick__/pubspec_overrides.yaml -echo "$localSetup" > actions/log_action/pubspec_overrides.yaml \ No newline at end of file From d73b34539c600c5dd012810fcfdcd446c296da0e Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 00:24:19 +0100 Subject: [PATCH 24/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 65318678..03d5317d 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -119,6 +119,7 @@ jobs: with: api-level: 29 avd-name: android + working-directory: example script: fluttium test -d android flows/${{ matrix.flow }}.yaml web: From e7e0e7be9c69228497431efef3d0a96aac4bad62 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 01:11:46 +0100 Subject: [PATCH 25/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 03d5317d..0152e059 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -120,7 +120,7 @@ jobs: api-level: 29 avd-name: android working-directory: example - script: fluttium test -d android flows/${{ matrix.flow }}.yaml + script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml web: needs: flows From b76b5ddd3f993aedfa7071633c007586b96e501d Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 17:27:03 +0100 Subject: [PATCH 26/43] ci: add e2e tests for user flows --- .../local_fluttium_environment/action.yaml | 2 +- CONTRIBUTING.md | 2 +- tools/setup_local_development.sh | 14 -------------- tools/setup_local_environment.dart | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 16 deletions(-) delete mode 100755 tools/setup_local_development.sh create mode 100644 tools/setup_local_environment.dart diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index a003728e..91397de5 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -12,7 +12,7 @@ runs: run: export PATH="$PATH":"$HOME/.pub-cache/bin" - shell: bash - run: tools/setup_local_development.sh + run: dart tools/setup_local_environment.dart - shell: bash run: dart pub global activate mason_cli diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3718654..28b10edb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,7 @@ Fluttium requires a bit of setup to develop locally, thankfully we have simple s does all the heavy lifting for you: ```shell -sh ./tools/setup_local_development.sh +dart ./tools/setup_local_environment.dart ``` After that you can install the local version of the CLI to test your changes: diff --git a/tools/setup_local_development.sh b/tools/setup_local_development.sh deleted file mode 100755 index 84bab012..00000000 --- a/tools/setup_local_development.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Setup local development for Fluttium. -# -# This is a one-time setup script. - -localSetup="dependency_overrides: - fluttium: - path: $(pwd)/packages/fluttium - fluttium_protocol: - path: $(pwd)/packages/fluttium_protocol - fluttium_interfaces: - path: $(pwd)/packages/fluttium_interfaces" - -echo "$localSetup" > example/pubspec_overrides.yaml -echo "$localSetup" > bricks/fluttium_test_runner/__brick__/pubspec_overrides.yaml diff --git a/tools/setup_local_environment.dart b/tools/setup_local_environment.dart new file mode 100644 index 00000000..1c0c8e19 --- /dev/null +++ b/tools/setup_local_environment.dart @@ -0,0 +1,17 @@ +import 'dart:io'; + +void main() { + final localSetup = ''' +dependency_overrides: + fluttium: + path: ${Directory.current.uri.resolve('packages/fluttium').path} + fluttium_protocol: + path: ${Directory.current.uri.resolve('packages/fluttium_protocol').path} + fluttium_interfaces: + path: ${Directory.current.uri.resolve('packages/fluttium_interfaces').path} +'''; + + File('example/pubspec_overrides.yaml').writeAsStringSync(localSetup); + File('bricks/fluttium_test_runner/__brick__/pubspec_overrides.yaml') + .writeAsStringSync(localSetup); +} From 73f3823fef28dcdc34d6a606cb9850130b7452b3 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:16:13 +0100 Subject: [PATCH 27/43] ci: add e2e tests for user flows --- .github/actions/local_fluttium_environment/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index 91397de5..611d24ff 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -9,7 +9,7 @@ runs: cache: true - shell: bash - run: export PATH="$PATH":"$HOME/.pub-cache/bin" + run: echo $path - shell: bash run: dart tools/setup_local_environment.dart From 3325d825bdc83572a89796567f59b24b19498ae3 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:16:25 +0100 Subject: [PATCH 28/43] ci: add e2e tests for user flows --- .github/actions/local_fluttium_environment/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index 611d24ff..ae58ce36 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -9,7 +9,7 @@ runs: cache: true - shell: bash - run: echo $path + run: echo $PATH - shell: bash run: dart tools/setup_local_environment.dart From 345543e04037fc64947811b213f5571b6b37060d Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:23:41 +0100 Subject: [PATCH 29/43] ci: add e2e tests for user flows --- .../local_fluttium_environment/action.yaml | 3 - .github/workflows/e2e.yaml | 216 +++++++++--------- 2 files changed, 109 insertions(+), 110 deletions(-) diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index ae58ce36..10ddb00e 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -7,9 +7,6 @@ runs: with: channel: stable cache: true - - - shell: bash - run: echo $PATH - shell: bash run: dart tools/setup_local_environment.dart diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 0152e059..91268d72 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -36,116 +36,116 @@ jobs: echo "flows=$( echo "$flows" )" >> $GITHUB_OUTPUT - ios: - needs: flows - - strategy: - matrix: - flow: ${{ fromJSON(needs.flows.outputs.flows) }} - fail-fast: true + # ios: + # needs: flows - runs-on: macos-latest + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - timeout-minutes: 30 + # runs-on: macos-latest - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # timeout-minutes: 30 - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - cd ios && pod install && cd .. + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: ๐Ÿ”ง Setting Up Simulator - id: simulator - uses: futureware-tech/simulator-action@v2 - with: - model: 'iPhone 11' + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # cd ios && pod install && cd .. - - name: ๐Ÿงช Testing - run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml + # - name: ๐Ÿ”ง Setting Up Simulator + # id: simulator + # uses: futureware-tech/simulator-action@v2 + # with: + # model: 'iPhone 11' - android: - needs: flows + # - name: ๐Ÿงช Testing + # run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml - strategy: - matrix: - flow: ${{ fromJSON(needs.flows.outputs.flows) }} - fail-fast: true + # android: + # needs: flows - runs-on: macos-latest + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # runs-on: macos-latest - - uses: actions/setup-java@v3 - with: - distribution: "temurin" - java-version: "11" + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # - uses: actions/setup-java@v3 + # with: + # distribution: "temurin" + # java-version: "11" - - name: ๐Ÿ“ฆ Installing packages - run: flutter pub get + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: AVD Cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29 - - - name: Cache AVD Snapshot - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - avd-name: android - script: echo "Generated AVD snapshot for caching." + # - name: ๐Ÿ“ฆ Installing packages + # run: flutter pub get + + # - name: AVD Cache + # uses: actions/cache@v3 + # id: avd-cache + # with: + # path: | + # ~/.android/avd/* + # ~/.android/adb* + # key: avd-29 + + # - name: Cache AVD Snapshot + # if: steps.avd-cache.outputs.cache-hit != 'true' + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # api-level: 29 + # force-avd-creation: false + # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + # disable-animations: false + # avd-name: android + # script: echo "Generated AVD snapshot for caching." - - name: ๐Ÿงช Testing - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - avd-name: android - working-directory: example - script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml - - web: - needs: flows + # - name: ๐Ÿงช Testing + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # api-level: 29 + # avd-name: android + # working-directory: example + # script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml + + # web: + # needs: flows - strategy: - matrix: - flow: ${{ fromJSON(needs.flows.outputs.flows) }} - fail-fast: true + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - runs-on: ubuntu-latest + # runs-on: ubuntu-latest - timeout-minutes: 30 + # timeout-minutes: 30 - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: ๐Ÿ“ฆ Installing packages - run: flutter pub get + # - name: ๐Ÿ“ฆ Installing packages + # run: flutter pub get - - name: ๐Ÿงช Testing - run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml + # - name: ๐Ÿงช Testing + # run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml # macos: # needs: flows @@ -174,33 +174,33 @@ jobs: # - name: ๐Ÿงช Testing # run: fluttium test -d macos flows/${{ matrix.flow }}.yaml - linux: - needs: flows + # linux: + # needs: flows - strategy: - matrix: - flow: ${{ fromJSON(needs.flows.outputs.flows) }} - fail-fast: true + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - runs-on: ubuntu-latest + # runs-on: ubuntu-latest - timeout-minutes: 30 + # timeout-minutes: 30 - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: ๐Ÿ“ฆ Installing packages - run: | - flutter pub get - sudo apt-get update -y - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + # - name: ๐Ÿ“ฆ Installing packages + # run: | + # flutter pub get + # sudo apt-get update -y + # sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - - name: ๐Ÿงช Testing - run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml + # - name: ๐Ÿงช Testing + # run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml windows: needs: flows @@ -221,6 +221,8 @@ jobs: - name: ๐Ÿฆ Setup Local Fluttium Environment uses: ./.github/actions/local_fluttium_environment + - run: /c/Users/runneradmin/AppData/Local/Pub/Cache/bin/mason.bat --help + - name: ๐Ÿ“ฆ Installing packages run: flutter pub get From f03f1bf0d74fa81db34184643aa55b066ac04b13 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:32:01 +0100 Subject: [PATCH 30/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 91268d72..f07bbdac 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -221,7 +221,7 @@ jobs: - name: ๐Ÿฆ Setup Local Fluttium Environment uses: ./.github/actions/local_fluttium_environment - - run: /c/Users/runneradmin/AppData/Local/Pub/Cache/bin/mason.bat --help + - run: mason.bat --help - name: ๐Ÿ“ฆ Installing packages run: flutter pub get From 9bdc7647578ebdf95f1f9a999baf29062df97fec Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:40:54 +0100 Subject: [PATCH 31/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f07bbdac..63d1e01b 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -221,8 +221,6 @@ jobs: - name: ๐Ÿฆ Setup Local Fluttium Environment uses: ./.github/actions/local_fluttium_environment - - run: mason.bat --help - - name: ๐Ÿ“ฆ Installing packages run: flutter pub get From d013c783c6f4c2e33784ca83ac470920c95063f2 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:41:18 +0100 Subject: [PATCH 32/43] ci: add e2e tests for user flows --- tools/bundle_all_bricks.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/bundle_all_bricks.sh b/tools/bundle_all_bricks.sh index bf30124d..4b89c21d 100755 --- a/tools/bundle_all_bricks.sh +++ b/tools/bundle_all_bricks.sh @@ -1,11 +1,16 @@ # Bundle all bricks for the packages. +correctMason=mason +if [[ "$OSTYPE" == "msys" ]]; then + correctMason=mason.bat +fi + # Bundle all cli bricks. -mason bundle -t dart bricks/fluttium_action -o packages/fluttium_cli/lib/src/bundles/ -mason bundle -t dart bricks/fluttium_flow -o packages/fluttium_cli/lib/src/bundles/ +$correctMason bundle -t dart bricks/fluttium_action -o packages/fluttium_cli/lib/src/bundles/ +$correctMason bundle -t dart bricks/fluttium_flow -o packages/fluttium_cli/lib/src/bundles/ dart format --fix packages/fluttium_cli # Bundle all driver bricks. -mason bundle -t dart bricks/fluttium_launcher -o packages/fluttium_driver/lib/src/bundles/ -mason bundle -t dart bricks/fluttium_test_runner -o packages/fluttium_driver/lib/src/bundles/ +$correctMason bundle -t dart bricks/fluttium_launcher -o packages/fluttium_driver/lib/src/bundles/ +$correctMason bundle -t dart bricks/fluttium_test_runner -o packages/fluttium_driver/lib/src/bundles/ dart format --fix packages/fluttium_driver \ No newline at end of file From 5c910bb63d959f17d9d1b0fe7dac4e171dca205f Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 20:54:33 +0100 Subject: [PATCH 33/43] ci: add e2e tests for user flows --- .github/actions/local_fluttium_environment/action.yaml | 4 ++++ CONTRIBUTING.md | 3 ++- tools/pubspec.yaml | 7 +++++++ tools/setup_local_environment.dart | 7 ++++--- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tools/pubspec.yaml diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml index 10ddb00e..2df85c96 100644 --- a/.github/actions/local_fluttium_environment/action.yaml +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -7,6 +7,10 @@ runs: with: channel: stable cache: true + + - shell: bash + working-directory: tools + run: dart pub get - shell: bash run: dart tools/setup_local_environment.dart diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28b10edb..583fe461 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,8 @@ Fluttium requires a bit of setup to develop locally, thankfully we have simple s does all the heavy lifting for you: ```shell -dart ./tools/setup_local_environment.dart +cd tools && dart pub get && cd .. +dart tools/setup_local_environment.dart ``` After that you can install the local version of the CLI to test your changes: diff --git a/tools/pubspec.yaml b/tools/pubspec.yaml new file mode 100644 index 00000000..6f499d5c --- /dev/null +++ b/tools/pubspec.yaml @@ -0,0 +1,7 @@ +name: tools +publish_to: none + +environment: + sdk: ">=2.19.0 <3.0.0" +dependencies: + path: ^1.8.3 diff --git a/tools/setup_local_environment.dart b/tools/setup_local_environment.dart index 1c0c8e19..513b294c 100644 --- a/tools/setup_local_environment.dart +++ b/tools/setup_local_environment.dart @@ -1,14 +1,15 @@ import 'dart:io'; +import 'package:path/path.dart' as path; void main() { final localSetup = ''' dependency_overrides: fluttium: - path: ${Directory.current.uri.resolve('packages/fluttium').path} + path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium').path)} fluttium_protocol: - path: ${Directory.current.uri.resolve('packages/fluttium_protocol').path} + path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium_protocol').path)} fluttium_interfaces: - path: ${Directory.current.uri.resolve('packages/fluttium_interfaces').path} + path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium_interfaces').path)} '''; File('example/pubspec_overrides.yaml').writeAsStringSync(localSetup); From 67255649daf995c327d5195c185cb57d07884d90 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 21:07:24 +0100 Subject: [PATCH 34/43] ci: add e2e tests for user flows --- tools/setup_local_environment.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/setup_local_environment.dart b/tools/setup_local_environment.dart index 513b294c..94d39482 100644 --- a/tools/setup_local_environment.dart +++ b/tools/setup_local_environment.dart @@ -5,11 +5,11 @@ void main() { final localSetup = ''' dependency_overrides: fluttium: - path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium').path)} + path: ${path.canonicalize(path.join(Directory.current.path, 'packages/fluttium'))} fluttium_protocol: - path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium_protocol').path)} + path: ${path.canonicalize(path.join(Directory.current.path, 'packages/fluttium_protocol'))} fluttium_interfaces: - path: ${path.canonicalize(Directory.current.uri.resolve('packages/fluttium_interfaces').path)} + path: ${path.canonicalize(path.join(Directory.current.path, 'packages/fluttium_interfaces'))} '''; File('example/pubspec_overrides.yaml').writeAsStringSync(localSetup); From f6bc837d250312d03b47dcd7c430cfb35351d79e Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 21:32:29 +0100 Subject: [PATCH 35/43] ci: add e2e tests for user flows --- packages/fluttium_driver/lib/src/fluttium_driver.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/fluttium_driver/lib/src/fluttium_driver.dart b/packages/fluttium_driver/lib/src/fluttium_driver.dart index fb318256..570dc633 100644 --- a/packages/fluttium_driver/lib/src/fluttium_driver.dart +++ b/packages/fluttium_driver/lib/src/fluttium_driver.dart @@ -6,7 +6,7 @@ import 'package:fluttium_driver/fluttium_driver.dart'; import 'package:fluttium_driver/src/bundles/bundles.dart'; import 'package:fluttium_interfaces/fluttium_interfaces.dart'; import 'package:fluttium_protocol/fluttium_protocol.dart'; -import 'package:mason/mason.dart'; +import 'package:mason/mason.dart' hide canonicalize; import 'package:meta/meta.dart'; import 'package:path/path.dart'; import 'package:process/process.dart'; @@ -446,6 +446,6 @@ extension on ActionLocation { // Else it is a path location return ''' - path: ${relativeDirectory.absolute.uri.resolve(path!).replace(scheme: '')}'''; + path: ${canonicalize(join(relativeDirectory.absolute.path, path))}'''; } } From 73131b14ed67967a488dc9a94eaefa8b8293c156 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 21:44:43 +0100 Subject: [PATCH 36/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 63d1e01b..304ea030 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -147,32 +147,32 @@ jobs: # - name: ๐Ÿงช Testing # run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml - # macos: - # needs: flows + macos: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: macos-latest + runs-on: macos-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # cd macos && pod install && cd .. + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + cd macos && pod install && cd .. - # - name: ๐Ÿงช Testing - # run: fluttium test -d macos flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: fluttium test -d macos flows/${{ matrix.flow }}.yaml # linux: # needs: flows @@ -202,27 +202,27 @@ jobs: # - name: ๐Ÿงช Testing # run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml - windows: - needs: flows + # windows: + # needs: flows - strategy: - matrix: - flow: ${{ fromJSON(needs.flows.outputs.flows) }} - fail-fast: true + # strategy: + # matrix: + # flow: ${{ fromJSON(needs.flows.outputs.flows) }} + # fail-fast: true - runs-on: windows-latest + # runs-on: windows-latest - timeout-minutes: 30 + # timeout-minutes: 30 - steps: - - name: ๐Ÿ“š Git Checkout - uses: actions/checkout@v3 + # steps: + # - name: ๐Ÿ“š Git Checkout + # uses: actions/checkout@v3 - - name: ๐Ÿฆ Setup Local Fluttium Environment - uses: ./.github/actions/local_fluttium_environment + # - name: ๐Ÿฆ Setup Local Fluttium Environment + # uses: ./.github/actions/local_fluttium_environment - - name: ๐Ÿ“ฆ Installing packages - run: flutter pub get + # - name: ๐Ÿ“ฆ Installing packages + # run: flutter pub get - - name: ๐Ÿงช Testing - run: fluttium test -d windows flows/${{ matrix.flow }}.yaml + # - name: ๐Ÿงช Testing + # run: fluttium test -d windows flows/${{ matrix.flow }}.yaml From 1dfab0828a9857b8107c5f574008d02278740c48 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 21:54:07 +0100 Subject: [PATCH 37/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 304ea030..69524a53 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -172,7 +172,7 @@ jobs: cd macos && pod install && cd .. - name: ๐Ÿงช Testing - run: fluttium test -d macos flows/${{ matrix.flow }}.yaml + run: fluttium test -d macos flows/${{ matrix.flow }}.yaml --verbose # linux: # needs: flows From 9b0d5342dc924a4b0da3c3e62d7d0ded62d36e28 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 22:11:22 +0100 Subject: [PATCH 38/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 93 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 69524a53..afb680d2 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -69,58 +69,58 @@ jobs: # - name: ๐Ÿงช Testing # run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml - # android: - # needs: flows - - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + android: + needs: flows - # runs-on: macos-latest + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + runs-on: macos-latest - # - uses: actions/setup-java@v3 - # with: - # distribution: "temurin" - # java-version: "11" + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "11" - # - name: ๐Ÿ“ฆ Installing packages - # run: flutter pub get + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: AVD Cache - # uses: actions/cache@v3 - # id: avd-cache - # with: - # path: | - # ~/.android/avd/* - # ~/.android/adb* - # key: avd-29 - - # - name: Cache AVD Snapshot - # if: steps.avd-cache.outputs.cache-hit != 'true' - # uses: reactivecircus/android-emulator-runner@v2 - # with: - # api-level: 29 - # force-avd-creation: false - # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - # disable-animations: false - # avd-name: android - # script: echo "Generated AVD snapshot for caching." + - name: ๐Ÿ“ฆ Installing packages + run: flutter pub get + + - name: AVD Cache + uses: actions/cache@v3 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-29 + + - name: Cache AVD Snapshot + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + avd-name: android + script: echo "Generated AVD snapshot for caching." - # - name: ๐Ÿงช Testing - # uses: reactivecircus/android-emulator-runner@v2 - # with: - # api-level: 29 - # avd-name: android - # working-directory: example - # script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + avd-name: android + working-directory: example + script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml # web: # needs: flows @@ -148,6 +148,7 @@ jobs: # run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml macos: + if: false # TODO: Metal is not supported on macos runners, https://github.com/actions/runner-images/discussions/6138 needs: flows strategy: @@ -172,7 +173,7 @@ jobs: cd macos && pod install && cd .. - name: ๐Ÿงช Testing - run: fluttium test -d macos flows/${{ matrix.flow }}.yaml --verbose + run: fluttium test -d macos flows/${{ matrix.flow }}.yaml # linux: # needs: flows From 29e553528caa166b74b6aaf7df4b6e8caa6458a8 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Wed, 1 Mar 2023 22:47:15 +0100 Subject: [PATCH 39/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 166 +++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 81 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index afb680d2..5221f207 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -1,9 +1,11 @@ name: e2e on: - pull_request: - branches: - - main + workflow_run: + workflows: + - ci + types: + - completed defaults: run: @@ -36,40 +38,41 @@ jobs: echo "flows=$( echo "$flows" )" >> $GITHUB_OUTPUT - # ios: - # needs: flows + ios: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: macos-latest + runs-on: macos-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # cd ios && pod install && cd .. + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + cd ios && pod install && cd .. - # - name: ๐Ÿ”ง Setting Up Simulator - # id: simulator - # uses: futureware-tech/simulator-action@v2 - # with: - # model: 'iPhone 11' + - name: ๐Ÿ”ง Setting Up Simulator + id: simulator + uses: futureware-tech/simulator-action@v2 + with: + model: 'iPhone 11' - # - name: ๐Ÿงช Testing - # run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: fluttium test --flavor development --target lib/main_development.dart -d ${{ steps.simulator.outputs.udid }} flows/${{ matrix.flow }}.yaml android: + if: false # TODO: Currently does not work needs: flows strategy: @@ -122,30 +125,30 @@ jobs: working-directory: example script: fluttium test --flavor development --target lib/main_development.dart -d android flows/${{ matrix.flow }}.yaml - # web: - # needs: flows + web: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: ubuntu-latest + runs-on: ubuntu-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: flutter pub get + - name: ๐Ÿ“ฆ Installing packages + run: flutter pub get - # - name: ๐Ÿงช Testing - # run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: xvfb-run fluttium test --flavor development --target lib/main_development.dart -d chrome flows/${{ matrix.flow }}.yaml macos: if: false # TODO: Metal is not supported on macos runners, https://github.com/actions/runner-images/discussions/6138 @@ -175,55 +178,56 @@ jobs: - name: ๐Ÿงช Testing run: fluttium test -d macos flows/${{ matrix.flow }}.yaml - # linux: - # needs: flows + linux: + if: false # TODO: tests currently dont work, but locally they do + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: ubuntu-latest + runs-on: ubuntu-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: | - # flutter pub get - # sudo apt-get update -y - # sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + - name: ๐Ÿ“ฆ Installing packages + run: | + flutter pub get + sudo apt-get update -y + sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - # - name: ๐Ÿงช Testing - # run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: xvfb-run fluttium test -d linux flows/${{ matrix.flow }}.yaml - # windows: - # needs: flows + windows: + needs: flows - # strategy: - # matrix: - # flow: ${{ fromJSON(needs.flows.outputs.flows) }} - # fail-fast: true + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true - # runs-on: windows-latest + runs-on: windows-latest - # timeout-minutes: 30 + timeout-minutes: 30 - # steps: - # - name: ๐Ÿ“š Git Checkout - # uses: actions/checkout@v3 + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 - # - name: ๐Ÿฆ Setup Local Fluttium Environment - # uses: ./.github/actions/local_fluttium_environment + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment - # - name: ๐Ÿ“ฆ Installing packages - # run: flutter pub get + - name: ๐Ÿ“ฆ Installing packages + run: flutter pub get - # - name: ๐Ÿงช Testing - # run: fluttium test -d windows flows/${{ matrix.flow }}.yaml + - name: ๐Ÿงช Testing + run: fluttium test -d windows flows/${{ matrix.flow }}.yaml From fe34080617c168d721606266128cc2a9465a035f Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Fri, 3 Mar 2023 20:10:08 +0100 Subject: [PATCH 40/43] ci: add e2e tests for user flows --- .../commands/test_command/test_command.dart | 334 ++++++++++++++++++ 1 file changed, 334 insertions(+) diff --git a/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart index 8b137891..98fcace2 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart @@ -1 +1,335 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:args/args.dart'; +import 'package:args/command_runner.dart'; +import 'package:collection/collection.dart'; +import 'package:fluttium_cli/src/commands/test_command/reporters/reporters.dart'; +import 'package:fluttium_cli/src/flutter_device.dart'; +import 'package:fluttium_cli/src/json_decode_safely.dart'; +import 'package:fluttium_driver/fluttium_driver.dart'; +import 'package:fluttium_interfaces/fluttium_interfaces.dart'; +import 'package:mason/mason.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart'; +import 'package:process/process.dart'; + +typedef FluttiumDriverCreator = FluttiumDriver Function({ + required DriverConfiguration configuration, + required Map actions, + required Directory projectDirectory, + required File userFlowFile, + Logger? logger, + ProcessManager? processManager, +}); + +/// Whether or not the current terminal supports ANSI escape codes. +/// +/// Otherwise only printable ASCII characters should be used. +bool get canUseSpecialChars => stdout.supportsAnsiEscapes; + +/// Whether or not the stdin has a terminal and if that terminal supports ANSI +/// escape codes. +bool get hasAnsiTerminal => stdin.hasTerminal && canUseSpecialChars; + +final defaultReporter = hasAnsiTerminal + ? 'pretty' + : canUseSpecialChars + ? 'compact' + : 'expanded'; + +/// {@template test_command} +/// `fluttium test` command which runs a [UserFlowYaml] test. +/// {@endtemplate} +class TestCommand extends Command { + /// {@macro test_command} + TestCommand({ + required Logger logger, + ProcessManager? processManager, + FluttiumDriverCreator? driver, + }) : _logger = logger, + _process = processManager ?? const LocalProcessManager(), + _driver = driver ?? FluttiumDriver.new { + argParser + ..addFlag( + 'watch', + abbr: 'w', + help: 'Watch for file changes.', + negatable: false, + ) + ..addOption( + 'device-id', + abbr: 'd', + help: 'Target device id or name (prefixes allowed).', + ) + ..addOption( + 'flavor', + help: ''' +Build a custom app flavor as defined by platform-specific build setup. +This will be passed to the --flavor option of flutter run.''', + ) + ..addOption( + 'target', + abbr: 't', + help: + '''The main entry-point file of the application, as run on the device.''', + defaultsTo: 'lib/main.dart', + ) + ..addMultiOption( + 'dart-define', + valueHelp: 'key=value', + help: ''' +Pass additional key-value pairs to the flutter run. +Multiple defines can be passed by repeating "--dart-define" multiple times.''', + ) + ..addOption( + 'reporter', + abbr: 'r', + defaultsTo: defaultReporter, + allowed: [ + 'expanded', + 'pretty', + 'compact', + ], + allowedHelp: { + 'expanded': 'A separate line for each update.', + 'compact': 'A single line that updates dynamically.', + 'pretty': 'A nicely formatted output that works nicely with --watch.', + }, + ); + } + + @override + String get description => 'Run a user flow test.'; + + @override + String get name => 'test'; + + @override + String get invocation => 'fluttium test [arguments]'; + + final Logger _logger; + + final ProcessManager _process; + + final FluttiumDriverCreator _driver; + + /// [ArgResults] used for testing purposes only. + @visibleForTesting + ArgResults? testArgResults; + + /// [ArgResults] for the current command. + ArgResults get results => testArgResults ?? argResults!; + + /// Indicates whether the `--watch` flag was passed. + bool get watch => results['watch'] as bool; + + String? get _flavor => results['flavor'] as String?; + + List get _dartDefines => results['dart-define'] as List; + + /// The file of the flow to run. + File get _userFlowFile { + if (results.rest.isEmpty || results.rest.first.isEmpty) { + usageException('No flow file specified.'); + } + return File(results.rest.first); + } + + Reporter _getReporter(FluttiumDriver driver) { + switch (results['reporter']) { + case 'pretty': + return PrettyReporter(driver, logger: _logger, watch: watch); + case 'compact': + return CompactReporter(driver, logger: _logger, watch: watch); + case 'expanded': + return ExpandedReporter(driver, logger: _logger, watch: watch); + default: + throw UnsupportedError('Unknown reporter: ${results['reporter']}'); + } + } + + /// The project directory to run in. + Directory? _getProjectDirectory(File file) { + var projectDir = file.parent.absolute; + while (projectDir.listSync().firstWhereOrNull( + (file) => basename(file.path) == 'pubspec.yaml', + ) == + null) { + if (projectDir.parent == projectDir) { + return null; + } + projectDir = projectDir.parent; + } + return projectDir; + } + + /// The target file to run. + File _getTarget(Directory directory) { + final target = results['target'] as String; + return File(join(directory.path, target)); + } + + Future getDevice( + String workingDirectory, + FluttiumYaml fluttium, + ) async { + final retrievingDevices = _logger.progress('Retrieving devices'); + final devices = await _getDevices(workingDirectory); + if (devices.isEmpty) { + retrievingDevices.fail(); + return null; + } + + FlutterDevice? device; + if (devices.length == 1) { + device = devices.first; + retrievingDevices.complete(); + } else { + retrievingDevices.cancel(); + } + + return device ?? + _logger.chooseOne( + 'Choose a device:', + choices: devices, + display: (device) => '${device.name} (${device.id})', + ); + } + + Future> _getDevices(String workingDirectory) async { + final result = await _process.run( + ['flutter', '--no-version-check', 'devices', '--machine'], + runInShell: true, + workingDirectory: workingDirectory, + ); + final devices = (jsonDecodeSafely(result.stdout as String) as List) + .cast>() + .map(FlutterDevice.new) + .toList(); + + return devices.where((device) { + if (!device.isSupported) return false; + + if (device.targetPlatform.startsWith('web')) { + return Directory(join(workingDirectory, 'web')).existsSync(); + } else if (device.targetPlatform.startsWith('darwin')) { + return Directory(join(workingDirectory, 'macos')).existsSync(); + } else if (device.targetPlatform.startsWith('linux')) { + return Directory(join(workingDirectory, 'linux')).existsSync(); + } else if (device.targetPlatform.startsWith('windows')) { + return Directory(join(workingDirectory, 'windows')).existsSync(); + } else if (device.targetPlatform.startsWith('ios')) { + return Directory(join(workingDirectory, 'ios')).existsSync(); + } else if (device.targetPlatform.startsWith('android')) { + return Directory(join(workingDirectory, 'android')).existsSync(); + } + return false; + }).toList(); + } + + @override + Future run() async { + final userFlowFile = _userFlowFile; + if (!userFlowFile.existsSync()) { + _logger.err('Flow file "${userFlowFile.path}" not found.'); + return ExitCode.unavailable.code; + } + + final projectDirectory = _getProjectDirectory(userFlowFile); + if (projectDirectory == null) { + _logger.err('Could not find pubspec.yaml in parent directories.'); + return ExitCode.unavailable.code; + } + + final target = _getTarget(projectDirectory); + if (!target.existsSync()) { + _logger.err('Target file "${results['target']}" not found.'); + return ExitCode.unavailable.code; + } + + // Setup a fluttium config file, if there is no fluttium.yaml we set up a + // basic one. + FluttiumYaml fluttium; + final fluttiumFile = File(join(projectDirectory.path, 'fluttium.yaml')); + if (fluttiumFile.existsSync()) { + fluttium = FluttiumYaml.fromData(fluttiumFile.readAsStringSync()); + } else { + fluttium = FluttiumYaml( + environment: FluttiumEnvironment( + fluttium: FluttiumDriver.fluttiumVersionConstraint, + ), + ); + } + + if (!fluttium.environment.fluttium + .allowsAny(FluttiumDriver.fluttiumVersionConstraint)) { + _logger.err( + ''' +Version solving failed: + The Fluttium CLI uses "${FluttiumDriver.fluttiumVersionConstraint}" as the version constraint. + The current project uses "${fluttium.environment.fluttium}" as defined in the fluttium.yaml. +Either adjust the constraint in the Fluttium configuration or update the CLI to a compatible version.''', + ); + return ExitCode.unavailable.code; + } + + // Setup the driver config for Fluttium. + fluttium = fluttium.copyWith( + driver: fluttium.driver.copyWith( + target: results.wasParsed('target') ? target.path : null, + flavor: _flavor, + dartDefines: [...fluttium.driver.dartDefines, ..._dartDefines], + deviceId: results['device-id'] as String?, + ), + ); + + // Retrieve the device to run on. + if (fluttium.driver.deviceId == null) { + final device = await getDevice(projectDirectory.path, fluttium); + fluttium = fluttium.copyWith( + driver: fluttium.driver.copyWith(deviceId: device?.id), + ); + } + + if (fluttium.driver.deviceId == null) { + _logger.err('No devices found.'); + return ExitCode.unavailable.code; + } + + final driver = _driver( + configuration: fluttium.driver, + actions: fluttium.actions, + projectDirectory: projectDirectory, + userFlowFile: userFlowFile, + logger: _logger, + processManager: _process, + ); + + final Reporter reporter; + try { + reporter = _getReporter(driver); + } catch (err) { + if (err is UnsupportedError) { + _logger.err(err.message); + return ExitCode.usage.code; + } + rethrow; + } + + final steps = []; + driver.steps.map((s) => (steps..clear())..addAll(s)).listen( + reporter.report, + onDone: reporter.done, + onError: reporter.error, + ); + + await driver.run(watch: watch); + + if (!steps.every((s) => s.status == StepStatus.done) || steps.isEmpty) { + return ExitCode.tempFail.code; + } + + return ExitCode.success.code; + } +} From 60cfbc82307e449a95fa319d1ddef9af57ea6ad5 Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Fri, 3 Mar 2023 20:10:44 +0100 Subject: [PATCH 41/43] ci: add e2e tests for user flows --- .../fluttium_cli/lib/src/commands/test_command/test_command.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart b/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart index 98fcace2..8a45732f 100644 --- a/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart +++ b/packages/fluttium_cli/lib/src/commands/test_command/test_command.dart @@ -269,6 +269,7 @@ Multiple defines can be passed by repeating "--dart-define" multiple times.''', Version solving failed: The Fluttium CLI uses "${FluttiumDriver.fluttiumVersionConstraint}" as the version constraint. The current project uses "${fluttium.environment.fluttium}" as defined in the fluttium.yaml. + Either adjust the constraint in the Fluttium configuration or update the CLI to a compatible version.''', ); return ExitCode.unavailable.code; From 7a63696c9e321fc5e641843bdb866e4aabe01fac Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Sat, 13 May 2023 15:56:33 +0200 Subject: [PATCH 42/43] ci: add e2e tests for user flows --- .github/workflows/e2e.yaml | 6 +----- .github/workflows/main.yaml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 5221f207..a2c890a8 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -1,11 +1,7 @@ name: e2e on: - workflow_run: - workflows: - - ci - types: - - completed + workflow_call: defaults: run: diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0e4d88c7..705e5bde 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -252,6 +252,23 @@ jobs: with: working_directory: actions/${{ matrix.brick }} + e2e: + needs: + [ + semantic_pull_request, + spell_check, + docs, + example, + pana_packages, + pana_actions, + build_packages, + build_bricks, + build_actions, + ] + + if: ${{ contains(join(needs.*.result, ','), 'failure') == 'false' }} + uses: ./.github/workflows/e2e.yaml + # Simply exists to be the final job in the workflow. This is required to # ensure that the workflow fails if any of the needed jobs fail. # From 415ad8b6085879f0397dc72100ce13e7e3e2504a Mon Sep 17 00:00:00 2001 From: Jochum van der Ploeg Date: Sat, 13 May 2023 15:58:21 +0200 Subject: [PATCH 43/43] ci: add e2e tests for user flows --- .github/workflows/main.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 705e5bde..acae26c1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -277,15 +277,7 @@ jobs: ci: needs: [ - semantic_pull_request, - spell_check, - docs, - example, - pana_packages, - pana_actions, - build_packages, - build_bricks, - build_actions, + e2e ] if: ${{ always() }}