-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
359 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
name: Build template | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/build-templates.yml' | ||
- 'packages/create-react-native-library/**' | ||
- '!**.md' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu | ||
- macos | ||
type: | ||
- module-legacy | ||
- module-mixed | ||
- module-new | ||
- view-legacy | ||
- view-mixed | ||
- view-new | ||
language: | ||
- java-objc | ||
- java-swift | ||
- kotlin-objc | ||
- kotlin-swift | ||
exclude: | ||
- os: macos | ||
language: kotlin-objc | ||
- os: macos | ||
language: kotlin-swift | ||
- type: module-new | ||
language: java-swift | ||
- type: module-new | ||
language: kotlin-swift | ||
- type: module-mixed | ||
language: java-swift | ||
- type: module-mixed | ||
language: kotlin-swift | ||
- type: view-new | ||
language: java-swift | ||
- type: view-new | ||
language: kotlin-swift | ||
- type: view-mixed | ||
language: java-swift | ||
- type: view-mixed | ||
language: kotlin-swift | ||
include: | ||
- os: ubuntu | ||
type: library | ||
language: js | ||
- os: ubuntu | ||
type: module-legacy | ||
language: cpp | ||
- os: ubuntu | ||
type: module-mixed | ||
language: cpp | ||
- os: ubuntu | ||
type: module-new | ||
language: cpp | ||
- os: macos | ||
type: module-legacy | ||
language: cpp | ||
- os: macos | ||
type: module-mixed | ||
language: cpp | ||
- os: macos | ||
type: module-new | ||
language: cpp | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }} | ||
cancel-in-progress: true | ||
|
||
runs-on: ${{ matrix.os }}-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- 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 }}-${{ matrix.language }}" >> $GITHUB_ENV | ||
- name: Create library | ||
run: | | ||
rm -rf ${{ env.work_dir }} # Workaround for tests failing intermittently | ||
./packages/create-react-native-library/bin/create-react-native-library ${{ env.work_dir }} \ | ||
--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 }} \ | ||
--languages ${{ matrix.language }} \ | ||
--no-local | ||
- name: Cache dependencies of library | ||
id: library-yarn-cache | ||
uses: actions/cache@v3 | ||
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)) }} | ||
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 | ||
env: | ||
POD_INSTALL: 0 | ||
|
||
- 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 }} == view-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; 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 }} == view-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == java-* ]] || [[ ${{ matrix.type }} == module-* && ${{ matrix.language }} == cpp ]]; then | ||
echo "ios_build=1" >> $GITHUB_ENV | ||
fi | ||
fi | ||
- name: Cache turborepo | ||
if: env.android_build == 1 || env.ios_build == 1 | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ env.work_dir }}/.turbo | ||
key: ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }} | ||
restore-keys: | | ||
${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.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.language == 'js' | ||
run: | | ||
yarn example expo export:web | ||
- name: Install JDK | ||
if: env.android_build == 1 && env.turbo_cache_hit_android != 1 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '11' | ||
|
||
- 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@v3 | ||
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) | ||
if: env.android_build == 1 | ||
working-directory: ${{ env.work_dir }} | ||
run: | | ||
yarn turbo run build:android --cache-dir=".turbo" | ||
- name: Cache cocoapods | ||
if: env.ios_build == 1 && env.turbo_cache_hit_ios != 1 | ||
id: library-cocoapods-cache | ||
uses: actions/cache@v3 | ||
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: | | ||
yarn pod-install example/ios | ||
env: | ||
NO_FLIPPER: 1 | ||
|
||
- name: Build example (iOS) | ||
if: env.ios_build == 1 | ||
working-directory: ${{ env.work_dir }} | ||
run: | | ||
yarn turbo run build:ios --cache-dir=".turbo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Check project | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check-project: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- name: Lint | ||
run: yarn lint | ||
|
||
- name: Typecheck | ||
run: yarn typecheck | ||
|
||
- name: Build packages | ||
run: yarn lerna run prepare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Deploy docs | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/deploy-docs.yml' | ||
- 'docs/**' | ||
|
||
jobs: | ||
deploy-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- name: Cache build | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
docs/.next/cache | ||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }} | ||
${{ runner.os }}-nextjs- | ||
- name: Build docs | ||
run: | | ||
yarn docs build | ||
touch docs/out/.nojekyll | ||
- name: Deploy to GitHub Pages | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
branch: gh-pages | ||
folder: docs/out | ||
|
||
permissions: | ||
contents: write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Automatic Rebase | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
rebase: | ||
name: Rebase | ||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Automatic Rebase | ||
uses: cirrus-actions/rebase@1.2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250 | ||
always_job: | ||
name: Always run job | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Always run | ||
run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped." |