Skip to content

chore: nitro modules ci fails #1127

chore: nitro modules ci fails

chore: nitro modules ci fails #1127

name: Build template
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
- next
paths:
- '.github/workflows/build-templates.yml'
- 'packages/create-react-native-library/**'
- '!**.md'
pull_request:
branches:
- main
- next
merge_group:
types:
- checks_requested
jobs:
build:
env:
XCODE_VERSION: 16.2
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
type:
- name: turbo-module
language: kotlin-objc
- name: fabric-view
language: kotlin-objc
- name: nitro-module
language: kotlin-swift
include:
- os: ubuntu
type.name: library
type.language: js
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}
cancel-in-progress: true
runs-on: ${{ matrix.os }}-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Build package
run: |
yarn workspace create-react-native-library prepare
- name: Get working directory
run: |
echo "work_dir=${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}" >> $GITHUB_ENV
- name: Create library
run: |
rm -rf ${{ env.work_dir }} # Workaround for tests failing intermittently
args=(
--slug @bob/react-native-test
--description test
--author-name test
--author-email test@test
--author-url https://test.test
--repo-url https://test.test
--type ${{ matrix.type.name }}
--languages ${{ matrix.type.language }}
--example ${{ matrix.type.language == 'js' && 'expo' || 'vanilla' }}
)
if [[ ${{ github.event_name }} == 'schedule' ]]; then
args+=(
--react-native-version latest
)
fi
./packages/create-react-native-library/bin/create-react-native-library ${{ env.work_dir }} ${args[@]}
- name: Restore dependencies of library
id: library-yarn-cache
uses: actions/cache/restore@v4
with:
path: |
${{ env.work_dir }}/**/node_modules
${{ env.work_dir }}/yarn.lock
key: ${{ runner.os }}-library-yarn-${{ hashFiles(format('{0}/**/package.json', env.work_dir), format('!{0}/node_modules/**', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-library-yarn-
- name: Install dependencies of library
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
working-directory: ${{ env.work_dir }}
run: |
touch yarn.lock # Without this Yarn will fail due to the parent directory being a Yarn workspace
rm -f example/yarn.lock # Workaround for cached yarn.lock from older version
yarn install --no-immutable
- name: Cache dependencies of library
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
${{ env.work_dir }}/**/node_modules
${{ env.work_dir }}/yarn.lock
key: ${{ steps.library-yarn-cache.outputs.cache-primary-key }}
- name: Use local version of react-native-builder-bob
run: |
cd packages/react-native-builder-bob
npm pack
tgz=$(ls react-native-builder-bob-*.tgz)
cd -
cd ${{ env.work_dir }}
YARN_CHECKSUM_BEHAVIOR=ignore yarn add --dev ../packages/react-native-builder-bob/$tgz
- name: Get build target
working-directory: ${{ env.work_dir }}
run: |
# Build Android for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == ubuntu ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == *-objc ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == *-objc ]]; then
echo "android_build=1" >> $GITHUB_ENV
fi
fi
# Build iOS for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == macos ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == kotlin-* ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == kotlin-* ]]; then
echo "ios_build=1" >> $GITHUB_ENV
fi
fi
- name: Cache turborepo
if: env.android_build == 1 || env.ios_build == 1
uses: actions/cache@v4
with:
path: |
${{ env.work_dir }}/.turbo
key: ${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-
- name: Check turborepo cache
if: env.android_build == 1 || env.ios_build == 1
working-directory: ${{ env.work_dir }}
run: |
TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn turbo run build:android --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn turbo run build:ios --cache-dir=".turbo" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then
echo "turbo_cache_hit_android=1" >> $GITHUB_ENV
fi
if [[ $TURBO_CACHE_STATUS_IOS == "HIT" ]]; then
echo "turbo_cache_hit_ios=1" >> $GITHUB_ENV
fi
- name: Lint library
working-directory: ${{ env.work_dir }}
run: |
yarn lint
- name: Typecheck library
working-directory: ${{ env.work_dir }}
run: |
yarn typecheck
- name: Test library
working-directory: ${{ env.work_dir }}
run: |
yarn test
- name: Build library
working-directory: ${{ env.work_dir }}
run: |
yarn prepare
- name: Build example (Web)
working-directory: ${{ env.work_dir }}
if: matrix.type.language == 'js'
run: |
yarn example expo export --platform web
- name: Install JDK
if: env.android_build == 1 && env.turbo_cache_hit_android != 1
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Finalize Android SDK
if: env.android_build == 1 && env.turbo_cache_hit_android != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Cache Gradle
if: env.android_build == 1 && env.turbo_cache_hit_android != 1
uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build example (Android)
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
if: env.android_build == 1
working-directory: ${{ env.work_dir }}
run: |
yarn turbo run build:android --cache-dir=".turbo"
- name: Use appropriate Xcode version
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Restore cocoapods
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1
id: library-cocoapods-cache
uses: actions/cache/restore@v4
with:
path: |
${{ env.work_dir }}/**/ios/Pods
${{ env.work_dir }}/**/ios/Podfile.lock
key: ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios/Podfile', env.work_dir)) }}-
${{ runner.os }}-library-cocoapods-
- name: Install cocoapods
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
working-directory: ${{ env.work_dir }}
run: |
cd example
bundle install
bundle exec pod install --project-directory=ios
- name: Cache cocoapods
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
${{ env.work_dir }}/**/ios/Pods
${{ env.work_dir }}/**/ios/Podfile.lock
key: ${{ steps.library-cocoapods-cache.outputs.cache-primary-key }}
- name: Build example (iOS)
if: env.ios_build == 1
working-directory: ${{ env.work_dir }}
run: |
yarn turbo run build:ios --cache-dir=".turbo"