diff --git a/.github/actions/local_fluttium_environment/action.yaml b/.github/actions/local_fluttium_environment/action.yaml new file mode 100644 index 00000000..2df85c96 --- /dev/null +++ b/.github/actions/local_fluttium_environment/action.yaml @@ -0,0 +1,25 @@ +name: Local Fluttium Environment + +runs: + using: "composite" + steps: + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + + - shell: bash + working-directory: tools + run: dart pub get + + - shell: bash + run: dart tools/setup_local_environment.dart + + - shell: bash + 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/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 00000000..a2c890a8 --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,229 @@ +name: e2e + +on: + workflow_call: + +defaults: + run: + 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 User Flows + id: flows + 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: + 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 ios && pod install && cd .. + + - 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 + + android: + if: false # TODO: Currently does not work + needs: flows + + strategy: + matrix: + flow: ${{ fromJSON(needs.flows.outputs.flows) }} + fail-fast: true + + runs-on: macos-latest + + steps: + - name: ๐Ÿ“š Git Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "11" + + - name: ๐Ÿฆ Setup Local Fluttium Environment + uses: ./.github/actions/local_fluttium_environment + + - 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 + + 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 + + - 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 + 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.flow }}.yaml + + 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 + + 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 clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev + + - 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 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0e4d88c7..acae26c1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -252,12 +252,7 @@ jobs: with: working_directory: actions/${{ matrix.brick }} - # 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. - # - # The build and pana job might not spawn but as long as the other jobs - # succeed this job will be considered successful through skipping. - ci: + e2e: needs: [ semantic_pull_request, @@ -270,6 +265,20 @@ jobs: 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. + # + # The build and pana job might not spawn but as long as the other jobs + # succeed this job will be considered successful through skipping. + ci: + needs: + [ + e2e + ] if: ${{ always() }} runs-on: ubuntu-latest