Skip to content

Commit

Permalink
ci: bring my ci!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed Apr 26, 2024
1 parent ee67859 commit 381771b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
**/node_modules
Expand Down
53 changes: 31 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,32 @@ 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

- 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
Expand All @@ -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
Expand All @@ -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 }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ example/ios/
!packages/*/android/
!packages/*/ios/

example/.watchman-cookie-*
example/.watchman-cookie-*

.turbo
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions script/ci-android-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a
3 changes: 3 additions & 0 deletions script/ci-ios-build.sh
Original file line number Diff line number Diff line change
@@ -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
33 changes: 31 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build:android": {
"ci:android:build:new": {
"inputs": [
"package.json",
"android",
Expand All @@ -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",
Expand Down

0 comments on commit 381771b

Please sign in to comment.