Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a matrix to deploy and cleanup apps #673

Merged
merged 5 commits into from
Jun 24, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 119 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@ jobs:
runs-on: ubuntu-latest
name: Deploy Cluster
outputs:
clusterName: ${{ steps.cluster-name.outputs.clusterName }}
clusterName: ${{ steps.deploy-atlas-cluster.outputs.clusterName }}
steps:
- name: Get cluster suffix
id: cluster-name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we return back this step for generating different names on every 12 h?

run: echo "::set-output name=clusterName::dart$(date +'%d%p')"

- uses: realm/ci-actions/mdb-realm/deployApps@916d1585f7e066431830b195cdb8cf7855747c2a
id: deploy-mdb-apps
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: ${{ steps.cluster-name.outputs.clusterName }}
clusterName: ${{ steps.cluster-name.outputs.clusterName }}
differentiator: dart
clusterName: dart
useExistingCluster: true

build-native:
Expand Down Expand Up @@ -114,7 +110,116 @@ 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
- 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: 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:
Expand All @@ -138,8 +243,8 @@ jobs:
needs:
- deploy-cluster
- build-native
- baas-matrix
steps:

- name: Checkout
uses: actions/checkout@v2
with:
Expand All @@ -160,19 +265,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:
Expand All @@ -190,10 +289,10 @@ jobs:
env:
BAAS_CLUSTER: ${{ needs.deploy-cluster.outputs.clusterName }}
BAAS_DIFFERENTIATOR: ${{ matrix.app }}${{ github.run_id }}${{ github.run_attempt }}

needs:
- deploy-cluster
- build-native
- baas-matrix
steps:

- name: Checkout
Expand Down Expand Up @@ -222,10 +321,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

Expand All @@ -236,12 +331,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
Expand All @@ -251,6 +340,7 @@ jobs:
needs:
- deploy-cluster
- build-ios-xcframework
- baas-matrix
steps:

- name: Checkout
Expand All @@ -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

Expand All @@ -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
Expand All @@ -306,6 +386,7 @@ jobs:
needs:
- deploy-cluster
- build-android-combined
- baas-matrix
steps:

- name: Checkout
Expand All @@ -324,10 +405,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

Expand Down Expand Up @@ -367,10 +444,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:
Expand Down