Skip to content

Commit

Permalink
chore(pipeline): migrate nightly_e2e_workflow
Browse files Browse the repository at this point in the history
SUITEDEV-35237

Co-authored-by: megamegax <[email protected]>
  • Loading branch information
davidSchuppa and megamegax committed Mar 1, 2024
1 parent a7162ed commit 826830c
Showing 1 changed file with 57 additions and 83 deletions.
140 changes: 57 additions & 83 deletions .github/workflows/nightly_e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@ name: Nightly E2E pipeline
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
- cron: '0 3 * * *'

env:
RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
USE_LOCAL_DEPENDENCY: ${{ vars.USE_LOCAL_DEPENDENCY }}
RELEASE_MODE: ${{ vars.RELEASE_MODE }}
ANDROID_RELEASE_STORE_FILE_BASE64: ${{ secrets.ANDROID_RELEASE_STORE_FILE_BASE64 }}
ANDROID_RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_STORE_PASSWORD }}
ANDROID_RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEY_ALIAS }}
ANDROID_RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }}
FIREBASE_PROJECT_ID: ${{ vars.FIREBASE_PROJECT_ID }}
FIREBASE_SERVICE_ACCOUNT_JSON: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }}
GOOGLE_OAUTH_SERVER_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_SERVER_CLIENT_ID }}
GOOGLE_PLAY_STORE_SEVICE_ACCOUNT_JSON_BASE64: ${{ secrets.GOOGLE_PLAY_STORE_SEVICE_ACCOUNT_JSON_BASE64 }}
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SONATYPE_SIGNING_KEY_ID: ${{ secrets.SONATYPE_SIGNING_KEY_ID }}
SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
SONATYPE_SIGNING_SECRET_KEY_RING_FILE_BASE64: ${{ secrets.SONATYPE_SIGNING_SECRET_KEY_RING_FILE_BASE64 }}
RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD }}
RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
RELEASE_STORE_FILE: ${{ secrets.RELEASE_STORE_FILE }}
DEVELOPMENT_MODE: ${{ secrets.DEVELOPMENT_MODE }}
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
Expand All @@ -22,112 +39,69 @@ jobs:
runs-on: ubuntu-latest
name: Build job
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: dev
submodules: true
fetch-depth: 0

- run: git fetch --all || echo "==> Accept any result"
- name: set up JDK 1.17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: create-google services json
uses: jsdaniell/[email protected]
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
name: google-services.json
json: ${{ secrets.GOOGLE_SERVICES_JSON }}
dir: sample
gradle-version: 8.6
cache-overwrite-existing: true
gradle-home-cache-cleanup: true

- name: create local.properties
run: echo $ANDROID_HOME > local.properties
- name: Prepare CI
run: make prepare-ci

- name: Build with Gradle
run: ./gradlew assembleAndroidTest -x lint

- name: upload sample app artifact
uses: actions/upload-artifact@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
name: sample
path: sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk
workload_identity_provider: 'projects/395478287999/locations/global/workloadIdentityPools/github-actions/providers/github-actions'
service_account: 'firebase-test-lab-service-acco@ems-mobile-sdk.iam.gserviceaccount.com'
create_credentials_file: true

- name: upload emarsys-e2e-test test apk artifact
uses: actions/upload-artifact@v4
with:
name: emarsys-e2e-test
path: emarsys-e2e-test/build/outputs/apk/androidTest/debug/emarsys-e2e-test-debug-androidTest.apk
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: create testlab services json
uses: jsdaniell/[email protected]
with:
name: sacc_key.json
json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
- name: Build
run: make build-test

TestE2E:
name: Run E2E tests on Firebase
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- run: git fetch --all || echo "==> Accept any result"
- name: Test E2E
run: make test-android-firebase MODULE_NAME=emarsys-e2e-test

- name: Download sample app
uses: actions/download-artifact@v4
with:
name: sample

- name: Download Emarsys E2E tests
uses: actions/download-artifact@v4
with:
name: emarsys-e2e-test

- name: Run tests
uses: asadmansr/[email protected]
with:
arg-spec: 'testWithSomeVirtualDevices.yml:emarsys-e2e-test'
env:
SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}

SlackNotification:
name: Send slack notification
Report:
if: always()
needs: [ Build ]
runs-on: ubuntu-latest
needs: [TestE2E]
steps:
- name: Slack Notification
uses: megamegax/[email protected]
- name: Report on Slack (Error)
if: ${{ !cancelled() && contains(needs.*.result, 'failure') }}
uses: megamegax/[email protected]
with:
webhook_url: '${{env.SLACK_WEBHOOK}}'
channel: '${{env.SLACK_CHANNEL}}'
message: 'Nightly E2E tests successful! :man-gesturing-ok: :bananadance:'
message: 'Nightly E2E tests failed! :man-gesturing-no: :blobcatfearful:'
user_name: '${{env.SLACK_USERNAME}}'
job_status: 'success'
job_status: 'failure'
user_icon: '${{env.SLACK_ICON}}'
actions: '[{ "type": "button", "text": "View actions", "url": "https://github.com/emartech/android-emarsys-sdk/actions" },{ "type": "button", "text": "View Firebase", "url": "https://console.firebase.google.com/project/ems-mobile-sdk/testlab/histories/" },{ "type": "button", "text": "Install page", "url": "http://ems-mobileteam-artifacts.s3-website-eu-west-1.amazonaws.com/index-ems.html" }]'


SlackNotificationOnError:
name: Send slack on error
runs-on: ubuntu-latest
needs: [TestE2E]
if: ${{ failure() }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0 # 0 indicates all history
- run: git fetch --all || echo "==> Accept any result"
actions: '[{ "type": "button", "text": "View actions", "url": "https://github.com/emartech/android-emarsys-sdk/actions" },{ "type": "button", "text": "View Firebase", "url": "https://console.firebase.google.com/project/ems-mobile-sdk/testlab/histories/" }]'

- name: Slack Notification
uses: megamegax/[email protected]
- name: Report on Slack (Success)
if: ${{ !contains(needs.*.result, 'cancelled') && !contains(needs.*.result, 'failure') }}
uses: megamegax/[email protected]
with:
webhook_url: '${{env.SLACK_WEBHOOK}}'
channel: '${{env.SLACK_CHANNEL}}'
message: 'Nightly E2E tests failed! :man-gesturing-no: :blobcatfearful:'
message: 'Nightly E2E tests successful! :man-gesturing-ok: :bananadance:'
user_name: '${{env.SLACK_USERNAME}}'
job_status: 'failure'
job_status: 'success'
user_icon: '${{env.SLACK_ICON}}'
actions: '[{ "type": "button", "text": "View actions", "url": "https://github.com/emartech/android-emarsys-sdk/actions" },{ "type": "button", "text": "View Firebase", "url": "https://console.firebase.google.com/project/ems-mobile-sdk/testlab/histories/" }]'
actions: '[{ "type": "button", "text": "View actions", "url": "https://github.com/emartech/android-emarsys-sdk/actions" },{ "type": "button", "text": "View Firebase", "url": "https://console.firebase.google.com/project/ems-mobile-sdk/testlab/histories/" }]'

0 comments on commit 826830c

Please sign in to comment.