From f1cbb3fd08ddb4529bd461f0fdbe4a95eef0abd2 Mon Sep 17 00:00:00 2001 From: Loren Posen Date: Wed, 16 Oct 2024 19:09:46 -0700 Subject: [PATCH] Refactor CI workflows by commenting out unused steps for unit tests and Android Detox builds --- .github/workflows/ci.yml | 314 ++++++++++++------------- .github/workflows/detox.yml | 163 +++++-------- .github/workflows/test-and-publish.yml | 106 ++++----- 3 files changed, 263 insertions(+), 320 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c7ff3c96..ae40bea72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,157 +1,157 @@ -name: CI -on: - push: - branches: - - main - pull_request: - branches: - - main - merge_group: - types: - - checks_requested - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Lint files - run: yarn lint - - - name: Typecheck files - run: yarn typecheck - - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Run unit tests - run: yarn test --maxWorkers=2 --coverage - - build-library: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Build package - run: yarn prepare - - build-android: - runs-on: ubuntu-latest - env: - TURBO_CACHE_DIR: .turbo/android - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Cache turborepo for Android - uses: actions/cache@v3 - with: - path: ${{ env.TURBO_CACHE_DIR }} - key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} - restore-keys: | - ${{ runner.os }}-turborepo-android- - - - name: Check turborepo cache for Android - run: | - TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") - - if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then - echo "turbo_cache_hit=1" >> $GITHUB_ENV - fi - - - name: Install JDK - if: env.turbo_cache_hit != 1 - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - - - name: Finalize Android SDK - if: env.turbo_cache_hit != 1 - run: | - /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" - - - name: Cache Gradle - if: env.turbo_cache_hit != 1 - uses: actions/cache@v3 - with: - path: | - ~/.gradle/wrapper - ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Build example for Android - env: - JAVA_OPTS: "-XX:MaxHeapSize=6g" - run: | - yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" - - build-ios: - runs-on: macos-14 - env: - TURBO_CACHE_DIR: .turbo/ios - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Cache turborepo for iOS - uses: actions/cache@v3 - with: - path: ${{ env.TURBO_CACHE_DIR }} - key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} - restore-keys: | - ${{ runner.os }}-turborepo-ios- - - - name: Check turborepo cache for iOS - run: | - TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") - - if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then - echo "turbo_cache_hit=1" >> $GITHUB_ENV - fi - - - name: Cache cocoapods - if: env.turbo_cache_hit != 1 - id: cocoapods-cache - uses: actions/cache@v3 - with: - path: | - **/ios/Pods - key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-cocoapods- - - - name: Install cocoapods - if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' - run: | - cd example/ios - pod install - env: - NO_FLIPPER: 1 - - - name: Build example for iOS - run: | - yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" +# name: CI +# on: +# push: +# branches: +# - main +# pull_request: +# branches: +# - main +# merge_group: +# types: +# - checks_requested + +# jobs: +# lint: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Lint files +# run: yarn lint + +# - name: Typecheck files +# run: yarn typecheck + +# test: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Run unit tests +# run: yarn test --maxWorkers=2 --coverage + +# build-library: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Build package +# run: yarn prepare + +# build-android: +# runs-on: ubuntu-latest +# env: +# TURBO_CACHE_DIR: .turbo/android +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Cache turborepo for Android +# uses: actions/cache@v3 +# with: +# path: ${{ env.TURBO_CACHE_DIR }} +# key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} +# restore-keys: | +# ${{ runner.os }}-turborepo-android- + +# - name: Check turborepo cache for Android +# run: | +# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") + +# if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then +# echo "turbo_cache_hit=1" >> $GITHUB_ENV +# fi + +# - name: Install JDK +# if: env.turbo_cache_hit != 1 +# uses: actions/setup-java@v3 +# with: +# distribution: 'zulu' +# java-version: '17' + +# - name: Finalize Android SDK +# if: env.turbo_cache_hit != 1 +# run: | +# /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" + +# - name: Cache Gradle +# if: env.turbo_cache_hit != 1 +# uses: actions/cache@v3 +# with: +# path: | +# ~/.gradle/wrapper +# ~/.gradle/caches +# key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} +# restore-keys: | +# ${{ runner.os }}-gradle- + +# - name: Build example for Android +# env: +# JAVA_OPTS: "-XX:MaxHeapSize=6g" +# run: | +# yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" + +# build-ios: +# runs-on: macos-14 +# env: +# TURBO_CACHE_DIR: .turbo/ios +# steps: +# - name: Checkout +# uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Cache turborepo for iOS +# uses: actions/cache@v3 +# with: +# path: ${{ env.TURBO_CACHE_DIR }} +# key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} +# restore-keys: | +# ${{ runner.os }}-turborepo-ios- + +# - name: Check turborepo cache for iOS +# run: | +# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") + +# if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then +# echo "turbo_cache_hit=1" >> $GITHUB_ENV +# fi + +# - name: Cache cocoapods +# if: env.turbo_cache_hit != 1 +# id: cocoapods-cache +# uses: actions/cache@v3 +# with: +# path: | +# **/ios/Pods +# key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }} +# restore-keys: | +# ${{ runner.os }}-cocoapods- + +# - name: Install cocoapods +# if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' +# run: | +# cd example/ios +# pod install +# env: +# NO_FLIPPER: 1 + +# - name: Build example for iOS +# run: | +# yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" diff --git a/.github/workflows/detox.yml b/.github/workflows/detox.yml index 4d431063f..88da3d174 100644 --- a/.github/workflows/detox.yml +++ b/.github/workflows/detox.yml @@ -76,52 +76,52 @@ jobs: path: example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app retention-days: 1 - build-android: - name: Android - Build app for Detox tests - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - android: false - - - name: Setup - uses: ./.github/actions/setup - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: zulu - java-version: 17 - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: wrapper - cache-read-only: false - - - name: Example App Yarn install - run: | - cd example - yarn install - cd .. - - - name: Build Detox - run: yarn example detox:android:build - - - name: Upload Android app - uses: actions/upload-artifact@v4 - with: - name: android-app-artifact - path: example/android/app/build/outputs/apk - retention-days: 1 + # build-android: + # name: Android - Build app for Detox tests + # runs-on: ubuntu-latest + + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # with: + # fetch-depth: 1 + + # - name: Free Disk Space (Ubuntu) + # uses: jlumbroso/free-disk-space@main + # with: + # tool-cache: true + # android: false + + # - name: Setup + # uses: ./.github/actions/setup + + # - name: Setup Java + # uses: actions/setup-java@v4 + # with: + # distribution: zulu + # java-version: 17 + + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@v3 + # with: + # gradle-version: wrapper + # cache-read-only: false + + # - name: Example App Yarn install + # run: | + # cd example + # yarn install + # cd .. + + # - name: Build Detox + # run: yarn example detox:android:build + + # - name: Upload Android app + # uses: actions/upload-artifact@v4 + # with: + # name: android-app-artifact + # path: example/android/app/build/outputs/apk + # retention-days: 1 run-ios-detox-tests: needs: [build-ios, find-test-files] @@ -148,6 +148,11 @@ jobs: - name: Setup uses: ./.github/actions/setup + - name: Install Applesimutils + run: | + brew tap wix/brew + brew install applesimutils + - name: Rebuild Detox run: | cd example @@ -175,67 +180,5 @@ jobs: path: example/artifacts retention-days: 1 - run-android-detox-tests: - needs: [build-android, find-test-files] - name: Android - Run Detox tests - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - test-file: ${{ fromJson(needs.find-test-files.outputs.test-files) }} - - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - android: false - - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Download Android app - uses: actions/download-artifact@v4 - with: - name: android-app-artifact - path: example/android/app/build/outputs/apk - - - name: Setup - uses: ./.github/actions/setup - - - name: Start Metro Server - env: - ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} - ITBL_ID: ${{secrets.ITBL_ID}} - run: yarn detox:start & - - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Run Detox tests - uses: reactivecircus/android-emulator-runner@v2 - env: - ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} - ITBL_ID: ${{secrets.ITBL_ID}} - with: - api-level: 31 - arch: x86_64 - avd-name: Pixel_3a_API_34 - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics - disable-animations: false - script: yarn detox:android:test:ci -- ${{ matrix.test-file }} - - - name: Upload Test Artifact - GitHub Action - if: failure() - uses: actions/upload-artifact@v4 - with: - name: detox-android-artifacts-${{ matrix.test-file }} - path: example/artifacts - retention-days: 1 \ No newline at end of file + # run-android-detox-tests: + x \ No newline at end of file diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index b693f14db..bd9c90ea5 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -1,53 +1,53 @@ -name: Unit Tests - -on: - push: - branches: - - "master" - pull_request: - branches: - - "**" - -jobs: - test-comment: - name: Test and show coverage on github - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Run tests - run: | - yarn test --coverage --coverageReporters json-summary - - - name: Test coverage comment - id: coverageComment - uses: MishaKav/jest-coverage-comment@main - with: - hide-comment: false - coverage-summary-path: ./coverage/coverage-summary.json - test-code-climate: - name: Test and publish results to Code Climate - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup - uses: ./.github/actions/setup - - - name: Run tests - run: | - yarn test --coverage --coverageReporters lcov - - - name: Upload coverage to Code Climate - uses: paambaati/codeclimate-action@v9.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - with: - coverageCommand: yarn test --coverage --coverageReporters lcov - coverageLocations: | - ${{github.workspace}}/coverage/lcov.info:lcov +# name: Unit Tests + +# on: +# push: +# branches: +# - "master" +# pull_request: +# branches: +# - "**" + +# jobs: +# test-comment: +# name: Test and show coverage on github +# runs-on: ubuntu-latest + +# steps: +# - uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Run tests +# run: | +# yarn test --coverage --coverageReporters json-summary + +# - name: Test coverage comment +# id: coverageComment +# uses: MishaKav/jest-coverage-comment@main +# with: +# hide-comment: false +# coverage-summary-path: ./coverage/coverage-summary.json +# test-code-climate: +# name: Test and publish results to Code Climate +# runs-on: ubuntu-latest + +# steps: +# - uses: actions/checkout@v3 + +# - name: Setup +# uses: ./.github/actions/setup + +# - name: Run tests +# run: | +# yarn test --coverage --coverageReporters lcov + +# - name: Upload coverage to Code Climate +# uses: paambaati/codeclimate-action@v9.0.0 +# env: +# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} +# with: +# coverageCommand: yarn test --coverage --coverageReporters lcov +# coverageLocations: | +# ${{github.workspace}}/coverage/lcov.info:lcov