diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 6f0b2424..46d7e029 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -22,6 +22,6 @@ runs: ${{ runner.os }}-yarn-ng- - name: Install dependencies - run: | - yarn install --immutable + if: steps.yarn-cache.outputs.cache-hit != 'true' + run: yarn install --immutable shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba914e58..4441fc76 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,12 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: Modify APP ID + run: | + sed "s/localAppId = '\(.*\)'/localAppId = '${{ secrets.APP_ID }}'/g" agora.config.ts > tmp + mv tmp agora.config.ts + working-directory: example/src/config + - name: Build example for Android run: | yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddb8d6c5..f6fa214e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: newArch: [ true, false ] runs-on: macos-latest env: - NITRO_API_KEY: ${{ secrets.NITRO_API_KEY }} + TURBO_CACHE_DIR: .turbo/android ORG_GRADLE_PROJECT_newArchEnabled: ${{ matrix.newArch }} steps: - name: Checkout @@ -70,6 +70,45 @@ jobs: - 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: '11' + + - 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: Install Detox dependencies shell: bash run: | @@ -81,13 +120,9 @@ jobs: mv tmp agora.config.ts working-directory: example/src/config - - uses: nitro-build/github-action-nitro-android@v1 - id: nitro - with: - debug: true - detox-configuration: android.emu.release - root-directory: example - cache-env-var-lookup-keys: ORG_GRADLE_PROJECT_* + - name: Build example for Android + run: | + yarn turbo run detox:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" - name: Run e2e tests if: ${{ matrix.newArch == false }} @@ -105,7 +140,7 @@ jobs: newArch: [ 1, 0 ] runs-on: macos-latest env: - NITRO_API_KEY: ${{ secrets.NITRO_API_KEY }} + TURBO_CACHE_DIR: .turbo/ios RCT_NEW_ARCH_ENABLED: ${{ matrix.newArch }} steps: - name: Checkout @@ -114,6 +149,40 @@ jobs: - 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: | + yarn pod-install example/ios + env: + NO_FLIPPER: 1 + - name: Install Detox dependencies shell: bash run: | @@ -127,13 +196,9 @@ jobs: mv tmp agora.config.ts working-directory: example/src/config - - uses: nitro-build/github-action-nitro-ios@v1 - id: nitro - with: - debug: true - detox-configuration: ios.sim.release - root-directory: example - cache-env-var-lookup-keys: RCT_NEW_ARCH_ENABLED + - name: Build example for iOS + run: | + yarn turbo run detox:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" - uses: futureware-tech/simulator-action@v1 with: diff --git a/example/package.json b/example/package.json index e9183a07..cfea7948 100644 --- a/example/package.json +++ b/example/package.json @@ -7,7 +7,9 @@ "ios": "react-native run-ios", "start": "react-native start", "build:android": "cd android && ./gradlew assembleRelease --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a", - "build:ios": "cd ios && xcodebuild -workspace AgoraRtcNgExample.xcworkspace -scheme AgoraRtcNgExample -configuration Release -sdk iphoneos CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO" + "build:ios": "cd ios && xcodebuild -workspace AgoraRtcNgExample.xcworkspace -scheme AgoraRtcNgExample -configuration Release -sdk iphoneos CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO", + "detex:android": "detox build --configuration android.emu.release", + "detex:ios": "detox build --configuration ios.sim.release" }, "dependencies": { "@react-native-community/slider": "^4.4.2",