Skip to content

chore: change gradle task for copying to new archs into JS scripts - #2224

Merged
maciekstosio merged 21 commits into
mainfrom
@maciekstosio/Change-gradle-copy-task-to-JS-
Jul 10, 2024
Merged

maciekstosio merged 21 commits into
mainfrom
@maciekstosio/Change-gradle-copy-task-to-JS-

Conversation

@maciekstosio

@maciekstosio maciekstosio commented Jul 2, 2024 •

Copy link
Copy Markdown
Contributor

Description

This task is rewrite to JS of #2168 with some improvements. General point of creating those tasks is:

When changing native props on Fabric, codegen generates corresponding interfaces and delegates. To make sure both implementations are consistent, we implement those interfaces on Paper too. Currently, after generating interfaces using codegen, developer needs to copy corresponding files for paper manually. This task adds Gradle task, that automates this.

Changes

Current assumption:
Two scripts: check-archs-consistency and sync-archs. The first one generates codegen interfaces and compares them with what we have for paper, the second generates and copies for paper to sync the archs.

  • sync is run pre build on example app
  • sync is run when staged on changes to src/paper
  • check is run on CI when src/paper or android/src/paper/java/com/facebook/react/viewmanagers changes

What it improves:

  • JS tasks are much faster, as codegen is JS script anyway, we skip gradle and java setup all together (CI task down from 7min to 30s),
  • we do not put code to library, so it shouldn't be possible to mess up something for end users,
  • instead of syncing archs when running codegen we do that on paper example build and when staged, so: when developer didn't touch the code it will have changes after commit, when developer switched to working on paper interfaces should be always up to date when building the app.

Test code and steps to reproduce

Open src/fabric/ScreenStackHeaderConfigNativeComponent.ts and remove any proper form interface. Now:

  • when building paper, interface should be updated
  • when committing, interface should be updated
  • if committed and pushed, Test consistency between Paper & Fabric should fail :)
    Brining back the prop and repeating up should cause the interface back and CI green.
    Posting changes in other places should cause CI task to run.

You can also run those commands yourself using yarn check-archs-consistency and yarn sync-archs

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just initial remarks - I'll have more once the PR is opened & ready for review. The approach is good.

Comment thread package.json Resolved
maciekstosio and others added 5 commits July 8, 2024 14:27
@maciekstosio
maciekstosio marked this pull request as ready for review July 8, 2024 13:26
Comment thread scripts/codegen-check-consistency.js Resolved
Comment thread scripts/codegen-utils.js Resolved
Comment thread scripts/codegen-utils.js Resolved

@WoLewicki WoLewicki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 2 comments

Comment thread scripts/codegen-utils.js Resolved
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.github.node-gradle.node'

task syncArchs(type: NodeTask) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it why it's still here. Don't we do everything on the JS side now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the app so it shouldn't interfere with the lib. I understood that @kkafar wanted to have it run automatically while developing. It needs to be added per example/test app, so I can just not add it in other packages.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah & I want this in screens.

@maciekstosio
maciekstosio requested review from j-piasecki and kkafar July 9, 2024 07:20

@j-piasecki j-piasecki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have anything else to add here 😄

@maciekstosio
maciekstosio requested a review from WoLewicki July 9, 2024 07:50

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks 👍🏻

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.github.node-gradle.node'

task syncArchs(type: NodeTask) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah & I want this in screens.

Comment thread scripts/codegen-utils.js Resolved
@tboba
tboba self-requested a review July 9, 2024 14:12

@tboba tboba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a one suggestion from me. Great change!

Comment on lines +17 to +19
uses: actions/checkout@v2
- name: Use Node.js 18
uses: actions/setup-node@v2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use v4 script versions.

Suggested change
uses: actions/checkout@v2
- name: Use Node.js 18
uses: actions/setup-node@v2
uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Comment thread scripts/codegen-utils.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with this one!

maciekstosio added a commit to software-mansion/react-native-svg that referenced this pull request Jul 22, 2024
Changes moved from:
software-mansion/react-native-screens#2224

## Description

When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.

## Changes
Current assumption: 
Two scripts: `check-archs-consistency` and `sync-archs`. The first one
generates codegen interfaces and compares them with what we have for
paper, the second generates and copies for paper to sync the archs.
- sync is run when staged on changes to `src/paper`
- check is run on CI when `src/paper` or
`android/src/paper/java/com/facebook/react/viewmanagers` changes

## Test code and steps to reproduce

Open `src/fabric/LineNativeComponent.ts` or/and
`src/fabric/NativeSvgRenderableModule.ts` and remove any proper form
interface. Now:
- when building paper, interface should be updated
- when committing, interface should be updated
- if committed and pushed, Test consistency between Paper & Fabric
should fail :)
Brining back the prop and repeating up should cause the interface back
and CI green.
Posting changes in other places should cause CI task to run. 

You can also run those commands yourself using `yarn
check-archs-consistency` and `yarn sync-archs`
maciekstosio added a commit to software-mansion/react-native-gesture-handler that referenced this pull request Jul 23, 2024
Changes moved from:
software-mansion/react-native-screens#2224

## Description

When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.

## Changes
Current assumption: 
Two scripts: `check-archs-consistency` and `sync-archs`. The first one
generates codegen interfaces and compares them with what we have for
paper, the second generates and copies for paper to sync the archs.
- sync is run when staged on changes to `src/specs`
- check is run on CI when `src/specs` or
`android/paper/src/java/com/facebook/react/viewmanagers` changes

## Test code and steps to reproduce

Open `src/specs/RNGestureHandlerButtonNativeComponent.ts` and remove any
proper form interface. Now:
- when building paper, interface should be updated
- when committing, interface should be updated
- if committed and pushed, Test consistency between Paper & Fabric
should fail :)
Brining back the prop and repeating up should cause the interface back
and CI green.
Posting changes in other places should cause CI task to run. 

You can also run those commands yourself using `yarn
check-archs-consistency` and `yarn sync-archs`

---------

Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
maciekstosio added a commit that referenced this pull request Jul 23, 2024
## Description

Fixes to
#2224, that
came out in other repos.


## Changes

- Bump version of GitHub actions 
- Fix warning when trying to copy non existing codegen interface

## Test code and steps to reproduce

Duplicate
`android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java`
with name change for example with ` copy` at the end. Before it would
fail because file wouldn't be found. Now there will be warning in logs.
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…oftware-mansion#2224)

## Description

This task is rewrite to JS of
software-mansion#2168 with
some improvements. General point of creating those tasks is:

> When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.

## Changes
Current assumption: 
Two scripts: `check-archs-consistency` and `sync-archs`. The first one
generates codegen interfaces and compares them with what we have for
paper, the second generates and copies for paper to sync the archs.
- sync is run pre build on example app
- sync is run when staged on changes to `src/paper`
- check is run on CI when `src/paper` or
`android/src/paper/java/com/facebook/react/viewmanagers` changes

What it improves:
- JS tasks are much faster, as codegen is JS script anyway, we skip
gradle and java setup all together (CI task down from 7min to 30s),
- we do not put code to library, so it shouldn't be possible to mess up
something for end users,
- instead of syncing archs when running codegen we do that on paper
example build and when staged, so: when developer didn't touch the code
it will have changes after commit, when developer switched to working on
paper interfaces should be always up to date when building the app.

## Test code and steps to reproduce

Open `src/fabric/ScreenStackHeaderConfigNativeComponent.ts` and remove
any proper form interface. Now:
- when building paper, interface should be updated
- when committing, interface should be updated
- if committed and pushed, Test consistency between Paper & Fabric
should fail :)
Brining back the prop and repeating up should cause the interface back
and CI green.
Posting changes in other places should cause CI task to run. 

You can also run those commands yourself using `yarn
check-archs-consistency` and `yarn sync-archs`

---------

Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
## Description

Fixes to
software-mansion#2224, that
came out in other repos.


## Changes

- Bump version of GitHub actions 
- Fix warning when trying to copy non existing codegen interface

## Test code and steps to reproduce

Duplicate
`android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java`
with name change for example with ` copy` at the end. Before it would
fail because file wouldn't be found. Now there will be warning in logs.
jamesdev-king added a commit to jamesdev-king/flutter_ui_challenge_flight_search that referenced this pull request Aug 1, 2025
## Description

Fixes to
software-mansion/react-native-screens#2224, that
came out in other repos.


## Changes

- Bump version of GitHub actions 
- Fix warning when trying to copy non existing codegen interface

## Test code and steps to reproduce

Duplicate
`android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java`
with name change for example with ` copy` at the end. Before it would
fail because file wouldn't be found. Now there will be warning in logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants