Skip to content

Commit

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

Co-authored-by: LasOri <[email protected]>
Co-authored-by: megamegax <[email protected]>
  • Loading branch information
3 people committed Feb 22, 2024
1 parent 4fef9df commit 62c130a
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/nightly_e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nightly_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/on_push_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,18 +51,12 @@ jobs:
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: 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
Expand Down
252 changes: 252 additions & 0 deletions .github/workflows/on_push_workflow_new.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[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: 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/[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: 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/[email protected]
# with:
# name: google-play-services.json
# json: ${{ secrets.GOOGLE_PLAY_STORE_SEVICE_ACCOUNT_JSON }}
#
# - name: Playstore upload
# uses: r0adkll/[email protected]
# 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/[email protected]
# 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/[email protected]
# 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/" }]'
1 change: 0 additions & 1 deletion .github/workflows/on_tag_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 62c130a

Please sign in to comment.