Skip to content

Commit

Permalink
Monorepo (#5992)
Browse files Browse the repository at this point in the history
## About

This pull request finally moves Reanimated repo to desired monorepo
structure.

The migration process will be divided into steps, so then code review
would be feasible.

## Summary

This particular pull request does only the following:

- Creates a monorepo structure
- Moves current contents of the repository, excluding `.git`, to
`packages/react-native-reanimated`.
- Creates a copy of the `LICENSE, .gitignore` in the root of the
repository.

When reviewing, please only take those changes into account - clone this
repository and browse the files.

After this PR monorepo's functionalities are not utilized.
`packages/react-native-reanimated` still has its own `node_modules` and
`yarn.lock`, as well as embedded packages. This will be changed in the
following PRs.

Also, a number of scripts/CI won't work either due to path differences.
This will also be amended in the upcoming PRs.

## Test plan

Run `yarn` in the root of the repository, `yarn && yarn build && yarn
build:app` in `packages/react-native-reanimated` and build the Example
app as usual. It's working as expected.

## Steps achieved towards monorepo

- [ ] All CI pass
- [x] Precommit scripts work properly
- [x] react-native-reanimated is a separate workspace which uses hoisted
node_modules
- [x] app is a separate workspace which uses hoisted node_modules
- [x] paper example is a separate workspace which uses hoisted
node_modules
- [x] fabric example is a separate workspace which uses hoisted
node_modules
- [x] web example is a separate workspace which uses hoisted
node_modules
- [x] macos example is a separate workspace which uses hoisted
node_modules
- [x] next example is a separate workspace which uses hoisted
node_modules
- [x] reanimated eslint plugin is a separate workspace which uses
hoisted node_modules
- [x] the npm package builds and works as expected
- [x] reanimated2 directory is removed
- [x] TypeScript, ESLint and Prettier configs are unified and only
extended when necessary in workspaces

---------

Co-authored-by: Michał Bert <michal.bert@swmansion.com>
Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com>
Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
Co-authored-by: szydlovsky <9szydlowski9@gmail.com>
  • Loading branch information
5 people authored Jun 10, 2024
1 parent 8a9e161 commit c6d999e
Show file tree
Hide file tree
Showing 1,705 changed files with 309,421 additions and 73,909 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ module.exports = {
},
},
],
parserOptions: {
requireConfigFile: false,
},
extends: [
'standard',
'prettier',
Expand Down Expand Up @@ -79,5 +82,10 @@ module.exports = {
eqeqeq: 'error',
'no-unreachable': 'error',
'tsdoc/syntax': 'error',
'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',
},
};
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugin/build/* linguist-generated=true

.yarn/releases/** binary
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
36 changes: 20 additions & 16 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
pull_request:
paths:
- .github/workflows/android-build.yml
- android/**
- Common/**
- Example/package.json
- Example/android/**
- FabricExample/package.json
- FabricExample/android/**
- packages/react-native-reanimated/android/**
- packages/react-native-reanimated/Common/**
- apps/paper-example/package.json
- apps/paper-example/android/**
- apps/fabric-example/package.json
- apps/fabric-example/android/**
merge_group:
branches:
- main
Expand All @@ -19,20 +19,20 @@ on:
- main
paths:
- .github/workflows/android-build.yml
- android/**
- Common/**
- Example/package.json
- Example/android/**
- FabricExample/package.json
- FabricExample/android/**
- packages/react-native-reanimated/android/**
- packages/react-native-reanimated/Common/**
- apps/paper-example/package.json
- apps/paper-example/android/**
- apps/fabric-example/package.json
- apps/fabric-example/android/**

jobs:
build:
if: github.repository == 'software-mansion/react-native-reanimated'
runs-on: ubuntu-latest
strategy:
matrix:
working-directory: [Example, FabricExample]
working-directory: [apps/paper-example, apps/fabric-example]
fail-fast: false
concurrency:
group: android-${{ matrix.working-directory }}-${{ github.ref }}
Expand All @@ -41,6 +41,9 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Install dependencies in root
run: yarn install --immutable

- name: Setup Java 17
uses: actions/setup-java@v3
with:
Expand All @@ -50,11 +53,12 @@ jobs:
- name: Restore Reanimated node_modules from cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-android-node-modules-reanimated-${{ hashFiles('yarn.lock') }}
path: packages/react-native-reanimated/node_modules
key: ${{ runner.os }}-android-node-modules-reanimated-${{ hashFiles('packages/react-native-reanimated/yarn.lock') }}
restore-keys: ${{ runner.os }}-android-node-modules-reanimated-

- name: Install Reanimated node_modules
working-directory: packages/react-native-reanimated
run: yarn install --immutable

- name: Restore app node_modules from cache
Expand All @@ -66,7 +70,7 @@ jobs:

- name: Install app node_modules
working-directory: ${{ matrix.working-directory }}
run: yarn install --immutable
run: yarn install

- name: Build app
working-directory: ${{ matrix.working-directory }}/android
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/build-monorepo.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Test monorepo build
env:
YARN_ENABLE_HARDENED_MODE: 0
on:
pull_request:
paths:
- .github/workflows/build-monorepo.yml
- .github/workflows/build-monorepo-action.yml
- RNReanimated.podspec
- scripts/reanimated_utils.rb
- android/build.gradle
- packages/react-native-reanimated/scripts/reanimated_utils.rb
- packages/react-native-reanimated/android/build.gradle
merge_group:
branches:
- main
Expand All @@ -18,9 +16,9 @@ on:
paths:
- .github/workflows/build-monorepo.yml
- .github/workflows/build-monorepo-action.yml
- RNReanimated.podspec
- scripts/reanimated_utils.rb
- android/build.gradle
- packages/react-native-reanimated/RNReanimated.podspec
- packages/react-native-reanimated/scripts/reanimated_utils.rb
- packages/react-native-reanimated/android/build.gradle
workflow_call:

jobs:
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/build-next-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
pull_request:
paths:
- .github/workflows/build-next-example.yml
- 'src/**'
- 'NextExample/**'
- 'packages/react-native-reanimated/src/**'
- 'packages/react-native-reanimated/NextExample/**'
push:
branches:
- master
- main

jobs:
check:
Expand All @@ -20,21 +20,23 @@ jobs:
steps:
- name: Checkout Git repository
uses: actions/checkout@v4

- name: Install Reanimated node_modules
- name: Install monorepo node dependencies
run: yarn install --immutable

- name: Build package
- name: Install Reanimated node dependencies
working-directory: packages/react-native-reanimated
run: yarn install --immutable
- name: Build Reanimated package
working-directory: packages/react-native-reanimated
run: yarn build

- name: Install NextExample node_modules
working-directory: NextExample
working-directory: apps/next-example
run: yarn install --immutable

- name: Compile production build
working-directory: NextExample
run: yarn build
working-directory: apps/next-example
run: yarn build:next

- name: Run e2e tests
working-directory: NextExample
working-directory: apps/next-example
run: yarn e2e:headless
66 changes: 20 additions & 46 deletions .github/workflows/build-npm-package-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ on:
ref:
required: false
type: string
upload_binaries:
required: false
type: boolean
publish_on_npm:
required: false
type: boolean
secrets:
NODE_AUTH_TOKEN:
required: false
workflow_dispatch:
inputs:
option:
required: false
type: string
ref:
required: false
type: string

jobs:
build:
Expand All @@ -36,72 +41,41 @@ jobs:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Clear annotations
run: scripts/clear-annotations.sh

- name: Set up JDK 11
if: ${{ inputs.ref == 'Reanimated2' }}
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Install NDK
if: ${{ inputs.ref == 'Reanimated2' }}
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21d
run: .github/workflows/helper/clear-annotations.sh

- name: Build package
working-directory: packages/react-native-reanimated
id: build
env:
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: >-
./createNPMPackage.sh ${{ inputs.option }} 2> build.log
./createNPMPackage.sh ${{ inputs.option }}
- name: Check if any node_modules were packed
working-directory: packages/react-native-reanimated
id: node_modules
run: >-
! grep --silent -E "node_modules/.+"
- name: Check if size is over 1MB
if: ${{ inputs.ref != 'Reanimated2' }}
id: size
run: grep --silent -E "npm notice package size:\s*[0-9][0-9]?[0-9]?(\.[0-9]*)?\s*kB" build.log
! grep --silent -E "node_modules/.+" build.log
- name: Show build log
working-directory: packages/react-native-reanimated
if: failure() && steps.build.outcome == 'failure'
run: >-
cat build.log
- name: Show packed node_modules
working-directory: packages/react-native-reanimated
if: failure() && steps.node_modules.outcome == 'failure'
run: >-
! grep -E "node_modules/.+"
! grep -E "node_modules/.+" build.log
- name: Show exceeded package size
if: failure() && steps.size.outcome == 'failure'
run: grep -E "npm notice package size:" build.log

- run: echo "PACKAGE_NAME=$(ls -l | egrep -o "react-native-reanimated-(.*)(=?\.tgz)")" >> $GITHUB_ENV
- name: Add package name to env
working-directory: packages/react-native-reanimated
run: echo "PACKAGE_NAME=$(ls -l | egrep -o "react-native-reanimated-(.*)(=?\.tgz)")" >> $GITHUB_ENV

- name: Upload npm package
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
path: '*.tgz'

- name: Compress Android build output
if: ${{ inputs.upload_binaries }}
run: zip -r android-build-output.zip build_output

- name: Upload Android build folder
if: ${{ inputs.upload_binaries }}
uses: actions/upload-artifact@v4
with:
name: android-build-output
path: android-build-output.zip
retention-days: 5
path: "packages/react-native-reanimated/${{ env.PACKAGE_NAME }}"

- run: npm publish $PACKAGE_NAME --tag nightly
if: ${{ inputs.publish_on_npm }}
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/build-release-npm-package-rea2.yml

This file was deleted.

21 changes: 16 additions & 5 deletions .github/workflows/check-TS-react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
react-native-version: ['0.71', '0.72', '0.73', '0.74.0-rc.6', nightly]
react-native-version: ['0.71', '0.72', '0.73', '0.74', nightly]
fail-fast: false
concurrency:
group: TS-react-native-nightly-${{ matrix.react-native-version }}-${{ github.ref }}
Expand All @@ -28,21 +28,32 @@ jobs:
with:
cache: 'yarn'
- name: Clear annotations
run: scripts/clear-annotations.sh
- name: Install dependencies
run: .github/workflows/helper/clear-annotations.sh

- name: Install monorepo node dependencies
run: yarn install
- name: Install Reanimated node dependencies
working-directory: packages/react-native-reanimated
run: yarn install
- name: Build repo
- name: Build Reanimated node dependencies
working-directory: packages/react-native-reanimated
run: yarn build
- name: Install react-native ${{ matrix.react-native-version }}
run: yarn add --dev react-native@${{ matrix.react-native-version }}
run: yarn up react-native@${{ matrix.react-native-version }}

- name: Check source types
working-directory: packages/react-native-reanimated
run: yarn type:check:src
- name: Check plugin types
working-directory: packages/react-native-reanimated
run: yarn type:check:plugin
- name: Check API
working-directory: packages/react-native-reanimated
run: yarn type:check:app
- name: Run common type tests
working-directory: packages/react-native-reanimated
run: yarn type:check:tests:common
- name: Run 0.72+ type tests
working-directory: packages/react-native-reanimated
if: matrix.react-native-version != '0.71'
run: yarn type:check:tests:0.72+
Loading

0 comments on commit c6d999e

Please sign in to comment.