From 4ccc2c16e31f695878c7caa614e6a3a85025d696 Mon Sep 17 00:00:00 2001 From: armantorkzaban Date: Fri, 7 Oct 2022 11:06:45 +0200 Subject: [PATCH 1/2] flutter driver --- workflows/flutter/flutter-driver.yml | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 workflows/flutter/flutter-driver.yml diff --git a/workflows/flutter/flutter-driver.yml b/workflows/flutter/flutter-driver.yml new file mode 100644 index 0000000..552359f --- /dev/null +++ b/workflows/flutter/flutter-driver.yml @@ -0,0 +1,48 @@ +# Name of your workflow. +name: flutter drive +# Trigger the workflow on push or pull request. +on: [push, pull_request] +# A workflow run is made up of one or more jobs. +jobs: + # id of job, a string that is unique to the "jobs" node above. + drive: + # Creates a build matrix for your jobs. You can define different + # variations of an environment to run each job in. + strategy: + # A set of different configurations of the virtual + # environment. + matrix: + device: + - "iPhone 8 (13.1)" + - "iPhone 11 Pro Max (13.1)" + # When set to true, GitHub cancels all in-progress jobs if any + # matrix job fails. + fail-fast: false + # The type of machine to run the job on. + runs-on: macOS-latest + # Contains a sequence of tasks. + steps: + # A name for your step to display on GitHub. + - name: "List all simulators" + run: "xcrun instruments -s" + - name: "Start Simulator" + run: | + UDID=$( + xcrun instruments -s | + awk \ + -F ' *[][]' \ + -v 'device=${{ matrix.device }}' \ + '$1 == device { print $2 }' + ) + xcrun simctl boot "${UDID:?No Simulator with this name found}" + # The branch or tag ref that triggered the workflow will be + # checked out. + # https://github.com/actions/checkout + - uses: actions/checkout@v1 + # Sets up a flutter environment. + # https://github.com/marketplace/actions/flutter-action + - uses: subosito/flutter-action@v1 + with: + channel: 'stable' # or: 'dev' or 'beta' + - name: "Run Flutter Driver tests" + run: "flutter drive --target=test_driver/app.dart" \ No newline at end of file From f86600e000441d1e942a6cd4b2ad0a4cffc30b34 Mon Sep 17 00:00:00 2001 From: armantorkzaban Date: Fri, 7 Oct 2022 11:18:34 +0200 Subject: [PATCH 2/2] flutter integration test --- .../flutter/flutter-integration-test.yml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 workflows/flutter/flutter-integration-test.yml diff --git a/workflows/flutter/flutter-integration-test.yml b/workflows/flutter/flutter-integration-test.yml new file mode 100644 index 0000000..a7a393f --- /dev/null +++ b/workflows/flutter/flutter-integration-test.yml @@ -0,0 +1,73 @@ +# .github/workflows/main.yml + +# Name of your workflow. +name: main + +# Trigger the workflow manually or after push a commit +on: [push, workflow_dispatch] + +# 2 jobs are configured. +# The first one runs tests on iOS devices. +# The second runs tests on Android devices +jobs: + # job responsible for running Flutter tests on iOS devices + ios: + # Creates a build matrix for your jobs. You can define different variations of an environment to run each job + strategy: + matrix: + device: + # The available simulators are listed by the "xcrun xctrace list devices" command + - "iPhone 11 Simulator (15.2)" # the name of the simulator could be different depending on the macos version you are using + # if one of the jobs in the matrix expansion fails, the rest of the jobs will be cancelled + fail-fast: true + runs-on: macos-11 # or macos-latest if you prefer, but be aware that the available simulators could be different if you run a different version + steps: + - name: "List all simulators" + run: "xcrun xctrace list devices" + - name: "Start Simulator" + # the command "xcrun simctl boot" expects a device identifier + # the assignment of the UDID variable consists of retrieving the ID of the simulator + # by extracting it from the command "xcrun xctrace list devices" + run: | + UDID=$(xcrun xctrace list devices | grep "^${{ matrix.device }}" | awk '{gsub(/[()]/,""); print $NF}') + echo $UDID + xcrun simctl boot "${UDID:?No Simulator with this name found}" + - uses: actions/checkout@v3 + - name: Setup Flutter SDK + uses: subosito/flutter-action@v2 + with: + channel: stable + # instead of "channel: stable", you could be more precise by specifying the exact version of Flutter you're using: + # flutter-version: '' + - name: Install Flutter dependencies + run: flutter pub get + - name: Run integration tests + run: flutter test integration_test --verbose + + # job responsible for running Flutter tests on Android devices + android: + runs-on: macos-11 + strategy: + matrix: + api-level: + - 29 + # you can add more API level if you want to run your tests on different API + fail-fast: true + steps: + - uses: actions/checkout@v3 + - name: Setup Flutter SDK + uses: subosito/flutter-action@v2 + with: + channel: stable + # instead of "channel: stable", you could be more precise by specifying the exact version of Flutter you're using: + # flutter-version: '' + - name: Install Flutter dependencies + run: flutter pub get + - name: Run integration tests + # more info on https://github.com/ReactiveCircus/android-emulator-runner + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: x86_64 + profile: Nexus 6 + script: flutter test integration_test --verbose