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

Move @generated from build to sync #29799

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

rickhanlonii
Copy link
Member

@rickhanlonii rickhanlonii commented Jun 7, 2024

Overview

Reverts #26616 and implements the suggested way instead.

This change in #26616 broken the internal sync command, which now results in duplicated @generated headers. It also makes it harder to detect changes during the diff train sync. Instead, we will check for changes, and if there are changes sign the files and commit them to the sync branch.

Strategy

The new sync strategy accounts for the generated headers during the sync:

  • Revert Version: Revert the version strings
  • Revert @generated: Re-sign the files (will be the same hash as before if unchanged)
  • Check: Check if there are changes if not, skip
  • Re-apply Version: Now add back the new version string
  • Re-sign @generated: And re-generate the headers

Then commit to branch. This ensures that if there are no changes, we'll skip.

Copy link

vercel bot commented Jun 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 10, 2024 2:12pm

@react-sizebot
Copy link

react-sizebot commented Jun 7, 2024

Comparing: 142b2a8...eb089cd

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.26 kB 497.26 kB = 89.11 kB 89.11 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.08 kB 502.08 kB = 89.80 kB 89.80 kB
facebook-www/ReactDOM-prod.classic.js = 596.77 kB 596.77 kB = 105.19 kB 105.19 kB
facebook-www/ReactDOM-prod.modern.js = 570.95 kB 570.95 kB = 101.13 kB 101.13 kB
facebook-react-native/react/cjs/JSXRuntime-prod.js = 1.73 kB 1.67 kB = 0.75 kB 0.70 kB
facebook-react-native/react/cjs/JSXRuntime-profiling.js = 1.73 kB 1.67 kB = 0.75 kB 0.70 kB
react-native/shims/createReactNativeComponentClass.js = 1.01 kB 0.95 kB = 0.55 kB 0.50 kB
react-native/shims/ReactFabric.js = 0.84 kB 0.78 kB = 0.47 kB 0.42 kB
react-native/shims/ReactNative.js = 0.60 kB 0.54 kB = 0.36 kB 0.31 kB
facebook-react-native/react/cjs/JSXDEVRuntime-prod.js = 0.43 kB 0.37 kB = 0.32 kB 0.27 kB
facebook-react-native/react/cjs/JSXDEVRuntime-profiling.js = 0.43 kB 0.37 kB = 0.32 kB 0.27 kB
react-native/shims/ReactFeatureFlags.js = 0.43 kB 0.36 kB = 0.31 kB 0.26 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-react-native/react/cjs/React-profiling.js = 20.10 kB 20.04 kB = 5.19 kB 5.14 kB
facebook-react-native/react/cjs/React-prod.js = 19.66 kB 19.60 kB = 5.11 kB 5.06 kB
facebook-react-native/scheduler/cjs/SchedulerMock-dev.js = 17.94 kB 17.88 kB = 4.33 kB 4.28 kB
facebook-react-native/scheduler/cjs/Scheduler-dev.js = 17.09 kB 17.02 kB = 4.84 kB 4.79 kB
facebook-react-native/scheduler/cjs/SchedulerMock-prod.js = 12.34 kB 12.28 kB = 2.92 kB 2.86 kB
facebook-react-native/scheduler/cjs/Scheduler-profiling.js = 10.84 kB 10.77 kB = 2.69 kB 2.64 kB
facebook-react-native/scheduler/cjs/Scheduler-prod.js = 10.40 kB 10.34 kB = 2.59 kB 2.54 kB
react-native/shims/ReactNativeTypes.js = 8.74 kB 8.67 kB = 2.38 kB 2.32 kB
facebook-react-native/react-is/cjs/ReactIs-dev.js = 6.52 kB 6.45 kB = 1.81 kB 1.75 kB
facebook-react-native/react-is/cjs/ReactIs-prod.js = 4.53 kB 4.47 kB = 1.13 kB 1.07 kB
facebook-react-native/react-is/cjs/ReactIs-profiling.js = 4.53 kB 4.47 kB = 1.13 kB 1.07 kB
react-native/shims/ReactNativeViewConfigRegistry.js = 3.63 kB 3.57 kB = 1.29 kB 1.24 kB
facebook-react-native/react/cjs/JSXRuntime-prod.js = 1.73 kB 1.67 kB = 0.75 kB 0.70 kB
facebook-react-native/react/cjs/JSXRuntime-profiling.js = 1.73 kB 1.67 kB = 0.75 kB 0.70 kB
react-native/shims/createReactNativeComponentClass.js = 1.01 kB 0.95 kB = 0.55 kB 0.50 kB
react-native/shims/ReactFabric.js = 0.84 kB 0.78 kB = 0.47 kB 0.42 kB
react-native/shims/ReactNative.js = 0.60 kB 0.54 kB = 0.36 kB 0.31 kB
facebook-react-native/react/cjs/JSXDEVRuntime-prod.js = 0.43 kB 0.37 kB = 0.32 kB 0.27 kB
facebook-react-native/react/cjs/JSXDEVRuntime-profiling.js = 0.43 kB 0.37 kB = 0.32 kB 0.27 kB
react-native/shims/ReactFeatureFlags.js = 0.43 kB 0.36 kB = 0.31 kB 0.26 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against eb089cd

git status
echo "===================="
if git status --porcelain | grep -qv '/REVISION'; then
echo "Changes detected"
echo "===== Changes ====="
git --no-pager diff -U0 | grep '^[+-]' | head -n 50
echo "==================="
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this so that if we ever create diffs we shouldn't, it's easy to debug in the workflow output. I truncate after 50 lines because that's enough to see that there are more than just hash / version changes.

else
echo "No Changes detected"
fi
- name: Revert signatures
Copy link
Member Author

Choose a reason for hiding this comment

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

So this is the clever bit. Once we've reverted the version strings, then we can re-generate the headers. If the only difference in the file was the version string, then this will output the same @generated header, and the working directory will be clean.

if: steps.check_should_commit.outputs.should_commit == 'true'
run: |
echo ":"
git add .
- name: Signing files
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that the version has been switched back to the new version, we also need to re-sign the files.

@@ -4,7 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @noformat
Copy link
Member Author

Choose a reason for hiding this comment

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

There was some login in the build switch to flip these files to @noformat but we can just... make them that way in source.

Copy link
Contributor

@yungsters yungsters left a comment

Choose a reason for hiding this comment

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

Don't look him in the eyes… don't look him in the eyes…

.github/workflows/commit_artifacts.yml Outdated Show resolved Hide resolved
.github/workflows/commit_artifacts.yml Show resolved Hide resolved
.github/workflows/commit_artifacts.yml Outdated Show resolved Hide resolved
.github/workflows/commit_artifacts.yml Show resolved Hide resolved
Co-authored-by: Timothy Yung <yungsters@gmail.com>
@rickhanlonii rickhanlonii changed the title [WIP] Move @generated from build to sync Move @generated from build to sync Jun 10, 2024
@rickhanlonii rickhanlonii merged commit 6b35ff7 into facebook:main Jun 10, 2024
47 checks passed
@rickhanlonii rickhanlonii deleted the rh/generated branch June 10, 2024 14:17
@rickhanlonii rickhanlonii mentioned this pull request Jun 10, 2024
rickhanlonii added a commit that referenced this pull request Jun 10, 2024
## Overview

The clever trick in #29799 turns
out to not work because signedsource includes the generated hash in the
header. Reverts back to checking git diff, filtering out the REVISION
file and `@generated` headers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants