From b1ecd6f97e7a3a9a3201f6b35ac368e97bc0591a Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Tue, 15 Oct 2024 14:52:49 -0500 Subject: [PATCH] Add `build-macos` to CI --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ apps/example/package.json | 4 +++- package.json | 1 + turbo.json | 28 +++++++++++++++++++++++++--- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1296580f..d5b562b16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,3 +164,36 @@ jobs: - name: Build example for iOS run: | yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" + + build-macos: + runs-on: macos-latest + env: + TURBO_CACHE_DIR: .turbo/macos + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache turborepo for macOS + uses: actions/cache@v3 + with: + path: ${{ env.TURBO_CACHE_DIR }} + key: ${{ runner.os }}-turborepo-macos-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-turborepo-macos- + + - name: Check turborepo cache for macOS + run: | + TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:macos --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:macos').cache.status") + + if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then + echo "turbo_cache_hit=1" >> $GITHUB_ENV + fi + + - name: Build example for macOS + run: | + yarn turbo run build:macos --cache-dir="${{ env.TURBO_CACHE_DIR }}" diff --git a/apps/example/package.json b/apps/example/package.json index c5a33bfdc..0d3563805 100644 --- a/apps/example/package.json +++ b/apps/example/package.json @@ -8,9 +8,11 @@ "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", - "pod:install": "pod install --project-directory=ios", + "pod:install:ios": "pod install --project-directory=ios", + "pod:install:macos": "pod install --project-directory=macos", "build:android": "cd android && ./gradlew assembleDebug --warning-mode all", "build:ios": "react-native build-ios --scheme Example --mode Debug --extra-params \"-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\"", + "build:macos": "react-native build-macos --scheme Example --mode Debug --extra-params \"-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\"", "mkdist": "node -e \"require('node:fs').mkdirSync('dist', { recursive: true, mode: 0o755 })\"" }, "dependencies": { diff --git a/package.json b/package.json index 0fc7d581e..1b3829df7 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lint": "turbo run lint", "tsc": "turbo run tsc", "build:ios": "turbo run build:ios", + "build:macos": "turbo run build:macos", "build:android": "turbo run build:android", "build": "turbo run build", "pod:install": "turbo run pod:install" diff --git a/turbo.json b/turbo.json index b11717250..852ee62d4 100644 --- a/turbo.json +++ b/turbo.json @@ -25,7 +25,7 @@ ] }, "build:ios": { - "dependsOn": ["pod:install"], + "dependsOn": ["pod:install:ios"], "outputs": [ "apps/*/ios/build", "apps/*/ios/Pods" @@ -34,14 +34,36 @@ "**/package.json", "**/*.podspec", "packages/webgpu/cpp/**", - "packages/webgpu/ios/**", + "packages/webgpu/apple/**", "apps/*/package.json", "apps/*/ios", "!apps/*/ios/build", "!apps/*/ios/Pods" ] }, - "pod:install": { + "build:macos": { + "dependsOn": ["pod:install:macos"], + "outputs": [ + "apps/*/macos/build", + "apps/*/macos/Pods" + ], + "inputs": [ + "**/package.json", + "**/*.podspec", + "packages/webgpu/cpp/**", + "packages/webgpu/apple/**", + "apps/*/package.json", + "apps/*/macos", + "!apps/*/macos/build", + "!apps/*/macos/Pods" + ] + }, + "pod:install:ios": { + "cache": false, + "inputs": ["**/ios/Podfile", "**/ios/Podfile.lock"], + "outputs": ["**/ios/Pods/**"] + }, + "pod:install:macos": { "cache": false, "inputs": ["**/ios/Podfile", "**/ios/Podfile.lock"], "outputs": ["**/ios/Pods/**"]