From 08fe7d0bb4d3075e3e11f91cc3a38526de1521f1 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 20 Feb 2023 14:43:24 +0000 Subject: [PATCH 01/17] Commit artifacts to react-fbsource-import repo --- .github/workflows/commit_artifacts.yml | 55 +++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index c7ca458044c06..a67f0b36bfb99 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -98,7 +98,7 @@ jobs: sed -i -e 's/ @license React*//' \ build/oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js \ build/oss-experimental/react-refresh/cjs/react-refresh-babel.development.js - - name: Move relevant files into compiled + - name: Move relevant files for React in www into compiled run: | mkdir -p ./compiled mkdir -p ./compiled/facebook-www @@ -122,6 +122,26 @@ jobs: mv build/oss-experimental/react-refresh/cjs/react-refresh-babel.development.js \ ./compiled/babel-plugin-react-refresh/index.js + ls -R ./compiled + - name: Move relevant files for React in fbsource into compiled-rn + run: | + BASE_FOLDER='compiled-rn/facebook-fbsource/xplat/js' + mkdir -p ${BASE_FOLDER}/react-native-github/Libraries/Renderer/ + mkdir -p ${BASE_FOLDER}/RKJSModules/vendor/{scheduler,react,react-is,react-test-renderer}/ + + # Move React Native renderer + mv build/react-native/implementations/ $BASE_FOLDER/react-native-github/Libraries/Renderer/ + mv build/react-native/shims/ $BASE_FOLDER/react-native-github/Libraries/Renderer/ + mv build/facebook-react-native/scheduler/cjs/ $BASE_FOLDER/RKJSModules/vendor/scheduler/ + mv build/facebook-react-native/react/cjs/ $BASE_FOLDER/RKJSModules/vendor/react/ + mv build/facebook-react-native/react-is/cjs/ $BASE_FOLDER/RKJSModules/vendor/react-is/ + mv build/facebook-react-native/react-test-renderer/cjs/ $BASE_FOLDER/RKJSModules/vendor/react-test-renderer/ + + # Delete OSS renderer. OSS renderer is synced through internal script. + RENDERER_FOLDER=$BASE_FOLDER/react-native-github/Libraries/Renderer/implementations/ + rm $RENDERER_FOLDER/ReactFabric-{dev,prod,profiling}.js + rm $RENDERER_FOLDER/ReactNativeRenderer-{dev,prod,profiling}.js + ls -R ./compiled - name: Add REVISION file run: | @@ -130,8 +150,12 @@ jobs: with: name: compiled path: compiled/ + - uses: actions/upload-artifact@v3 + with: + name: compiled-rn + path: compiled-rn/ - commit_artifacts: + commit_www_artifacts: needs: download_artifacts runs-on: ubuntu-latest steps: @@ -165,3 +189,30 @@ jobs: commit_user_name: ${{ github.actor }} commit_user_email: ${{ github.actor }}@users.noreply.github.com create_branch: true + file_pattern: 'compiled/facebook-www/' + + commit_fbsource_artifacts: + needs: download_artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: builds/facebook-fbsource + repository: facebook/react-fbsource-import + token: ${{secrets.PUSH_TOKEN}} + - name: Ensure clean directory + run: rm -rf compiled + - uses: actions/download-artifact@v3 + with: + name: compiled-rn + path: compiled-rn/ + - run: git status -u + - name: Commit changes to branch + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: | + ${{ github.event.head_commit.message }} + + DiffTrain build for commit https://github.com/facebook/react/commit/${{ github.sha }}. + commit_user_name: ${{ github.actor }} + commit_user_email: ${{ github.actor }}@users.noreply.github.com From e78b26b10400d1d37cbb40ff368a594b8c925f96 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:13:42 +0000 Subject: [PATCH 02/17] Change branch and fix deleted directory --- .github/workflows/commit_artifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index a67f0b36bfb99..a68405b190088 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -197,11 +197,11 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: builds/facebook-fbsource + ref: main repository: facebook/react-fbsource-import token: ${{secrets.PUSH_TOKEN}} - name: Ensure clean directory - run: rm -rf compiled + run: rm -rf compiled-rn - uses: actions/download-artifact@v3 with: name: compiled-rn From e914b30a2bf3850111dc3a12d69186c8117d18cb Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:15:41 +0000 Subject: [PATCH 03/17] test 1 --- .github/workflows/commit_artifacts.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index a68405b190088..4dc11e6d6b1d9 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -1,8 +1,10 @@ name: Commit Artifacts for Facebook WWW -on: - push: - branches: [main] +# on: +# push: +# branches: [main] + +on: [push] jobs: download_artifacts: From 1dabec52514ca8d7f3c062fa7fc16c18c2a7802a Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:21:28 +0000 Subject: [PATCH 04/17] add test code --- .github/workflows/commit_artifacts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 4dc11e6d6b1d9..c9e831772a730 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -39,9 +39,9 @@ jobs: let iter = 0; spinloop: while (iter < 15) { const res = await github.rest.repos.listCommitStatusesForRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.sha + owner: 'facebook', // context.repo.owner, + repo: 'react', // context.repo.repo, + ref: '55308554edb7a7d0c091c2ee4973ba5f4b06dfe8' // context.sha }); for (const status of res.data) { if (/process_artifacts_combined/.test(status.context)) { From f17ea0aae4d4e2409a2db54e9d715cfa6a212f0d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:23:21 +0000 Subject: [PATCH 05/17] Change action name --- .github/workflows/commit_artifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index c9e831772a730..a946e989097a6 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -1,4 +1,4 @@ -name: Commit Artifacts for Facebook WWW +name: Commit Artifacts for Facebook WWW and fbsource # on: # push: @@ -41,7 +41,7 @@ jobs: const res = await github.rest.repos.listCommitStatusesForRef({ owner: 'facebook', // context.repo.owner, repo: 'react', // context.repo.repo, - ref: '55308554edb7a7d0c091c2ee4973ba5f4b06dfe8' // context.sha + ref: '8fa41ffa275cae4895b650b0c3b5e8acdbb5055d' // context.sha }); for (const status of res.data) { if (/process_artifacts_combined/.test(status.context)) { From a26541d20334167ec8879501fc35d5ab14ca403d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:27:03 +0000 Subject: [PATCH 06/17] Use different ref --- .github/workflows/commit_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index a946e989097a6..531982049e8ff 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -41,7 +41,7 @@ jobs: const res = await github.rest.repos.listCommitStatusesForRef({ owner: 'facebook', // context.repo.owner, repo: 'react', // context.repo.repo, - ref: '8fa41ffa275cae4895b650b0c3b5e8acdbb5055d' // context.sha + ref: 'ef8bdbecb6dbb9743b895c2e867e5a5264dd6651' // context.sha }); for (const status of res.data) { if (/process_artifacts_combined/.test(status.context)) { From 00b856b12cfec885614084d7b15a36bebad22d80 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:29:04 +0000 Subject: [PATCH 07/17] console log res data --- .github/workflows/commit_artifacts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 531982049e8ff..fe1f56a768697 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -43,6 +43,7 @@ jobs: repo: 'react', // context.repo.repo, ref: 'ef8bdbecb6dbb9743b895c2e867e5a5264dd6651' // context.sha }); + console.log(res.data); for (const status of res.data) { if (/process_artifacts_combined/.test(status.context)) { switch (status.state) { From 23e52ea30f76b85e5aaa6c4218cd3def91ddeb8e Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:31:09 +0000 Subject: [PATCH 08/17] log data --- .github/workflows/commit_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index fe1f56a768697..1fddf077e93ec 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -43,7 +43,6 @@ jobs: repo: 'react', // context.repo.repo, ref: 'ef8bdbecb6dbb9743b895c2e867e5a5264dd6651' // context.sha }); - console.log(res.data); for (const status of res.data) { if (/process_artifacts_combined/.test(status.context)) { switch (status.state) { @@ -85,6 +84,7 @@ jobs: if (artifactsUrl != null) { const res = await fetch(artifactsUrl); const data = await res.json(); + console.log(data); for (const artifact of data) { if (artifact.path === 'build.tgz') { console.log(`Downloading and unzipping ${artifact.url}`); From 21970973b337ddb7e0c7d647ad38dc1921c088cb Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:32:41 +0000 Subject: [PATCH 09/17] save --- .github/workflows/commit_artifacts.yml | 51 +------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 1fddf077e93ec..0f3d3c59d58c9 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -33,56 +33,9 @@ jobs: }); } - let artifactsUrl = null; - // This is a temporary, dirty hack to avoid needing a GitHub auth token in the circleci - // workflow to notify this GitHub action. Sorry! - let iter = 0; - spinloop: while (iter < 15) { - const res = await github.rest.repos.listCommitStatusesForRef({ - owner: 'facebook', // context.repo.owner, - repo: 'react', // context.repo.repo, - ref: 'ef8bdbecb6dbb9743b895c2e867e5a5264dd6651' // context.sha - }); - for (const status of res.data) { - if (/process_artifacts_combined/.test(status.context)) { - switch (status.state) { - case 'pending': { - console.log(`${status.context} is still pending`); - break; - } - case 'failure': - case 'error': { - throw new Error(`${status.context} has failed or errored`); - } - case 'success': { - // The status does not include a build ID, but we can extract it - // from the URL. I couldn't find a better way to do this. - const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec( - status.target_url, - )[1]; - console.log(`CircleCI build id found: ${ciBuildId}`); - if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) { - artifactsUrl = - `https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`; - break spinloop; - } else { - throw new Error(`${ciBuildId} isn't a number`); - } - break; - } - default: { - throw new Error(`Unhandled status state: ${status.state}`); - break; - } - } - } - } - iter++; - console.log("Sleeping for 60s..."); - await sleep(60_000); - } + let artifactsUrl = 'https://circleci.com/api/v1.1/project/github/facebook/react/645534/artifacts'; if (artifactsUrl != null) { - const res = await fetch(artifactsUrl); + const res = await fetch(); const data = await res.json(); console.log(data); for (const artifact of data) { From 323b247b6bfe0288b56ad85aadc4290c0b3273d8 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:33:53 +0000 Subject: [PATCH 10/17] fix --- .github/workflows/commit_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 0f3d3c59d58c9..af0687f691891 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -35,7 +35,7 @@ jobs: let artifactsUrl = 'https://circleci.com/api/v1.1/project/github/facebook/react/645534/artifacts'; if (artifactsUrl != null) { - const res = await fetch(); + const res = await fetch(artifactsUrl); const data = await res.json(); console.log(data); for (const artifact of data) { From 32048429023c45268e17c43e0cf6f2db0f95d023 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:34:59 +0000 Subject: [PATCH 11/17] test --- .github/workflows/commit_artifacts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index af0687f691891..334aa94ea6e48 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -35,6 +35,7 @@ jobs: let artifactsUrl = 'https://circleci.com/api/v1.1/project/github/facebook/react/645534/artifacts'; if (artifactsUrl != null) { + console.log('about to fetch'); const res = await fetch(artifactsUrl); const data = await res.json(); console.log(data); From e5c67bce018bf057b25824e99adda9b54a6857d9 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:35:41 +0000 Subject: [PATCH 12/17] test --- .github/workflows/commit_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 334aa94ea6e48..51b463fb88390 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -35,7 +35,7 @@ jobs: let artifactsUrl = 'https://circleci.com/api/v1.1/project/github/facebook/react/645534/artifacts'; if (artifactsUrl != null) { - console.log('about to fetch'); + console.log('about to fetch', artifactsUrl); const res = await fetch(artifactsUrl); const data = await res.json(); console.log(data); From b6c5fec5d7a44e71983995840ffff7f4ce182972 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:50:18 +0000 Subject: [PATCH 13/17] test --- .github/workflows/commit_artifacts.yml | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 51b463fb88390..3b3e6d2b5bb62 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -33,23 +33,10 @@ jobs: }); } - let artifactsUrl = 'https://circleci.com/api/v1.1/project/github/facebook/react/645534/artifacts'; - if (artifactsUrl != null) { - console.log('about to fetch', artifactsUrl); - const res = await fetch(artifactsUrl); - const data = await res.json(); - console.log(data); - for (const artifact of data) { - if (artifact.path === 'build.tgz') { - console.log(`Downloading and unzipping ${artifact.url}`); - await execHelper( - `curl -L ${artifact.url} | tar -xvz` - ); - } - } - } else { - process.exitCode = 1; - } + let url = 'https://output.circle-artifacts.com/output/job/f2eb575f-7cf7-43ab-9b04-1178285adde6/artifacts/0/build.tgz'; + await execHelper( + `curl -L ${url} | tar -xvz` + ); - name: Strip @license from eslint plugin and react-refresh run: | sed -i -e 's/ @license React*//' \ From b75392166ff9d6a099058a0bb3041fdaa289dd18 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 17:51:32 +0000 Subject: [PATCH 14/17] test 32 --- .github/workflows/commit_artifacts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 3b3e6d2b5bb62..2421b89a2e8bd 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -37,6 +37,7 @@ jobs: await execHelper( `curl -L ${url} | tar -xvz` ); + - name: Strip @license from eslint plugin and react-refresh run: | sed -i -e 's/ @license React*//' \ From d5b983f4ef5b2cf7fb1edce9c1cd0412a9e77c22 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 18:03:50 +0000 Subject: [PATCH 15/17] test --- .github/workflows/commit_artifacts.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 2421b89a2e8bd..3b3e6d2b5bb62 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -37,7 +37,6 @@ jobs: await execHelper( `curl -L ${url} | tar -xvz` ); - - name: Strip @license from eslint plugin and react-refresh run: | sed -i -e 's/ @license React*//' \ From 515e7e38cedab6f0b7764e3e4ab4affcf2d1c165 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 18:06:18 +0000 Subject: [PATCH 16/17] Remove test code --- .github/workflows/commit_artifacts.yml | 74 ++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 3b3e6d2b5bb62..70f2648b01a5f 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -1,10 +1,8 @@ name: Commit Artifacts for Facebook WWW and fbsource -# on: -# push: -# branches: [main] - -on: [push] +on: + push: + branches: [main] jobs: download_artifacts: @@ -33,10 +31,68 @@ jobs: }); } - let url = 'https://output.circle-artifacts.com/output/job/f2eb575f-7cf7-43ab-9b04-1178285adde6/artifacts/0/build.tgz'; - await execHelper( - `curl -L ${url} | tar -xvz` - ); + let artifactsUrl = null; + // This is a temporary, dirty hack to avoid needing a GitHub auth token in the circleci + // workflow to notify this GitHub action. Sorry! + let iter = 0; + spinloop: while (iter < 15) { + const res = await github.rest.repos.listCommitStatusesForRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: context.sha + }); + for (const status of res.data) { + if (/process_artifacts_combined/.test(status.context)) { + switch (status.state) { + case 'pending': { + console.log(`${status.context} is still pending`); + break; + } + case 'failure': + case 'error': { + throw new Error(`${status.context} has failed or errored`); + } + case 'success': { + // The status does not include a build ID, but we can extract it + // from the URL. I couldn't find a better way to do this. + const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec( + status.target_url, + )[1]; + console.log(`CircleCI build id found: ${ciBuildId}`); + if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) { + artifactsUrl = + `https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`; + break spinloop; + } else { + throw new Error(`${ciBuildId} isn't a number`); + } + break; + } + default: { + throw new Error(`Unhandled status state: ${status.state}`); + break; + } + } + } + } + iter++; + console.log("Sleeping for 60s..."); + await sleep(60_000); + } + if (artifactsUrl != null) { + const res = await fetch(artifactsUrl); + const data = await res.json(); + for (const artifact of data) { + if (artifact.path === 'build.tgz') { + console.log(`Downloading and unzipping ${artifact.url}`); + await execHelper( + `curl -L ${artifact.url} | tar -xvz` + ); + } + } + } else { + process.exitCode = 1; + } - name: Strip @license from eslint plugin and react-refresh run: | sed -i -e 's/ @license React*//' \ From 20944a64bcdc965054fd41d206f75a62c0a29cac Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Mar 2023 18:29:13 +0000 Subject: [PATCH 17/17] Change token name and file pattern --- .github/workflows/commit_artifacts.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/commit_artifacts.yml b/.github/workflows/commit_artifacts.yml index 70f2648b01a5f..7b6599a25adf4 100644 --- a/.github/workflows/commit_artifacts.yml +++ b/.github/workflows/commit_artifacts.yml @@ -189,7 +189,6 @@ jobs: commit_user_name: ${{ github.actor }} commit_user_email: ${{ github.actor }}@users.noreply.github.com create_branch: true - file_pattern: 'compiled/facebook-www/' commit_fbsource_artifacts: needs: download_artifacts @@ -199,7 +198,7 @@ jobs: with: ref: main repository: facebook/react-fbsource-import - token: ${{secrets.PUSH_TOKEN}} + token: ${{secrets.FBSOURCE_SYNC_PUSH_TOKEN}} - name: Ensure clean directory run: rm -rf compiled-rn - uses: actions/download-artifact@v3