@samitouri / QOS-React-1 / commits / 5ad2c37273

Skip empty sync commits (both repos) (#29707)

Requires https://github.com/facebook/react/pull/29706 The strategy here is to: - Checkout the builds/facebook-www branch - Read the current sync'd VERSION - Checkout out main and sync new build - sed/{new version string}/{old version string} - Run git status, skip sync if clean - Otherwise, sed/{old version string}/{new version string} and push commit This means that: - We're using the real version strings from the builds - We are checking the last commit on the branch for the real last version - We're skipping any commits that won't result in changes - ??? - Profit!

Ricky committed Jun 3, 2024 at 10:09 UTC 5ad2c37273b7c192011010c6bdb9ac0a4c9c232f
2 files changed +164 -6
.github/workflows/commit_artifacts.yml
+139 -4
@@ -10,7 +10,36 @@ jobs:
10 outputs:
11 www_branch_count: ${{ steps.check_branches.outputs.www_branch_count }}
12 fbsource_branch_count: ${{ steps.check_branches.outputs.fbsource_branch_count }}
13 + last_version_classic: ${{ steps.get_last_version_www.outputs.last_version_classic }}
14 + last_version_modern: ${{ steps.get_last_version_www.outputs.last_version_modern }}
15 + last_version_rn: ${{ steps.get_last_version_rn.outputs.last_version_rn }}
16 + current_version_classic: ${{ steps.get_current_version.outputs.current_version_classic }}
17 + current_version_modern: ${{ steps.get_current_version.outputs.current_version_modern }}
18 + current_version_rn: ${{ steps.get_current_version.outputs.current_version_rn }}
19 steps:
20 + - uses: actions/checkout@v4
21 + with:
22 + ref: builds/facebook-www
23 + - name: "Get last version string for www"
24 + id: get_last_version_www
25 + run: |
26 + # Empty checks only needed for backwards compatibility,can remove later.
27 + VERSION_CLASSIC=$( [ -f ./compiled/facebook-www/VERSION_CLASSIC ] && cat ./compiled/facebook-www/VERSION_CLASSIC || echo '' )
28 + VERSION_MODERN=$( [ -f ./compiled/facebook-www/VERSION_MODERN ] && cat ./compiled/facebook-www/VERSION_MODERN || echo '' )
29 + echo "Last classic version is $VERSION_CLASSIC"
30 + echo "Last modern version is $VERSION_MODERN"
31 + echo "last_version_classic=$VERSION_CLASSIC" >> "$GITHUB_OUTPUT"
32 + echo "last_version_modern=$VERSION_MODERN" >> "$GITHUB_OUTPUT"
33 + - uses: actions/checkout@v4
34 + with:
35 + ref: builds/facebook-fbsource
36 + - name: "Get last version string for rn"
37 + id: get_last_version_rn
38 + run: |
39 + # Empty checks only needed for backwards compatibility,can remove later.
40 + VERSION_NATIVE_FB=$( [ -f ./compiled-rn/VERSION_NATIVE_FB ] && cat ./compiled-rn/VERSION_NATIVE_FB || echo '' )
41 + echo "Last rn version is $VERSION_NATIVE_FB"
42 + echo "last_version_rn=$VERSION_NATIVE_FB" >> "$GITHUB_OUTPUT"
43 - uses: actions/checkout@v4
44 - name: "Check branches"
45 id: check_branches
@@ -160,12 +189,27 @@ jobs:
189 rm $RENDERER_FOLDER/ReactFabric-{dev,prod,profiling}.js
190 rm $RENDERER_FOLDER/ReactNativeRenderer-{dev,prod,profiling}.js
191
163 - ls -R ./compiled
192 + # Move React Native version file
193 + mv build/facebook-react-native/VERSION_NATIVE_FB ./compiled-rn/VERSION_NATIVE_FB
194 +
195 + ls -R ./compiled-rn
196 - name: Add REVISION files
197 run: |
198 echo ${{ github.sha }} >> ./compiled/facebook-www/REVISION
199 cp ./compiled/facebook-www/REVISION ./compiled/facebook-www/REVISION_TRANSFORMS
200 echo ${{ github.sha }} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
201 + - name: "Get current version string"
202 + id: get_current_version
203 + run: |
204 + VERSION_CLASSIC=$(cat ./compiled/facebook-www/VERSION_CLASSIC)
205 + VERSION_MODERN=$(cat ./compiled/facebook-www/VERSION_MODERN)
206 + VERSION_NATIVE_FB=$(cat ./compiled-rn/VERSION_NATIVE_FB)
207 + echo "Current classic version is $VERSION_CLASSIC"
208 + echo "Current modern version is $VERSION_MODERN"
209 + echo "Current rn version is $VERSION_NATIVE_FB"
210 + echo "current_version_classic=$VERSION_CLASSIC" >> "$GITHUB_OUTPUT"
211 + echo "current_version_modern=$VERSION_MODERN" >> "$GITHUB_OUTPUT"
212 + echo "current_version_rn=$VERSION_NATIVE_FB" >> "$GITHUB_OUTPUT"
213 - uses: actions/upload-artifact@v3
214 with:
215 name: compiled
@@ -189,8 +233,60 @@ jobs:
233 with:
234 name: compiled
235 path: compiled/
192 - - run: git status -u
236 + - name: Revert version changes
237 + if: needs.download_artifacts.outputs.last_version_classic != '' && needs.download_artifacts.outputs.last_version_modern != ''
238 + env:
239 + CURRENT_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.current_version_classic }}
240 + CURRENT_VERSION_MODERN: ${{ needs.download_artifacts.outputs.current_version_modern }}
241 + LAST_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.last_version_classic }}
242 + LAST_VERSION_MODERN: ${{ needs.download_artifacts.outputs.last_version_modern }}
243 + run: |
244 + echo "Reverting $CURRENT_VERSION_CLASSIC to $LAST_VERSION_CLASSIC"
245 + grep -rl "$CURRENT_VERSION_CLASSIC" ./compiled || echo "No files found with $CURRENT_VERSION_CLASSIC"
246 + grep -rl "$CURRENT_VERSION_CLASSIC" ./compiled | xargs -r sed -i -e "s/$CURRENT_VERSION_CLASSIC/$LAST_VERSION_CLASSIC/g"
247 + grep -rl "$CURRENT_VERSION_CLASSIC" ./compiled || echo "Classic version reverted"
248 + echo "===================="
249 + echo "Reverting $CURRENT_VERSION_MODERN to $LAST_VERSION_MODERN"
250 + grep -rl "$CURRENT_VERSION_MODERN" ./compiled || echo "No files found with $CURRENT_VERSION_MODERN"
251 + grep -rl "$CURRENT_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$CURRENT_VERSION_MODERN/$LAST_VERSION_MODERN/g"
252 + grep -rl "$CURRENT_VERSION_MODERN" ./compiled || echo "Modern version reverted"
253 + - name: Check if only the REVISION file has changed
254 + id: check_should_commit
255 + run: |
256 + echo "Full git status"
257 + git status
258 + echo "===================="
259 + if git status --porcelain | grep -qv '/REVISION'; then
260 + echo "Changes detected"
261 + echo "should_commit=true" >> "$GITHUB_OUTPUT"
262 + else
263 + echo "No Changes detected"
264 + echo "should_commit=false" >> "$GITHUB_OUTPUT"
265 + fi
266 + - name: Re-apply version changes
267 + if: steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_classic != '' && needs.download_artifacts.outputs.last_version_modern != ''
268 + env:
269 + CURRENT_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.current_version_classic }}
270 + CURRENT_VERSION_MODERN: ${{ needs.download_artifacts.outputs.current_version_modern }}
271 + LAST_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.last_version_classic }}
272 + LAST_VERSION_MODERN: ${{ needs.download_artifacts.outputs.last_version_modern }}
273 + run: |
274 + echo "Re-applying $LAST_VERSION_CLASSIC to $CURRENT_VERSION_CLASSIC"
275 + grep -rl "$LAST_VERSION_CLASSIC" ./compiled || echo "No files found with $LAST_VERSION_CLASSIC"
276 + grep -rl "$LAST_VERSION_CLASSIC" ./compiled | xargs -r sed -i -e "s/$LAST_VERSION_CLASSIC/$CURRENT_VERSION_CLASSIC/g"
277 + grep -rl "$LAST_VERSION_CLASSIC" ./compiled || echo "Classic version re-applied"
278 + echo "===================="
279 + echo "Re-applying $LAST_VERSION_MODERN to $CURRENT_VERSION_MODERN"
280 + grep -rl "$LAST_VERSION_MODERN" ./compiled || echo "No files found with $LAST_VERSION_MODERN"
281 + grep -rl "$LAST_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$LAST_VERSION_MODERN/$CURRENT_VERSION_MODERN/g"
282 + grep -rl "$LAST_VERSION_MODERN" ./compiled || echo "Classic version re-applied"
283 + - name: Will commit these changes
284 + if: steps.check_should_commit.outputs.should_commit == 'true'
285 + run: |
286 + echo ":"
287 + git status -u
288 - name: Commit changes to branch
289 + if: false && steps.check_should_commit.outputs.should_commit == 'true'
290 uses: stefanzweifel/git-auto-commit-action@v4
291 with:
292 commit_message: |
@@ -211,13 +307,52 @@ jobs:
307 with:
308 ref: builds/facebook-fbsource
309 - name: Ensure clean directory
214 - run: rm -rf compiled
310 + run: rm -rf compiled-rn
311 - uses: actions/download-artifact@v3
312 with:
313 name: compiled-rn
314 path: compiled-rn/
219 - - run: git status -u
315 + - name: Revert version changes
316 + if: needs.download_artifacts.outputs.last_version_rn != ''
317 + env:
318 + CURRENT_VERSION: ${{ needs.download_artifacts.outputs.current_version_rn }}
319 + LAST_VERSION: ${{ needs.download_artifacts.outputs.last_version_rn }}
320 + run: |
321 + echo "Reverting $CURRENT_VERSION to $LAST_VERSION"
322 + grep -rl "$CURRENT_VERSION" ./compiled-rn || echo "No files found with $CURRENT_VERSION"
323 + grep -rl "$CURRENT_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$CURRENT_VERSION/$LAST_VERSION/g"
324 + grep -rl "$CURRENT_VERSION" ./compiled-rn || echo "Version reverted"
325 + - name: Check if only the REVISION file has changed
326 + id: check_should_commit
327 + run: |
328 + echo "Full git status"
329 + git status
330 + echo "===================="
331 + echo "Checking for changes"
332 + if git status --porcelain | grep -qv '/REVISION'; then
333 + echo "Changes detected"
334 + echo "should_commit=true" >> "$GITHUB_OUTPUT"
335 + else
336 + echo "No Changes detected"
337 + echo "should_commit=false" >> "$GITHUB_OUTPUT"
338 + fi
339 + - name: Re-apply version changes
340 + if: steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_rn != ''
341 + env:
342 + CURRENT_VERSION: ${{ needs.download_artifacts.outputs.current_version_rn }}
343 + LAST_VERSION: ${{ needs.download_artifacts.outputs.last_version_rn }}
344 + run: |
345 + echo "Re-applying $LAST_VERSION to $CURRENT_VERSION"
346 + grep -rl "$LAST_VERSION" ./compiled-rn || echo "No files found with $LAST_VERSION"
347 + grep -rl "$LAST_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$LAST_VERSION/$CURRENT_VERSION/g"
348 + grep -rl "$LAST_VERSION" ./compiled-rn || echo "Version re-applied"
349 + - name: Will commit these changes
350 + if: steps.check_should_commit.outputs.should_commit == 'true'
351 + run: |
352 + echo ":"
353 + git status -u
354 - name: Commit changes to branch
355 + if: steps.check_should_commit.outputs.should_commit == 'true'
356 uses: stefanzweifel/git-auto-commit-action@v4
357 with:
358 commit_message: |
scripts/rollup/build-all-release-channels.js
+25 -2
@@ -167,10 +167,14 @@ function processStable(buildDir) {
167 fs.renameSync(filePath, filePath.replace('.js', '.classic.js'));
168 }
169 }
170 + const versionString =
171 + ReactVersion + '-www-classic-' + sha + '-' + dateString;
172 updatePlaceholderReactVersionInCompiledArtifacts(
173 buildDir + '/facebook-www',
172 - ReactVersion + '-www-classic-' + sha + '-' + dateString
174 + versionString
175 );
176 + // Also save a file with the version number
177 + fs.writeFileSync(buildDir + '/facebook-www/VERSION_CLASSIC', versionString);
178 }
179
180 if (fs.existsSync(buildDir + '/sizes')) {
@@ -213,9 +217,28 @@ function processExperimental(buildDir, version) {
217 fs.renameSync(filePath, filePath.replace('.js', '.modern.js'));
218 }
219 }
220 + const versionString =
221 + ReactVersion + '-www-modern-' + sha + '-' + dateString;
222 updatePlaceholderReactVersionInCompiledArtifacts(
223 buildDir + '/facebook-www',
218 - ReactVersion + '-www-modern-' + sha + '-' + dateString
224 + versionString
225 + );
226 +
227 + // Also save a file with the version number
228 + fs.writeFileSync(buildDir + '/facebook-www/VERSION_MODERN', versionString);
229 + }
230 +
231 + if (fs.existsSync(buildDir + '/facebook-react-native')) {
232 + const versionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
233 + updatePlaceholderReactVersionInCompiledArtifacts(
234 + buildDir + '/facebook-react-native',
235 + versionString
236 + );
237 +
238 + // Also save a file with the version number
239 + fs.writeFileSync(
240 + buildDir + '/facebook-react-native/VERSION_NATIVE_FB',
241 + versionString
242 );
243 }
244