Skip to content

Commit 5a683bf

Browse files
authored
Migrate to turborepo (#2608)
1 parent a53ed23 commit 5a683bf

File tree

9 files changed

+349
-135
lines changed

9 files changed

+349
-135
lines changed

.github/workflows/ci.yml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
merge_group:
10+
types:
11+
- checks_requested
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
22+
- name: Setup
23+
uses: ./.github/actions/setup
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Clang Format
28+
working-directory: packages/skia
29+
run: yarn clang-format
30+
31+
- name: Lint files
32+
run: yarn lint
33+
34+
- name: Typecheck files
35+
run: yarn tsc
36+
37+
test:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v3
42+
with:
43+
submodules: recursive
44+
45+
- name: Setup
46+
uses: ./.github/actions/setup
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Test
51+
run: yarn test
52+
53+
build-library:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v3
58+
with:
59+
submodules: recursive
60+
61+
- name: Setup
62+
uses: ./.github/actions/setup
63+
with:
64+
github_token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Build package
67+
run: yarn build
68+
69+
build-android:
70+
runs-on: macos-latest-large
71+
continue-on-error: true
72+
env:
73+
TURBO_CACHE_DIR: .turbo/android
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v3
77+
with:
78+
submodules: recursive
79+
80+
- name: Setup
81+
uses: ./.github/actions/setup
82+
with:
83+
github_token: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Cache turborepo for Android
86+
uses: actions/cache@v3
87+
with:
88+
path: ${{ env.TURBO_CACHE_DIR }}
89+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
90+
restore-keys: |
91+
${{ runner.os }}-turborepo-android
92+
93+
- name: Check turborepo cache for Android
94+
run: |
95+
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")
96+
97+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
98+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
99+
fi
100+
101+
- name: Install JDK
102+
if: env.turbo_cache_hit != 1
103+
uses: actions/setup-java@v3
104+
with:
105+
distribution: 'zulu'
106+
java-version: '17'
107+
108+
- name: Install NDK
109+
if: env.turbo_cache_hit != 1
110+
uses: nttld/setup-ndk@v1
111+
id: setup-ndk
112+
with:
113+
ndk-version: r26d
114+
115+
- name: Set ANDROID_NDK
116+
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
117+
118+
- name: Finalize Android SDK
119+
if: env.turbo_cache_hit != 1
120+
run: |
121+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
122+
123+
- name: Install Android SDK
124+
run: |
125+
echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/paper/android/local.properties
126+
echo "sdk.dir=$ANDROID_HOME" > $GITHUB_WORKSPACE/apps/fabric/android/local.properties
127+
128+
- name: Cache Gradle
129+
if: env.turbo_cache_hit != 1
130+
uses: actions/cache@v3
131+
with:
132+
path: |
133+
~/.gradle/wrapper
134+
~/.gradle/caches
135+
key: ${{ runner.os }}-gradle-${{ hashFiles('./apps/paper/android/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('./apps/fabric/android/gradle/wrapper/gradle-wrapper.properties') }}
136+
restore-keys: |
137+
${{ runner.os }}-gradle-
138+
139+
- name: Build example for Android
140+
env:
141+
JAVA_OPTS: "-XX:MaxHeapSize=6g"
142+
run: |
143+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --concurrency 1
144+
145+
build-ios:
146+
runs-on: macos-latest-large
147+
env:
148+
TURBO_CACHE_DIR: .turbo/ios
149+
steps:
150+
- name: Checkout
151+
uses: actions/checkout@v3
152+
with:
153+
submodules: recursive
154+
155+
- name: Setup
156+
uses: ./.github/actions/setup
157+
with:
158+
github_token: ${{ secrets.GITHUB_TOKEN }}
159+
160+
- name: Cache turborepo for iOS
161+
uses: actions/cache@v3
162+
with:
163+
path: ${{ env.TURBO_CACHE_DIR }}
164+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
165+
restore-keys: |
166+
${{ runner.os }}-turborepo-ios-
167+
168+
- name: Check turborepo cache for iOS
169+
run: |
170+
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")
171+
172+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
173+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
174+
fi
175+
176+
- name: Cache cocoapods
177+
if: env.turbo_cache_hit != 1
178+
id: cocoapods-cache
179+
uses: actions/cache@v3
180+
with:
181+
path: |
182+
**/ios/Pods
183+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('./apps/paper/ios/Podfile.lock') }}
184+
restore-keys: |
185+
${{ runner.os }}-cocoapods-
186+
187+
- name: Install cocoapods
188+
run: |
189+
cd apps/paper/ios
190+
pod install
191+
cd ../../fabric/ios
192+
pod install
193+
env:
194+
NO_FLIPPER: 1
195+
196+
- name: Build example for iOS
197+
run: |
198+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.github/workflows/ios-build.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.turbo
2+
13
# Yarn
24
.yarn/*
35
!.yarn/patches

apps/fabric/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"android": "react-native run-android",
88
"ios": "react-native run-ios",
99
"start": "react-native start",
10-
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest"
10+
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest",
11+
"tsc": "tsc --noEmit",
12+
"build:android": "cd android && ./gradlew assembleDebug --warning-mode all",
13+
"build:ios": "npm run mkdist && react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist && react-native build-ios --scheme fabric --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\"",
14+
"mkdist": "node -e \"require('node:fs').mkdirSync('dist', { recursive: true, mode: 0o755 })\""
1115
},
1216
"dependencies": {
1317
"@react-native-community/slider": "^4.5.2",

apps/paper/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"android": "react-native run-android",
88
"ios": "react-native run-ios",
99
"start": "react-native start",
10-
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest"
10+
"test": "node --experimental-vm-modules ../../node_modules/.bin/jest",
11+
"tsc": "tsc --noEmit",
12+
"build:android": "cd android && ./gradlew assembleDebug --warning-mode all",
13+
"build:ios": "npm run mkdist && react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist && react-native build-ios --scheme paper --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\"",
14+
"mkdist": "node -e \"require('node:fs').mkdirSync('dist', { recursive: true, mode: 0o755 })\""
1115
},
1216
"dependencies": {
1317
"@react-native-community/slider": "^4.5.2",

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,16 @@
2020
"packages/*",
2121
"apps/*"
2222
],
23-
"packageManager": "[email protected]"
23+
"scripts": {
24+
"lint": "turbo run lint",
25+
"tsc": "turbo run tsc",
26+
"test": "turbo run test",
27+
"build": "turbo run build",
28+
"build:ios": "turbo run build:ios",
29+
"build:android": "turbo run build:android"
30+
},
31+
"packageManager": "[email protected]",
32+
"devDependencies": {
33+
"turbo": "^2.1.1"
34+
}
2435
}

0 commit comments

Comments
 (0)