Nightly E2E pipeline #950
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly E2E pipeline | |
on: | |
workflow_dispatch: | |
schedule: | |
- 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 }} | |
RELEASE_STORE_FILE: ${{ secrets.RELEASE_STORE_FILE }} | |
DEVELOPMENT_MODE: ${{ secrets.DEVELOPMENT_MODE }} | |
GOOGLE_SERVICES_API_KEY: ${{ secrets.GOOGLE_SERVICES_API_KEY }} | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
SLACK_ICON: https://icons.iconarchive.com/icons/martz90/circle/256/android-icon.png | |
SLACK_TITLE: Commit status | |
SLACK_USERNAME: Emarsys SDK - Android | |
SLACK_WEBHOOK: ${{ secrets.SLACK_MOBILE_TEAM_CI_CHANNEL_WEBHOOK }} | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
name: Build job | |
steps: | |
- uses: actions/checkout@v3 | |
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@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: create-google services json | |
uses: jsdaniell/[email protected] | |
with: | |
name: google-services.json | |
json: ${{ secrets.GOOGLE_SERVICES_JSON }} | |
dir: sample | |
- name: create local.properties | |
run: echo $ANDROID_HOME > local.properties | |
- name: Build with Gradle | |
run: ./gradlew assembleAndroidTest -x lint | |
- name: Create file 'FAILURE.TXT' and write 'false' into it | |
run: echo 'false' > FAILURE.TXT | |
- name: Upload file 'FAILURE.TXT' as an artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: failure_file | |
path: FAILURE.TXT | |
- name: upload sample app artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: sample | |
path: sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk | |
- name: upload emarsys-e2e-test test apk artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: emarsys-e2e-test | |
path: emarsys-e2e-test/build/outputs/apk/androidTest/debug/emarsys-e2e-test-debug-androidTest.apk | |
- name: create testlab services json | |
uses: jsdaniell/[email protected] | |
with: | |
name: sacc_key.json | |
json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} | |
- name: Create file 'FAILURE.TXT' and write 'true' into it | |
if: ${{ failure() }} | |
run: echo 'true' > FAILURE.TXT | |
- name: Upload file 'FAILURE.TXT' as an artifact | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v1 | |
with: | |
name: failure_file | |
path: FAILURE.TXT | |
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: Download sample app | |
uses: actions/download-artifact@v2 | |
with: | |
name: sample | |
- name: Download Emarsys E2E tests | |
uses: actions/download-artifact@v2 | |
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 }} | |
- name: Create file 'FAILURE.TXT' and write 'true' into it | |
if: ${{ failure() }} | |
run: echo 'true' > FAILURE.TXT | |
- name: Upload file 'FAILURE.TXT' as an artifact | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v1 | |
with: | |
name: failure_file | |
path: FAILURE.TXT | |
SlackNotification: | |
name: Send slack notification | |
runs-on: ubuntu-latest | |
needs: [TestE2E] | |
steps: | |
- name: Slack Notification | |
uses: megamegax/[email protected] | |
with: | |
channel: '${{env.SLACK_CHANNEL}}' | |
message: 'Nightly E2E tests successful! :man-gesturing-ok: :bananadance:' | |
user_name: '${{env.SLACK_USERNAME}}' | |
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/" },{ "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: always() | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 # 0 indicates all history | |
- run: git fetch --all || echo "==> Accept any result" | |
- name: Download file 'FAILURE.TXT' from artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: failure_file | |
- name: Read file 'FAILURE.TXT' and set output parameter | |
id: set_output | |
run: echo "::set-output name=FAILURE::$(<failure_file/FAILURE.TXT)" | |
- name: Slack Notification | |
if: steps.set_output.outputs.FAILURE == 'true' | |
uses: megamegax/[email protected] | |
with: | |
channel: '${{env.SLACK_CHANNEL}}' | |
message: 'Nightly E2E tests failed! :man-gesturing-no: :blobcatfearful:' | |
user_name: '${{env.SLACK_USERNAME}}' | |
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/" }]' |