Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/actions/build-app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build App
description: 'Set up your GitHub Actions workflow with a specific version of Node.js'
inputs:
new-arch-enabled:
description: 'Enable new architecture (example: 1 or 0))'
required: true

rn-ver:
description: 'Version of React Native (example: 0.72.6))'
required: true

arch:
description: 'Architecture (example: "arm64-v8a" or "x86_64,arm64-v8a") android only'
required: false
default: 'armeabi-v7a,arm64-v8a,x86,x86_64'

module-to-install:
description: 'Module to install (example: "react-native-architectures" or "file:/path/to/module"))'
required: true

store-artifacts:
description: 'Store artifacts on GitHub (example: true or false))'
required: false
default: 'true'

platform:
description: 'Platform (example: android or ios))'
required: true


runs:
using: 'composite'
steps:
- uses: ./.github/actions/lock-nodejs-ver

- uses: ./.github/actions/lock-java-ver
if: ${{ inputs.platform == 'android' }}

- uses: ./.github/actions/lock-ruby-ver
if: ${{ inputs.platform == 'ios' }}

- name: Create tmp directory
shell: bash
id: clear_name
env:
APP_NAME: Example${{ inputs.rn-ver }}${{ inputs.new-arch-enabled }}App
run: |
input_string="${{ env.APP_NAME }}"

# Remove "." and "-" symbols from the input string
modified_string="${input_string//./}"
modified_string="${modified_string//-/}"

echo "folder=${modified_string}" >> $GITHUB_OUTPUT

- name: Build ${{ inputs.platform }} (${{ inputs.arch }})
working-directory: /tmp
shell: bash
id: app_build
env:
APP_NAME: ${{ steps.clear_name.outputs.folder }}
# iOS only
NO_FLIPPER: 1
RCT_NEW_ARCH_ENABLED: ${{ inputs.new-arch-enabled }}
run: |
set -x # print all executed commands

# Create new tmp React Native project
npx react-native@${{ inputs.rn-ver }} init ${{ env.APP_NAME }} --version ${{ inputs.rn-ver }}
cd ${{ env.APP_NAME }}

# Install my module
yarn add ${{ inputs.module-to-install }}

# Debug info
npx react-native@${{ inputs.rn-ver }} info

if [[ '${{ inputs.platform }}' == 'ios' ]]; then
brew install xcbeautify

# Update pods after adding new module
npx pod-install

# Build iOS App
xcodebuild -scheme ${{ env.APP_NAME }} -workspace ios/${{ env.APP_NAME }}.xcworkspace -configuration Release -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' | xcbeautify --quiet

# set output variable
echo "app_path=$(find ~/Library/Developer/Xcode/DerivedData -type d -name "${{ env.APP_NAME }}.app")" >> $GITHUB_OUTPUT
else
# Enable new arch for Android
if [[ '${{ inputs.new-arch-enabled }}' == '1' ]]; then
sed -i 's/newArchEnabled=false/newArchEnabled=true/' android/gradle.properties
fi

# Build Android
./android/gradlew assembleRelease --no-daemon -p android -PreactNativeArchitectures=${{ inputs.arch }}

# set output variable
echo "app_path=$(find $(pwd)/android -type f -name '*.apk')" >> $GITHUB_OUTPUT
fi

- name: Store Android artifacts on GitHub
uses: actions/upload-artifact@v3
if: ${{ inputs.store-artifacts == 'true' }}
with:
name: ${{ inputs.platform }}-${{ inputs.rn-ver }}-newArch${{ inputs.new-arch-enabled }}
if-no-files-found: error
retention-days: 14 # 2 weeks
path: ${{ steps.app_build.outputs.app_path }}
41 changes: 41 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Install dependencies
description: 'Installs and caches Node.js dependencies using Yarn.'
inputs:
node-version:
description: 'The Node.js version to set up'
required: false


runs:
using: 'composite'
steps:
- uses: ./.github/actions/lock-nodejs-ver
with:
node-version: ${{ inputs.node-version }}

- name: Restore node_modules from cache
uses: actions/cache/restore@v3
id: restore_node_modules
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
path: ${{ github.workspace }}/node_modules


- name: Install node_modules
if: steps.restore_node_modules.outputs.cache-hit != 'true'
shell: bash
run: |
# Retry 3 times before the steps actually fails
(echo "===== Install node_modules Attempt: 1 ====" && yarn install --frozen-lockfile) || \
(echo "===== Install node_modules Attempt: 2 ====" && yarn install --frozen-lockfile) || \
(echo "===== Install node_modules Attempt: 3 ====" && yarn install --frozen-lockfile) || \
(echo "===== Install node_modules Step Failed ====" && exit 1)


- name: Save node_modules to cache
if: steps.restore_node_modules.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
key: ${{ steps.restore_node_modules.outputs.cache-primary-key }}
path: ${{ github.workspace }}/node_modules
16 changes: 16 additions & 0 deletions .github/actions/lock-java-ver/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Setup Java
description: 'Set up your GitHub Actions workflow with a specific version of Java'
inputs:
java-version:
description: 'The Java version to set up'
required: false
default: 17

runs:
using: 'composite'
steps:
- name: Setup Java ${{ inputs.java-version }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ inputs.java-version }}
15 changes: 15 additions & 0 deletions .github/actions/lock-nodejs-ver/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Setup Node.js
description: 'Set up your GitHub Actions workflow with a specific version of Node.js'
inputs:
node-version:
description: 'The Node.js version to set up'
required: false
default: 18

runs:
using: 'composite'
steps:
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
16 changes: 16 additions & 0 deletions .github/actions/lock-ruby-ver/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Setup Ruby
description: 'Set up your GitHub Actions workflow with a specific version of Ruby'
inputs:
ruby-version:
description: 'The Ruby version to set up'
required: false
default: 3.0

runs:
using: 'composite'
steps:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
89 changes: 89 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Main

on:
pull_request:
branches:
- master
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
ACTIONS_RUNNER_DEBUG: true # Enable debug logs

jobs:
cache-node-modules:
name: Cache node_modules
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/install-dependencies

code-quality:
name: Code Quality
runs-on: ubuntu-22.04
needs: [cache-node-modules]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/install-dependencies

- name: Lint files
run: yarn run test:eslint

- name: Flow files
run: yarn run test:flow

build-android:
name: Build Android
runs-on: ubuntu-22.04
strategy:
fail-fast: false
max-parallel: 4
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [latest ] # also, can be any npm tag: 0.71-stable, next, nightly
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/build-app
with:
arch: arm64-v8a
new-arch-enabled: ${{ matrix.new_arch_enabled }}
rn-ver: ${{ matrix.rn_ver }}
module-to-install: file:${{ github.workspace }}
store-artifacts: true
platform: android

build-ios:
name: Build iOS
runs-on: macos-13
strategy:
fail-fast: false
max-parallel: 3
matrix:
new_arch_enabled: [ 1, 0 ]
rn_ver: [latest ] # also, can be any npm tag: 0.71-stable, next, nightly
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/build-app
with:
new-arch-enabled: ${{ matrix.new_arch_enabled }}
rn-ver: ${{ matrix.rn_ver }}
module-to-install: file:${{ github.workspace }}
store-artifacts: true
platform: ios