From cdd8e58f0cb228b9397e1c84c9b5c72b338e518c Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 17 Jun 2022 13:32:45 +0200 Subject: [PATCH 1/5] Use a matrix to deploy and cleanup apps --- .github/workflows/ci.yml | 148 +++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13cb7f7f1..40803b54f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,115 @@ jobs: needs: build-native uses: ./.github/workflows/binary-combine-ios.yml -# Linux jobs + baas-matrix: + needs: + - deploy-cluster + strategy: + fail-fast: false + matrix: + include: + - app: dm + description: dart macos + - app: dma + description: dart macos-arm + - app: dl + description: dart linux + - app: dw + description: dart windows + - app: fm + description: flutter macos + - app: fl + description: flutter linux + - app: fw + description: flutter windows + - app: fa + description: flutter android + - app: fi + description: flutter iOS + runs-on: ubuntu-latest + name: Deploy apps for ${{ matrix.description }} + timeout-minutes: 20 + env: + BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} + BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: false + + - name : Setup Dart SDK + uses: dart-lang/setup-dart@main + with: + sdk: stable + + - name: Deploy Apps + run: | + dart run realm_dart deploy-apps \ + --baas-url ${{ env.BAAS_URL }} \ + --atlas-cluster ${{ env.BAAS_CLUSTER }} \ + --api-key ${{ env.BAAS_API_KEY }} \ + --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ + --project-id ${{ env.BAAS_PROJECT_ID }} \ + --differentiator "${{ env.BAAS_DIFFERENTIATOR }}" + + cleanup-matrix: + needs: + - dart-tests + - flutter-desktop-tests + - flutter-ios + - flutter-android + strategy: + fail-fast: false + matrix: + include: + - app: dm + description: dart macos + - app: dma + description: dart macos-arm + - app: dl + description: dart linux + - app: dw + description: dart windows + - app: fm + description: flutter macos + - app: fl + description: flutter linux + - app: fw + description: flutter windows + - app: fa + description: flutter android + - app: fi + description: flutter iOS + runs-on: ubuntu-latest + name: Cleanup apps for ${{ matrix.description }} + timeout-minutes: 20 + if: always() + env: + BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} + BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: false + + - name : Setup Dart SDK + uses: dart-lang/setup-dart@main + with: + sdk: stable + + - name: Cleanup apps + run: | + dart run realm_dart delete-apps \ + --baas-url ${{ env.BAAS_URL }} \ + --atlas-cluster ${{ env.BAAS_CLUSTER }} \ + --api-key ${{ env.BAAS_API_KEY }} \ + --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} \ + --project-id ${{ env.BAAS_PROJECT_ID }} \ + --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' + +# Dart jobs dart-tests: strategy: @@ -139,7 +247,6 @@ jobs: - deploy-cluster - build-native steps: - - name: Checkout uses: actions/checkout@v2 with: @@ -160,19 +267,13 @@ jobs: sdk: stable architecture: ${{ matrix.architecture == 'arm' && 'arm64' || 'x64'}} - - name: Deploy Apps for Dart tests on ${{ matrix.os }} - id: deploy-apps - run: dart run realm_dart deploy-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - - name: Install dependencies run: dart pub get - name: Run tests run: ${{ matrix.architecture == 'arm' && 'arch -arm64 ' || '' }}dart test -r expanded -j 1 --test-randomize-ordering-seed random - - name: Cleanup apps - if: always() - run: dart run realm_dart delete-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' +# Flutter jobs flutter-desktop-tests: strategy: @@ -190,7 +291,6 @@ jobs: env: BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }} BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }} - needs: - deploy-cluster - build-native @@ -222,10 +322,6 @@ jobs: with: channel: 'stable' - - name: Deploy Apps for Flutter tests on ${{ matrix.os }} - id: deploy-apps - run: dart run realm_dart deploy-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - - name: Enable Flutter Desktop support run: flutter config --enable-${{ matrix.os }}-desktop @@ -236,12 +332,6 @@ jobs: run: ${{ matrix.os == 'linux' && 'xvfb-run' || '' }} flutter drive -d ${{ matrix.os }} --target=test_driver/app.dart --suppress-analytics --dart-entrypoint-args="" #--verbose #-a="Some test name" working-directory: ./flutter/realm_flutter/tests - - name: Cleanup apps - if: always() - run: dart run realm_dart delete-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - -# iOS jobs - flutter-ios: runs-on: macos-latest name: Flutter Tests iOS @@ -272,10 +362,6 @@ jobs: with: channel: 'stable' - - name: Deploy Apps for Flutter IOS tests on ${{ matrix.os }} - id: deploy-apps - run: dart run realm_dart deploy-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - - name: Install dependencies run: flutter pub get @@ -291,12 +377,6 @@ jobs: flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics working-directory: ./flutter/realm_flutter/tests - - name: Cleanup apps - if: always() - run: dart run realm_dart delete-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - -# Android jobs - flutter-android: runs-on: macos-latest name: Flutter Tests Android @@ -324,10 +404,6 @@ jobs: with: channel: 'stable' - - name: Deploy Apps for Flutter Android tests on ${{ matrix.os }} - id: deploy-apps - run: dart run realm_dart deploy-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - - name: Install dependencies run: flutter pub get @@ -367,10 +443,6 @@ jobs: script: flutter drive --target=test_driver/app.dart --dart-define=testName="" --suppress-analytics working-directory: ./flutter/realm_flutter/tests - - name: Cleanup apps - if: always() - run: dart run realm_dart delete-apps --baas-url ${{ env.BAAS_URL }} --atlas-cluster ${{ env.BAAS_CLUSTER }} --api-key ${{ env.BAAS_API_KEY }} --private-api-key ${{ env.BAAS_PRIVATE_API_KEY }} --project-id ${{ env.BAAS_PROJECT_ID }} --differentiator '${{ env.BAAS_DIFFERENTIATOR }}' - # Generator jobs generator: From 5096e3361e0b3aa77e29b6e8047a31f9e7878542 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 17 Jun 2022 13:35:45 +0200 Subject: [PATCH 2/5] Add some needs --- .github/workflows/ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40803b54f..4b24cc437 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,20 +20,15 @@ jobs: outputs: clusterName: ${{ steps.cluster-name.outputs.clusterName }} steps: - - name: Get cluster suffix - id: cluster-name - run: echo "::set-output name=clusterName::dart$(date +'%d%p')" - - uses: realm/ci-actions/mdb-realm/deployApps@916d1585f7e066431830b195cdb8cf7855747c2a - id: deploy-mdb-apps with: realmUrl: ${{ env.BAAS_URL }} atlasUrl: ${{ secrets.ATLAS_QA_URL }} projectId: ${{ env.BAAS_PROJECT_ID }} apiKey: ${{ env.BAAS_API_KEY }} privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - differentiator: ${{ steps.cluster-name.outputs.clusterName }} - clusterName: ${{ steps.cluster-name.outputs.clusterName }} + differentiator: dart + clusterName: dart useExistingCluster: true build-native: @@ -246,6 +241,7 @@ jobs: needs: - deploy-cluster - build-native + - baas-matrix steps: - name: Checkout uses: actions/checkout@v2 @@ -294,6 +290,7 @@ jobs: needs: - deploy-cluster - build-native + - baas-matrix steps: - name: Checkout @@ -341,6 +338,7 @@ jobs: needs: - deploy-cluster - build-ios-xcframework + - baas-matrix steps: - name: Checkout @@ -386,6 +384,7 @@ jobs: needs: - deploy-cluster - build-android-combined + - baas-matrix steps: - name: Checkout From 55897d8d847a9eb72e0c75aa88dc7204d7807081 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 17 Jun 2022 13:39:29 +0200 Subject: [PATCH 3/5] Fix cluster name --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b24cc437..0279c3b65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,10 @@ jobs: runs-on: ubuntu-latest name: Deploy Cluster outputs: - clusterName: ${{ steps.cluster-name.outputs.clusterName }} + clusterName: ${{ steps.deploy-atlas-cluster.outputs.clusterName }} steps: - uses: realm/ci-actions/mdb-realm/deployApps@916d1585f7e066431830b195cdb8cf7855747c2a + id: deploy-atlas-cluster with: realmUrl: ${{ env.BAAS_URL }} atlasUrl: ${{ secrets.ATLAS_QA_URL }} From dcbb41709cf45f88b4f5c0a851351098e86d9662 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 20 Jun 2022 17:05:27 +0200 Subject: [PATCH 4/5] Add needs for deploy-cluster --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0279c3b65..4a98965cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,6 +168,7 @@ jobs: - flutter-desktop-tests - flutter-ios - flutter-android + - deploy-cluster strategy: fail-fast: false matrix: From 5518120f9962863f82ae03e5d1d4bde9387db612 Mon Sep 17 00:00:00 2001 From: Desislava Stefanova Date: Fri, 24 Jun 2022 17:05:51 +0300 Subject: [PATCH 5/5] New cluster name per 12h --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a98965cc..f66764805 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,18 +18,20 @@ jobs: runs-on: ubuntu-latest name: Deploy Cluster outputs: - clusterName: ${{ steps.deploy-atlas-cluster.outputs.clusterName }} + clusterName: ${{ steps.cluster-name.outputs.clusterName }} steps: + - name: Get cluster suffix + id: cluster-name + run: echo "::set-output name=clusterName::dart$(date +'%d%p')" + - uses: realm/ci-actions/mdb-realm/deployApps@916d1585f7e066431830b195cdb8cf7855747c2a - id: deploy-atlas-cluster with: realmUrl: ${{ env.BAAS_URL }} atlasUrl: ${{ secrets.ATLAS_QA_URL }} projectId: ${{ env.BAAS_PROJECT_ID }} apiKey: ${{ env.BAAS_API_KEY }} privateApiKey: ${{ env.BAAS_PRIVATE_API_KEY }} - differentiator: dart - clusterName: dart + clusterName: ${{ steps.cluster-name.outputs.clusterName }} useExistingCluster: true build-native: