CMP-4885: minor improvements #234
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: Test | |
on: | |
push: | |
branches: | |
- "**" | |
- "!main" # Prevent when pushing on main | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
js: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Node dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm install | |
- name: Run JS tests | |
run: npm test | |
android: | |
needs: js | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Node dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install bob | |
run: npm install -g react-native-builder-bob | |
- name: Install dependencies | |
run: npm install | |
- name: Cache Gradle Wrapper | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
- name: Cache Gradle Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-caches- | |
- name: Make Gradlew Executable | |
run: cd android && chmod +x ./gradlew | |
- name: Build Android App | |
run: | | |
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ | |
cd android && ./gradlew assembleDebug --no-daemon | |
- name: Upload Android App APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-debug.apk | |
path: test/android/app/build/outputs/apk/debug/app-debug.apk | |
- name: Build Android Test | |
run: | | |
cd android && ./gradlew :app:assembleDebugAndroidTest --no-daemon | |
- name: Upload Android Test APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-debug-androidTest.apk | |
path: test/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk | |
# Authenticate Cloud SDK | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Setup Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.FIREBASE_PROJECT_ID }} | |
install_components: 'beta' | |
- name: Run Instrumentation Tests in Firebase Test Lab | |
run: | | |
gcloud beta firebase test android run \ | |
--type=instrumentation \ | |
--app=android/app/build/outputs/apk/debug/app-debug.apk \ | |
--test=android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ | |
--device="model=MediumPhone.arm,version=34,locale=en,orientation=portrait" \ | |
--test-targets="package io.didomi.reactnative.test" \ | |
--results-history-name="${{ github.ref_name }}" \ | |
--num-flaky-test-attempts=3 \ | |
--num-uniform-shards=3 \ | |
--use-orchestrator \ | |
--quiet | |
ios: | |
needs: js | |
runs-on: macos-14 | |
defaults: | |
run: | |
working-directory: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Cache Node dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install bob | |
run: npm install -g react-native-builder-bob | |
- name: Install dependencies | |
run: npm install | |
- name: Install pods | |
run: cd ios && pod install | |
- name: Run iOS Tests | |
run: | | |
npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets | |
cd ios && TEST=1 && RCT_NO_LAUNCH_PACKAGER=1 xcodebuild \ | |
-workspace "Didomi Tests.xcworkspace" \ | |
-scheme "Didomi Tests" \ | |
-sdk iphonesimulator \ | |
-destination "platform=iOS Simulator,name=iPhone 15" \ | |
clean test |