From 939132f8affbcd9977b67510458c2f9157570001 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 27 Nov 2023 17:00:01 +0100 Subject: [PATCH] update CI --- .github/workflows/patrol-prepare.yaml | 39 +--- .github/workflows/prepare-e2e_app.yaml | 245 ++++++++++++++++++++++ .github/workflows/test-ios-simulator.yaml | 2 +- dev/e2e_app/ios/Podfile.lock | 2 +- 4 files changed, 249 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/prepare-e2e_app.yaml diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index 0f21c0f7ff..df8d564270 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -140,8 +140,8 @@ jobs: brew install xcbeautify # Disabled because of generated protobuf code - #- name: swift-format lint - # run: test -z $(swift-format lint --recursive --strict .) + - name: swift-format lint + run: test -z $(swift-format lint --recursive --strict .) - name: swift-format format if: success() || failure() @@ -154,41 +154,6 @@ jobs: if: success() || failure() run: | find . -iname '*.h' -o -iname '*.m' | xargs -I {} clang-format --dry-run --Werror {} - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: ${{ matrix.flutter-version }} - channel: ${{ matrix.flutter-channel }} - - - name: Preload Flutter artifacts - run: flutter precache --ios - - - name: Generate iOS build filesP - working-directory: packages/patrol/example - run: flutter build ios --config-only --simulator - - - name: Start iOS simulator - uses: futureware-tech/simulator-action@v2 - with: - model: iPhone 14 - os: iOS - os_version: 16.2 - erase_before_boot: true - shutdown_after_job: true - - - name: Run unit tests - working-directory: packages/patrol/example/ios - run: | - set -o pipefail - xcodebuild test \ - -workspace Runner.xcworkspace \ - -scheme Runner \ - -only-testing RunnerTests \ - -configuration Debug \ - -sdk iphoneos -destination 'platform=iOS Simulator,name=iPhone 14' \ - -derivedDataPath ../build/ios_unit | xcbeautify --renderer github-actions - prepare-flutter: name: Flutter ${{ matrix.flutter-version }} runs-on: ubuntu-latest diff --git a/.github/workflows/prepare-e2e_app.yaml b/.github/workflows/prepare-e2e_app.yaml new file mode 100644 index 0000000000..7f7b56f18c --- /dev/null +++ b/.github/workflows/prepare-e2e_app.yaml @@ -0,0 +1,245 @@ +name: prepare e2e_app + +on: + workflow_dispatch: + pull_request: + paths: + - './**' + - '!**.md' # ignore readmes + - '!**.mdx' # ignore docs + +jobs: + prepare-android-on-windows: + runs-on: ${{ matrix.os }} + name: Android on ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [windows-latest] + flutter-version: ['3.16.x'] + flutter-channel: ['stable'] + + defaults: + run: + working-directory: dev/e2e_app/android + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} + + - name: Preload Flutter artifacts + run: flutter precache --android + + - name: Generate Gradle wrapper + run: flutter build apk --config-only + + - name: ktlint check + run: .\gradlew.bat :patrol:ktlintCheck + + - name: ktlint format + run: .\gradlew.bat :patrol:ktlintFormat + + - name: Build app with Gradle + run: .\gradlew.bat :app:assembleDebug + + - name: Build app with Flutter tool + run: flutter build apk --debug + + prepare-android-on-linux: + runs-on: ${{ matrix.os }} + name: Android on ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + flutter-version: ['3.16.x'] + flutter-channel: ['stable'] + + defaults: + run: + working-directory: dev/e2e_app + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} + + - name: Preload Flutter artifacts + run: flutter precache --android + + - name: Generate Gradle wrapper + run: flutter build apk --config-only + + - name: Run unit tests + if: success() || failure() + run: ./gradlew :patrol:testDebug + + - name: ktlint check + if: success() || failure() + run: ./gradlew :patrol:ktlintCheck + + - name: ktlint format + if: success() || failure() + run: ./gradlew :patrol:ktlintFormat + + - name: Build app with Gradle + run: ./gradlew :app:assembleDebug + + - name: Build app with Flutter tool + run: flutter build apk --debug + + prepare-ios: + runs-on: ${{ matrix.os }} + name: iOS on ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [macos-latest] + flutter-version: ['3.16.x'] + flutter-channel: ['stable'] + + defaults: + run: + working-directory: packages/patrol/ios + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install tools + run: | + brew update + brew install swift-format + brew install clang-format + brew install xcbeautify + + - name: swift-format lint + run: test -z $(swift-format lint --recursive --strict .) + + - name: swift-format format + if: success() || failure() + run: | + swift-format format --recursive --in-place . + git update-index --refresh + git diff-index --quiet HEAD -- + + - name: clang-format + if: success() || failure() + run: | + find . -iname '*.h' -o -iname '*.m' | xargs -I {} clang-format --dry-run --Werror {} + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} + + - name: Preload Flutter artifacts + run: flutter precache --ios + + - name: Generate iOS build files + working-directory: packages/patrol/example + run: flutter build ios --config-only --simulator + + - name: Start iOS simulator + uses: futureware-tech/simulator-action@v2 + with: + model: iPhone 14 + os: iOS + os_version: 16.2 + erase_before_boot: true + shutdown_after_job: true + + - name: Run unit tests + working-directory: packages/patrol/example/ios + run: | + set -o pipefail + xcodebuild test \ + -workspace Runner.xcworkspace \ + -scheme Runner \ + -only-testing RunnerTests \ + -configuration Debug \ + -sdk iphoneos -destination 'platform=iOS Simulator,name=iPhone 14' \ + -derivedDataPath ../build/ios_unit | xcbeautify --renderer github-actions + + prepare-flutter: + name: Flutter ${{ matrix.flutter-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + flutter-version: ['3.16.x'] + flutter-channel: ['stable'] + + defaults: + run: + working-directory: packages/patrol + + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} + + - name: Set up Melos and activate workspace + working-directory: . + run: | + dart pub global activate melos + melos bootstrap + + - name: flutter pub get + run: flutter pub get + + - name: flutter test + if: success() || failure() + run: flutter test + + - name: Run analyzer + if: success() || failure() + run: | + flutter analyze + dart run custom_lint + + - name: dart format + if: success() || failure() + run: dart format --set-exit-if-changed . + + - name: flutter pub publish --dry-run + if: success() || failure() + run: flutter pub publish --dry-run + + - name: flutter pub get (example app) + if: success() || failure() + working-directory: ./packages/patrol/example + run: flutter pub get diff --git a/.github/workflows/test-ios-simulator.yaml b/.github/workflows/test-ios-simulator.yaml index fef6e54377..108f92587e 100644 --- a/.github/workflows/test-ios-simulator.yaml +++ b/.github/workflows/test-ios-simulator.yaml @@ -87,7 +87,7 @@ jobs: echo "EXCLUDED_TESTS=$TESTS_TO_EXCLUDE" >> "$GITHUB_OUTPUT" echo "EXCLUDED_TESTS=$target_paths" >> "$GITHUB_ENV" - - name: Run tests + - name: Run UI tests id: tests_step run: | xcrun simctl io booted recordVideo --codec=h264 "${{ matrix.device_model }}.mp4" & diff --git a/dev/e2e_app/ios/Podfile.lock b/dev/e2e_app/ios/Podfile.lock index d7cd4bbf65..4e0d4d622d 100644 --- a/dev/e2e_app/ios/Podfile.lock +++ b/dev/e2e_app/ios/Podfile.lock @@ -64,4 +64,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: b2bb71756d032256bcb4043384dd40772d5e6a93 -COCOAPODS: 1.14.2 +COCOAPODS: 1.14.3