From 62c130a42425997b3b2b473c7ca8dc26e31184c0 Mon Sep 17 00:00:00 2001 From: David Schuppa <32750715+davidSchuppa@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:43:27 +0100 Subject: [PATCH] chore(pipeline): modified pipelines SUITEDEV-35237 Co-authored-by: LasOri <24588073+LasOri@users.noreply.github.com> Co-authored-by: megamegax --- .github/workflows/nightly_e2e_workflow.yml | 1 - .github/workflows/nightly_workflow.yml | 1 - .github/workflows/on_push_workflow.yml | 30 ++- .github/workflows/on_push_workflow_new.yml | 252 +++++++++++++++++++++ .github/workflows/on_tag_workflow.yml | 1 - Makefile | 61 +++++ 6 files changed, 333 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/on_push_workflow_new.yml create mode 100644 Makefile diff --git a/.github/workflows/nightly_e2e_workflow.yml b/.github/workflows/nightly_e2e_workflow.yml index 0cd3361b..161ffe23 100644 --- a/.github/workflows/nightly_e2e_workflow.yml +++ b/.github/workflows/nightly_e2e_workflow.yml @@ -11,7 +11,6 @@ env: 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 diff --git a/.github/workflows/nightly_workflow.yml b/.github/workflows/nightly_workflow.yml index 1e9bcc5d..22cbdfd0 100644 --- a/.github/workflows/nightly_workflow.yml +++ b/.github/workflows/nightly_workflow.yml @@ -11,7 +11,6 @@ env: 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: Nightly build status diff --git a/.github/workflows/on_push_workflow.yml b/.github/workflows/on_push_workflow.yml index 1fb4f5cc..51f3b5fc 100644 --- a/.github/workflows/on_push_workflow.yml +++ b/.github/workflows/on_push_workflow.yml @@ -11,7 +11,23 @@ env: 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 }} + + 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_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 }} SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} SLACK_ICON: https://icons.iconarchive.com/icons/martz90/circle/256/android-icon.png SLACK_TITLE: Commit status @@ -35,18 +51,12 @@ jobs: with: distribution: 'temurin' java-version: 17 - - name: create-google services json - uses: jsdaniell/create-json@1.1.2 - with: - name: google-services.json - json: ${{ secrets.GOOGLE_SERVICES_JSON }} - dir: sample - - name: create local.properties - run: echo $ANDROID_HOME > local.properties + - name: Prepare CI + run: make prepare-ci - name: Build with Gradle - run: ./gradlew clean assembleAndroidTest -x lint + run: make build-test - name: upload sample app artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/on_push_workflow_new.yml b/.github/workflows/on_push_workflow_new.yml new file mode 100644 index 00000000..837d25f4 --- /dev/null +++ b/.github/workflows/on_push_workflow_new.yml @@ -0,0 +1,252 @@ +name: Last push build + +on: + workflow_dispatch: + +env: + 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_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 }} + 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@v4 + with: + ref: dev + submodules: true + fetch-depth: 0 # 0 indicates all history + + - name: set up JDK 1.17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Prepare CI + run: make prepare-ci + + - name: Build with Gradle + run: make build-test + + Test: + needs: Build + runs-on: ubuntu-latest + name: Test modules + strategy: + matrix: + include: + - module: core + - module: mobile-engage + - module: predict + - module: emarsys-firebase + - module: emarsys-huawei + - module: emarsys-sdk + steps: + - uses: actions/checkout@v4 + with: + ref: dev + submodules: true + fetch-depth: 0 # 0 indicates all history + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Prepare CI + run: make prepare-ci + + - name: Authenticate to Google Cloud + if: matrix.platform == 'android' + uses: google-github-actions/auth@v2.1.1 + with: + credentials_json: ${{ env.FIREBASE_SERVICE_ACCOUNT_JSON }} + + - name: Set up Cloud SDK + if: matrix.platform == 'android' + uses: google-github-actions/setup-gcloud@v2 + with: + project_id: ${{ env.FIREBASE_PROJECT_ID }} + + - name: create apks + run: make create-apks + + - name: test core + if: matrix.module == 'core' + run: make test-android-firebase MODULE_NAME=core + + - name: test mobile-engage + if: matrix.module == 'mobile-engage' + run: make test-android-firebase MODULE_NAME=mobile-engage + + - name: test predict + if: matrix.module == 'predict' + run: make test-android-firebase MODULE_NAME=predict + + - name: test emarsys-firebase + if: matrix.module == 'emarsys-firebase' + run: make test-android-firebase MODULE_NAME=emarsys-firebase + + - name: test emarsys-huawei + if: matrix.module == 'emarsys-huawei' + run: make test-android-firebase MODULE_NAME=emarsys-huawei + + - name: test emarsys-sdk + if: matrix.module == 'emarsys-sdk' + run: make test-android-firebase MODULE_NAME=emarsys-sdk + +# GradleLint: +# name: Run lint on project +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# submodules: true +# fetch-depth: 0 # 0 indicates all history +# - 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/create-json@1.1.2 +# with: +# name: google-services.json +# json: ${{ secrets.GOOGLE_SERVICES_JSON }} +# dir: sample +# +# - name: create local.properties +# run: echo $ANDROID_HOME > local.properties +# +# - name: Lint project with Gradle +# run: ./gradlew lint + +# CreateReleaseBundle: +# name: Create release bundle +# needs: Build +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# submodules: true +# fetch-depth: 0 # 0 indicates all history +# - 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/create-json@1.1.2 +# with: +# name: google-services.json +# json: ${{ secrets.GOOGLE_SERVICES_JSON }} +# dir: sample +# +# - name: create local.properties +# run: echo $ANDROID_HOME > local.properties +# +# - name: Create release keystore file +# shell: bash +# run: | +# echo "${{ secrets.ANDROID_KEYSTORE }}" > mobile-team-android.jks.asc +# gpg -d --passphrase "${{ secrets.ANDROID_GPG_PASSWORD }}" --batch mobile-team-android.jks.asc > sample/mobile-team-android.jks +# - name: Create release sample app with Gradle +# run: ./gradlew :sample:bundleRelease +# +# - name: Upload bundle +# uses: actions/upload-artifact@v2 +# with: +# name: mobile-sdk-sample +# path: sample/build/outputs/bundle/release/sample-release.aab + +# ReleaseSample: +# name: Release sample app +# runs-on: ubuntu-latest +# needs: [ Build, TestCore, TestMobileEngage, TestPredict, TestEmarsysSDK, TestEmarsys, TestCommon, TestEmarsysFirebase, TestEmarsysHuawei, CreateReleaseBundle, GradleLint ] +# 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 sample app +# uses: actions/download-artifact@v2 +# with: +# name: mobile-sdk-sample +# +# - name: create-google services json +# uses: jsdaniell/create-json@1.1.2 +# with: +# name: google-play-services.json +# json: ${{ secrets.GOOGLE_PLAY_STORE_SEVICE_ACCOUNT_JSON }} +# +# - name: Playstore upload +# uses: r0adkll/upload-google-play@v1.0.15 +# with: +# serviceAccountJson: google-play-services.json +# packageName: com.emarsys.sample +# releaseFile: sample-release.aab +# track: alpha +# +# SlackNotification: +# name: Send slack notification +# runs-on: ubuntu-latest +# needs: [ ReleaseSample ] +# steps: +# - name: Slack Notification +# uses: megamegax/slack_action@0.2.3 +# with: +# channel: '${{env.SLACK_CHANNEL}}' +# message: 'Last push build 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: [ ReleaseSample ] +# 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" +# +# - name: Slack Notification +# uses: megamegax/slack_action@0.2.3 +# with: +# channel: '${{env.SLACK_CHANNEL}}' +# message: 'Last push build 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/" }]' diff --git a/.github/workflows/on_tag_workflow.yml b/.github/workflows/on_tag_workflow.yml index cbd6a140..5cb2c7f9 100644 --- a/.github/workflows/on_tag_workflow.yml +++ b/.github/workflows/on_tag_workflow.yml @@ -11,7 +11,6 @@ env: 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: New SDK Release diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..a7f7d9d0 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +.PHONY: check-env help build-test create-apks prepare-ci run-github-workflow-locally test-android-firebase test-android-firebase-emulator +.DEFAULT_GOAL := help + +ifneq (,$(wildcard .env)) +include .env +export +endif + +REQUIRED_VARS := $(shell cat .env.example | sed 's/=.*//' | xargs) +check-env: + @MISSING_VARS=""; \ + for var in $(REQUIRED_VARS); do \ + if [ -z "$${!var+x}" ]; then \ + MISSING_VARS="$$MISSING_VARS $$var"; \ + fi; \ + done; \ + if [ -n "$$MISSING_VARS" ]; then \ + echo "Missing environment variables:$$MISSING_VARS"; \ + echo "Please set them in your .env file or as system environment variables. Check https://secret.emarsys.net/cred/detail/18243/"; \ + exit 1; \ + fi + +help: check-env ## Show this help + @echo "Targets:" + @fgrep -h "##" $(MAKEFILE_LIST) | grep ":" | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/\(.*\):.*##[ \t]*/ \1 ## /' | sort | column -t -s '##' + @echo + +build-test: check-env ## builds android tests excluding and lint + @./gradlew clean assembleAndroidTest -x lint -x + +create-apks: check-env ## create apks for testing + @./gradlew assembleAndroidTest -x :sample:test + +prepare-ci: check-env ## setup prerequisites for pipeline + @chmod +x gradlew + @echo $ANDROID_HOME > local.properties + @./gradlew base64EnvToFile -PpropertyName=GOOGLE_SERVICES_JSON_BASE64 -Pfile=./sample/google-services.json + +test-android-firebase-emulator: check-env ## run Android Instrumented tests on emulators on Firebase Test Lab + @gcloud firebase test android run \ + --type instrumentation \ + --app ./sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk \ + --test ./$(MODULE_NAME)/build/outputs/apk/androidTest/debug/$(MODULE_NAME)-debug-androidTest.apk \ + --device model=Nexus5X,version=24,locale=en,orientation=portrait \ + --device model=Pixel2,version=30,locale=en,orientation=portrait \ + --device model=SmallPhone,version=33,locale=en,orientation=portrait \ + --client-details matrixLabel="Android Emarsys SDK" + +test-android-firebase: check-env ## run Android Instrumented tests on real devices on Firebase Test Lab + @gcloud firebase test android run \ + --type instrumentation \ + --app ./sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk \ + --test ./$(MODULE_NAME)/build/outputs/apk/androidTest/debug/$(MODULE_NAME)-debug-androidTest.apk \ + --device model=f2q,version=30,locale=en,orientation=portrait \ + --device model=a51,version=31,locale=en,orientation=portrait \ + --device model=bluejay,version=32,locale=en,orientation=portrait \ + --device model=b4q,version=33,locale=en,orientation=portrait \ + --client-details matrixLabel="Unified SDK" + +run-github-workflow-locally: check-env ## needs act to be installed: `brew install act` and docker running. Pass in workflow path to run + @act --secret-file ./workflow.secrets -W $(WORKFLOW_PATH) --container-architecture linux/amd64