From 658f9f4efa3099588d6e09d1ffc6bb9a4a9d5168 Mon Sep 17 00:00:00 2001 From: Dirk Doesburg Date: Wed, 2 Nov 2022 11:33:28 +0100 Subject: [PATCH] Combine workflows and use iOS for integration test --- .github/workflows/build.yaml | 139 --------------- .github/workflows/integration-testing.yaml | 31 ---- .github/workflows/linting.yaml | 29 ---- .github/workflows/testing.yaml | 189 ++++++++++++++++++++- 4 files changed, 186 insertions(+), 202 deletions(-) delete mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/integration-testing.yaml delete mode 100644 .github/workflows/linting.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 05ffc17eb..000000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,139 +0,0 @@ ---- -name: Build -on: - - push - - workflow_dispatch - -jobs: - build-ios: - name: iOS - runs-on: macos-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: 3.3.6 - channel: stable - cache: true - - - name: Flutter version - run: flutter --version - - - name: Pods cache - uses: actions/cache@v3 - with: - path: ios/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods- - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: 2.7.0 - - - name: Decode secrets - env: - APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} - run: | - echo $APPLE_API_KEY | base64 --decode > $GITHUB_WORKSPACE/app-store.p8 - - - name: Build app - env: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - KEYCHAIN_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_GIT_PRIVATE_KEY: ${{ secrets.PASSWORDS_REPO_DEPLOY_KEY }} - THALIA_API_HOST: thalia.nu - THALIA_OAUTH_APP_ID: ${{ secrets.THALIA_OAUTH_APP_ID }} - THALIA_OAUTH_APP_SECRET: ${{ secrets.THALIA_OAUTH_APP_SECRET }} - TOSTI_API_HOST: tosti.science.ru.nl - TOSTI_OAUTH_APP_ID: ${{ secrets.TOSTI_OAUTH_APP_ID }} - TOSTI_OAUTH_APP_SECRET: ${{ secrets.TOSTI_OAUTH_APP_SECRET }} - run: bundle exec fastlane ios deploy_adhoc - - - name: Upload IPA - uses: actions/upload-artifact@v3 - with: - name: ThaliApp.ipa - path: ios/build - - build-android: - name: Android - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Checkout passwords repo - uses: actions/checkout@v3 - with: - repository: svthalia/ThaliApp-passwords - path: thaliapp-passwords - ssh-key: ${{ secrets.PASSWORDS_REPO_DEPLOY_KEY }} - - - name: Decode secrets - env: - GOOGLE_PLAY_CONFIG: ${{ secrets.GOOGLE_PLAY_CONFIG_JSON }} - RELEASE_CONFIG_STORE_FILE: ${{ secrets.ANDROID_RELEASE_CONFIG_STORE_FILE }} - RELEASE_CONFIG_STORE_PASS: ${{ secrets.ANDROID_RELEASE_CONFIG_STORE_PASS }} - RELEASE_CONFIG_KEY_PASS: ${{ secrets.ANDROID_RELEASE_CONFIG_KEY_PASS }} - RELEASE_CONFIG_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_CONFIG_KEY_ALIAS }} - run: | - echo $GOOGLE_PLAY_CONFIG > $GITHUB_WORKSPACE/google-play.json - - echo "storeFile=$RELEASE_CONFIG_STORE_FILE" > $GITHUB_WORKSPACE/android/key.properties - echo "storePassword=$RELEASE_CONFIG_STORE_PASS" >> $GITHUB_WORKSPACE/android/key.properties - echo "keyPassword=$RELEASE_CONFIG_KEY_PASS" >> $GITHUB_WORKSPACE/android/key.properties - echo "keyAlias=$RELEASE_CONFIG_KEY_ALIAS" >> $GITHUB_WORKSPACE/android/key.properties - - - name: Setup JDK 8 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: zulu - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: 3.3.6 - channel: stable - cache: true - - - name: Flutter version - run: flutter --version - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: 2.7.0 - - - name: Gradle cache - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Build app - env: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - THALIA_API_HOST: thalia.nu - THALIA_OAUTH_APP_ID: ${{ secrets.THALIA_OAUTH_APP_ID }} - THALIA_OAUTH_APP_SECRET: ${{ secrets.THALIA_OAUTH_APP_SECRET }} - TOSTI_API_HOST: tosti.science.ru.nl - TOSTI_OAUTH_APP_ID: ${{ secrets.TOSTI_OAUTH_APP_ID }} - TOSTI_OAUTH_APP_SECRET: ${{ secrets.TOSTI_OAUTH_APP_SECRET }} - run: bundle exec fastlane android deploy_adhoc - - - name: Upload APK - uses: actions/upload-artifact@v3 - with: - name: app-release.apk - path: build/app/outputs/flutter-apk/app-release.apk diff --git a/.github/workflows/integration-testing.yaml b/.github/workflows/integration-testing.yaml deleted file mode 100644 index a3a8b43ca..000000000 --- a/.github/workflows/integration-testing.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Integration Testing -on: - - push - - workflow_dispatch - -jobs: - integration-testing: - name: Testing - runs-on: macos-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: 3.3.6 - channel: stable - cache: true - - - name: Flutter version - run: flutter --version - - - name: Run integration tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 31 - arch: x86_64 - profile: Nexus 6 - script: flutter test -r expanded integration_test diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml deleted file mode 100644 index 22eded91a..000000000 --- a/.github/workflows/linting.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: Linting -on: - - push - - workflow_dispatch - -jobs: - linting: - name: Linting - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: 3.3.6 - channel: stable - cache: true - - - name: Flutter version - run: flutter --version - - - name: Flutter format - run: flutter format --set-exit-if-changed . - - - name: Flutter analyze - run: flutter analyze diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index f7136bbf9..6ec4f13c4 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -1,10 +1,35 @@ --- -name: Testing +name: CI on: - push - workflow_dispatch +env: + FLUTTER_VERSION: 3.3.6 + jobs: + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Flutter version + run: flutter --version + + - name: Flutter format + run: flutter format --set-exit-if-changed . + + - name: Flutter analyze + run: flutter analyze + testing: name: Testing runs-on: ubuntu-latest @@ -15,8 +40,7 @@ jobs: - name: Setup Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 3.3.6 - channel: stable + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true - name: Flutter version @@ -24,3 +48,162 @@ jobs: - name: Flutter test run: flutter test -r expanded + + integration-ios: + name: Integration Testing - iOS + runs-on: macos-latest + steps: + - name: "List all simulators" + run: "xcrun xctrace list devices" + + - name: "Start Simulator" + env: + DEVICE: "iPhone 12 Pro Simulator (15.2)" + run: | + UDID=$(xcrun xctrace list devices | grep "^$DEVICE (" | awk '{gsub(/[()]/,""); print $NF}') + echo $UDID + xcrun simctl boot "${UDID:?No Simulator with this name found}" + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + - name: Install Flutter dependencies + run: flutter pub get + - name: Run integration tests + run: flutter test integration_test -r expanded + + build-ios: + name: Build - iOS + runs-on: macos-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Flutter version + run: flutter --version + + - name: Pods cache + uses: actions/cache@v3 + with: + path: ios/Pods + key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: 2.7.0 + + - name: Decode secrets + env: + APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} + run: | + echo $APPLE_API_KEY | base64 --decode > $GITHUB_WORKSPACE/app-store.p8 + + - name: Build app + env: + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + MATCH_GIT_PRIVATE_KEY: ${{ secrets.PASSWORDS_REPO_DEPLOY_KEY }} + THALIA_API_HOST: thalia.nu + THALIA_OAUTH_APP_ID: ${{ secrets.THALIA_OAUTH_APP_ID }} + THALIA_OAUTH_APP_SECRET: ${{ secrets.THALIA_OAUTH_APP_SECRET }} + TOSTI_API_HOST: tosti.science.ru.nl + TOSTI_OAUTH_APP_ID: ${{ secrets.TOSTI_OAUTH_APP_ID }} + TOSTI_OAUTH_APP_SECRET: ${{ secrets.TOSTI_OAUTH_APP_SECRET }} + run: bundle exec fastlane ios deploy_adhoc + + - name: Upload IPA + uses: actions/upload-artifact@v3 + with: + name: ThaliApp.ipa + path: ios/build + + build-android: + name: Build - Android + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Checkout passwords repo + uses: actions/checkout@v3 + with: + repository: svthalia/ThaliApp-passwords + path: thaliapp-passwords + ssh-key: ${{ secrets.PASSWORDS_REPO_DEPLOY_KEY }} + + - name: Decode secrets + env: + GOOGLE_PLAY_CONFIG: ${{ secrets.GOOGLE_PLAY_CONFIG_JSON }} + RELEASE_CONFIG_STORE_FILE: ${{ secrets.ANDROID_RELEASE_CONFIG_STORE_FILE }} + RELEASE_CONFIG_STORE_PASS: ${{ secrets.ANDROID_RELEASE_CONFIG_STORE_PASS }} + RELEASE_CONFIG_KEY_PASS: ${{ secrets.ANDROID_RELEASE_CONFIG_KEY_PASS }} + RELEASE_CONFIG_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_CONFIG_KEY_ALIAS }} + run: | + echo $GOOGLE_PLAY_CONFIG > $GITHUB_WORKSPACE/google-play.json + + echo "storeFile=$RELEASE_CONFIG_STORE_FILE" > $GITHUB_WORKSPACE/android/key.properties + echo "storePassword=$RELEASE_CONFIG_STORE_PASS" >> $GITHUB_WORKSPACE/android/key.properties + echo "keyPassword=$RELEASE_CONFIG_KEY_PASS" >> $GITHUB_WORKSPACE/android/key.properties + echo "keyAlias=$RELEASE_CONFIG_KEY_ALIAS" >> $GITHUB_WORKSPACE/android/key.properties + + - name: Setup JDK 8 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: zulu + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + + - name: Flutter version + run: flutter --version + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: 2.7.0 + + - name: Gradle cache + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build app + env: + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + THALIA_API_HOST: thalia.nu + THALIA_OAUTH_APP_ID: ${{ secrets.THALIA_OAUTH_APP_ID }} + THALIA_OAUTH_APP_SECRET: ${{ secrets.THALIA_OAUTH_APP_SECRET }} + TOSTI_API_HOST: tosti.science.ru.nl + TOSTI_OAUTH_APP_ID: ${{ secrets.TOSTI_OAUTH_APP_ID }} + TOSTI_OAUTH_APP_SECRET: ${{ secrets.TOSTI_OAUTH_APP_SECRET }} + run: bundle exec fastlane android deploy_adhoc + + - name: Upload APK + uses: actions/upload-artifact@v3 + with: + name: app-release.apk + path: build/app/outputs/flutter-apk/app-release.apk