From 381771bc7bf9b440f6148ea1bea3108ef5adb05b Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sat, 27 Apr 2024 01:18:22 +0900 Subject: [PATCH] ci: bring my ci!!! --- .github/actions/setup/action.yml | 2 +- .github/workflows/ci.yml | 53 +++++++++++++++++++------------- .gitignore | 4 ++- package.json | 6 +++- script/ci-android-build.sh | 3 ++ script/ci-ios-build.sh | 3 ++ turbo.json | 33 ++++++++++++++++++-- 7 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 script/ci-android-build.sh create mode 100644 script/ci-ios-build.sh diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 17f830c..2574d7a 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -11,7 +11,7 @@ runs: - name: Cache dependencies id: yarn-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | **/node_modules diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b16ed8..ddec1a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,11 @@ jobs: build-android: runs-on: ubuntu-latest + strategy: + matrix: + arch: [ old, new ] env: - TURBO_CACHE_DIR: .turbo/android + TURBO_CACHE_DIR: .turbo/android-${{matrix.arch}} steps: - name: Checkout uses: actions/checkout@v4 @@ -66,17 +69,20 @@ jobs: - name: Setup uses: ./.github/actions/setup + - name: Convert Arch + run: yarn ${{matrix.arch}} + - name: Cache turborepo for Android uses: actions/cache@v4 with: path: ${{ env.TURBO_CACHE_DIR }} - key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}-${{matrix.arch}} restore-keys: | - ${{ runner.os }}-turborepo-android- + ${{ runner.os }}-turborepo-android-${{matrix.arch}}- - 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") + TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run ci:android:build:${{matrix.arch}} --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'ci:android:build:${{matrix.arch}}').cache.status") if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then echo "turbo_cache_hit=1" >> $GITHUB_ENV @@ -96,43 +102,49 @@ jobs: - name: Cache Gradle if: env.turbo_cache_hit != 1 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/wrapper ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}-${{matrix.arch}} restore-keys: | - ${{ runner.os }}-gradle- + ${{ runner.os }}-gradle-${{matrix.arch}}- - name: Build example for Android env: JAVA_OPTS: "-XX:MaxHeapSize=6g" run: | - yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" + yarn turbo run ci:android:build:${{matrix.arch}} --cache-dir="${{ env.TURBO_CACHE_DIR }}" build-ios: runs-on: macos-latest + strategy: + matrix: + arch: [ old, new ] env: - TURBO_CACHE_DIR: .turbo/ios + TURBO_CACHE_DIR: .turbo/ios-${{matrix.arch}} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup + - name: Convert Arch + run: yarn ${{matrix.arch}} + - name: Cache turborepo for iOS - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.TURBO_CACHE_DIR }} - key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }} + key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}-${{matrix.arch}} restore-keys: | - ${{ runner.os }}-turborepo-ios- + ${{ runner.os }}-turborepo-ios-${{matrix.arch}}- - 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") + TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run ci:ios:build:${{matrix.arch}} --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'ci:ios:build:${{matrix.arch}}').cache.status") if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then echo "turbo_cache_hit=1" >> $GITHUB_ENV @@ -141,23 +153,20 @@ jobs: - name: Cache cocoapods if: env.turbo_cache_hit != 1 id: cocoapods-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | **/ios/Pods - key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }} + key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}-${{matrix.arch}} restore-keys: | - ${{ runner.os }}-cocoapods- + ${{ runner.os }}-cocoapods-${{matrix.arch}}- - name: Install cocoapods if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' - run: | - cd example/ios - bundle exec pod install + run: yarn pod:${{matrix.arch}} env: NO_FLIPPER: 1 - RCT_NEW_ARCH_ENABLED: 1 - name: Build example for iOS run: | - yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" + yarn turbo run ci:ios:build:${{matrix.arch}} --cache-dir="${{ env.TURBO_CACHE_DIR }}" diff --git a/.gitignore b/.gitignore index 7903c1e..8cc4d74 100644 --- a/.gitignore +++ b/.gitignore @@ -113,4 +113,6 @@ example/ios/ !packages/*/android/ !packages/*/ios/ -example/.watchman-cookie-* \ No newline at end of file +example/.watchman-cookie-* + +.turbo diff --git a/package.json b/package.json index 45e4d8b..6e085b7 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,11 @@ "codegen:android": "cd example/android && ./gradlew generateCodegenArtifactsFromSchema", "codegen:ios": "node node_modules/react-native/scripts/generate-codegen-artifacts.js --path example/ --outputPath example/ios", "codegen": "yarn codegen:android && yarn codegen:ios", - "watchman-refresh": "watchman watch-del $(pwd) ; watchman watch-project $(pwd)" + "watchman-refresh": "watchman watch-del $(pwd) ; watchman watch-project $(pwd)", + "ci:android:build:new": "script/ci-android-build.sh", + "ci:android:build:old": "script/ci-android-build.sh", + "ci:ios:build:new": "script/ci-ios-build.sh", + "ci:ios:build:old": "script/ci-ios-build.sh" }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", diff --git a/script/ci-android-build.sh b/script/ci-android-build.sh new file mode 100644 index 0000000..51650f1 --- /dev/null +++ b/script/ci-android-build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a diff --git a/script/ci-ios-build.sh b/script/ci-ios-build.sh new file mode 100644 index 0000000..6d0a32c --- /dev/null +++ b/script/ci-ios-build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cd example/ios && xcodebuild -workspace KakaoExample.xcworkspace -scheme KakaoExample -configuration Debug -sdk iphonesimulator 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 diff --git a/turbo.json b/turbo.json index 331e289..c8b32a0 100644 --- a/turbo.json +++ b/turbo.json @@ -1,7 +1,7 @@ { "$schema": "https://turbo.build/schema.json", "pipeline": { - "build:android": { + "ci:android:build:new": { "inputs": [ "package.json", "android", @@ -16,7 +16,36 @@ ], "outputs": [] }, - "build:ios": { + "ci:android:build:old": { + "inputs": [ + "package.json", + "android", + "!android/build", + "src/*.ts", + "src/*.tsx", + "example/package.json", + "example/android", + "!example/android/.gradle", + "!example/android/build", + "!example/android/app/build" + ], + "outputs": [] + }, + "ci:ios:build:new": { + "inputs": [ + "package.json", + "*.podspec", + "ios", + "src/*.ts", + "src/*.tsx", + "example/package.json", + "example/ios", + "!example/ios/build", + "!example/ios/Pods" + ], + "outputs": [] + }, + "ci:ios:build:old": { "inputs": [ "package.json", "*.podspec",