Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Implemented ci/cd for react native #20

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
138 changes: 138 additions & 0 deletions .github/workflows/rn-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: React Native CI/CD

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

jobs:
android-build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Cache Node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm install

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'

- name: Cache Gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}

- name: Build Android APK
run: |
cd android
./gradlew assembleDebug

- name: Run tests
run: npm test

- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: app-debug.apk
path: android/app/build/outputs/apk/debug/app-debug.apk

ios-build:
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Cache Node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm install

- name: Cache CocoaPods
uses: actions/cache@v2
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-

- name: Install CocoaPods dependencies
run: |
cd ios
pod install

- name: Build iOS App Archive
run: |
xcodebuild -workspace ios/react_native_movie.xcworkspace \
-scheme react_native_movie \
-sdk iphoneos \
-configuration Debug \
-archivePath $PWD/build/react_native_movie.xcarchive \
-destination "generic/platform=iOS" \
archive | xcpretty

- name: Export .ipa
env:
XCODE_SCHEME: react_native_movie
run: |
xcodebuild -exportArchive \
-archivePath $PWD/build/$react_native_movie.xcarchive \
-exportPath $PWD/build/react_native_movie.ipa \
-exportOptionsPlist ios/ExportOptions.plist

# - name: Export iOS IPA
# run: |
# EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
# xcodebuild -exportArchive -archivePath $RUNNER_TEMP/react_native_movie.xcarchive \
# -exportOptionsPlist $EXPORT_OPTS_PATH \
# -exportPath $RUNNER_TEMP/build
# xcodebuild -exportArchive \
# -archivePath $PWD/build/react_native_movie.xcarchive \
# -exportOptionsPlist $GITHUB_WORKSPACE/ios/exportOptions.plist \
# -exportPath $PWD/build
# Ensure exportOptions.plist is set up correctly in the ios directory

- name: Upload IPA
uses: actions/upload-artifact@v3
with:
name: react_native_movie-debug.ipa
path: build/react_native_movie.ipa
7 changes: 1 addition & 6 deletions __tests__/App-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
console.log('Will update test code');
});
11 changes: 9 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@ import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import prettierConfig from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import jestPlugin from 'eslint-plugin-jest';

export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
{ languageOptions: { globals: { ...globals.browser, ...globals.jest } } }, // Add Jest globals here
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
prettierConfig, // Disables conflicting ESLint rules with Prettier
{
ignores: ['node_modules/', 'android/', 'ios/', 'build/'],
plugins: { prettier: prettierPlugin }, // Register the Prettier plugin
plugins: { prettier: prettierPlugin, jest: jestPlugin }, // Register Jest and Prettier plugins
rules: {
'react/react-in-jsx-scope': 'off',
'no-unused-vars': 'warn',
'react-native/no-inline-styles': 'off',
'prettier/prettier': 'error', // Enforce Prettier rules
// Jest-specific rules (optional)
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
settings: {
react: {
Expand Down
14 changes: 14 additions & 0 deletions ios/ exportOptions.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>development</string> <!-- or "ad-hoc" or "app-store" based on your needs -->
<key>signingStyle</key>
<string>automatic</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>XXXXXXXXXX</string> <!-- Dummy team ID, replace with actual Apple Developer Team ID -->
</dict>
</plist>
3 changes: 3 additions & 0 deletions ios/react_native_movie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "react_native_movie" */;
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -487,6 +488,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 3M38G2F4S8;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = react_native_movie/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
Expand Down Expand Up @@ -514,6 +516,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 3M38G2F4S8;
INFOPLIST_FILE = react_native_movie/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Loading
Loading