1- name : (Runtime) Commit Artifacts for Meta WWW and fbsource
1+ name : (Runtime) Commit Artifacts for Meta WWW and fbsource V2
22
33on :
4- push :
5- branches : [main, meta-www, meta-fbsource]
4+ workflow_run :
5+ workflows : ["(Runtime) Build and Test"]
6+ types : [completed]
7+ branches :
8+ - main
69
710env :
811 TZ : /usr/share/zoneinfo/America/Los_Angeles
@@ -49,102 +52,27 @@ jobs:
4952 run : |
5053 echo "www_branch_count=$(git ls-remote --heads origin "refs/heads/meta-www" | wc -l)" >> "$GITHUB_OUTPUT"
5154 echo "fbsource_branch_count=$(git ls-remote --heads origin "refs/heads/meta-fbsource" | wc -l)" >> "$GITHUB_OUTPUT"
52- - name : Download and unzip artifacts
53- uses : actions/github-script@v6
54- env :
55- CIRCLECI_TOKEN : ${{secrets.CIRCLECI_TOKEN_DIFFTRAIN}}
55+ - uses : actions/setup-node@v4
5656 with :
57- script : |
58- // TODO: Move this to a script file.
59- const cp = require('child_process');
60-
61- function sleep(ms) {
62- return new Promise(resolve => setTimeout(resolve, ms));
63- }
64-
65- function execHelper(command, options, streamStdout = false) {
66- return new Promise((resolve, reject) => {
67- const proc = cp.exec(
68- command,
69- options,
70- (error, stdout) => (error ? reject(error) : resolve(stdout.trim())),
71- );
72- if (streamStdout) {
73- proc.stdout.pipe(process.stdout);
74- }
75- });
76- }
77-
78- let artifactsUrl = null;
79- // This is a temporary, dirty hack to avoid needing a GitHub auth token in the circleci
80- // workflow to notify this GitHub action. Sorry!
81- let iter = 0;
82- spinloop: while (iter < 15) {
83- const res = await github.rest.repos.listCommitStatusesForRef({
84- owner: context.repo.owner,
85- repo: context.repo.repo,
86- ref: context.sha
87- });
88- for (const status of res.data) {
89- if (/process_artifacts_combined/.test(status.context)) {
90- switch (status.state) {
91- case 'pending': {
92- console.log(`${status.context} is still pending`);
93- break;
94- }
95- case 'failure':
96- case 'error': {
97- throw new Error(`${status.context} has failed or errored`);
98- }
99- case 'success': {
100- // The status does not include a build ID, but we can extract it
101- // from the URL. I couldn't find a better way to do this.
102- const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec(
103- status.target_url,
104- )[1];
105- if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) {
106- artifactsUrl =
107- `https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`;
108- console.log(`Found artifactsUrl: ${artifactsUrl}`);
109- break spinloop;
110- } else {
111- throw new Error(`${ciBuildId} isn't a number`);
112- }
113- break;
114- }
115- default: {
116- throw new Error(`Unhandled status state: ${status.state}`);
117- break;
118- }
119- }
120- }
121- }
122- iter++;
123- console.log("Sleeping for 60s...");
124- await sleep(60_000);
125- }
126- if (artifactsUrl != null) {
127- const {CIRCLECI_TOKEN} = process.env;
128- const res = await fetch(artifactsUrl, {
129- headers: {
130- 'Circle-Token': CIRCLECI_TOKEN
131- }
132- });
133- const data = await res.json();
134- if (!Array.isArray(data) && data.message != null) {
135- throw `CircleCI returned: ${data.message}`;
136- }
137- for (const artifact of data) {
138- if (artifact.path === 'build.tgz') {
139- console.log(`Downloading and unzipping ${artifact.url}`);
140- await execHelper(
141- `curl -L ${artifact.url} -H "Circle-Token: ${CIRCLECI_TOKEN}" | tar -xvz`
142- );
143- }
144- }
145- } else {
146- process.exitCode = 1;
147- }
57+ node-version : 18.20.1
58+ cache : yarn
59+ cache-dependency-path : yarn.lock
60+ - name : Restore cached node_modules
61+ uses : actions/cache@v4
62+ id : node_modules
63+ with :
64+ path : " **/node_modules"
65+ key : ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }}
66+ - run : yarn install --frozen-lockfile
67+ name : yarn install (react)
68+ - run : yarn install --frozen-lockfile
69+ name : yarn install (scripts/release)
70+ working-directory : scripts/release
71+ - name : Download artifacts for base revision
72+ run : |
73+ GH_TOKEN=${{ github.token }} scripts/release/download-experimental-build-ghaction.js --commit=${{ github.event.workflow_run.head_sha }}
74+ - name : Display structure of build
75+ run : ls -R build
14876 - name : Strip @license from eslint plugin and react-refresh
14977 run : |
15078 sed -i -e 's/ @license React*//' \
@@ -199,9 +127,9 @@ jobs:
199127 ls -R ./compiled-rn
200128 - name : Add REVISION files
201129 run : |
202- echo ${{ github.sha }} >> ./compiled/facebook-www/REVISION
130+ echo ${{ github.event.workflow_run.head_sha }} >> ./compiled/facebook-www/REVISION
203131 cp ./compiled/facebook-www/REVISION ./compiled/facebook-www/REVISION_TRANSFORMS
204- echo ${{ github.sha }} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
132+ echo ${{ github.event.workflow_run.head_sha }} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
205133 - name : " Get current version string"
206134 id : get_current_version
207135 run : |
@@ -214,11 +142,11 @@ jobs:
214142 echo "current_version_classic=$VERSION_CLASSIC" >> "$GITHUB_OUTPUT"
215143 echo "current_version_modern=$VERSION_MODERN" >> "$GITHUB_OUTPUT"
216144 echo "current_version_rn=$VERSION_NATIVE_FB" >> "$GITHUB_OUTPUT"
217- - uses : actions/upload-artifact@v3
145+ - uses : actions/upload-artifact@v4
218146 with :
219147 name : compiled
220148 path : compiled/
221- - uses : actions/upload-artifact@v3
149+ - uses : actions/upload-artifact@v4
222150 with :
223151 name : compiled-rn
224152 path : compiled-rn/
@@ -233,7 +161,7 @@ jobs:
233161 ref : builds/facebook-www
234162 - name : Ensure clean directory
235163 run : rm -rf compiled
236- - uses : actions/download-artifact@v3
164+ - uses : actions/download-artifact@v4
237165 with :
238166 name : compiled
239167 path : compiled/
@@ -298,12 +226,12 @@ jobs:
298226 uses : stefanzweifel/git-auto-commit-action@v4
299227 with :
300228 commit_message : |
301- ${{ github.event.head_commit.message }}
229+ ${{ github.event.workflow_run. head_commit.message }}
302230
303- DiffTrain build for [${{ github.sha }}](https://github.com/facebook/react/commit/${{ github.sha }})
231+ DiffTrain build for [${{ github.event.workflow_run.head_sha }}](https://github.com/facebook/react/commit/${{ github.event.workflow_run.head_sha }})
304232 branch : builds/facebook-www
305- commit_user_name : ${{ github.actor }}
306- commit_user_email : ${{ github.actor }} @users.noreply.github.com
233+ commit_user_name : ${{ github.event.workflow_run.triggering_actor.login }}
234+ commit_user_email : ${{ github.event.workflow_run.triggering_actor.email || format('{0} @users.noreply.github.com', github.event.workflow_run.triggering_actor.login) }}
307235 create_branch : true
308236
309237 commit_fbsource_artifacts :
@@ -316,7 +244,7 @@ jobs:
316244 ref : builds/facebook-fbsource
317245 - name : Ensure clean directory
318246 run : rm -rf compiled-rn
319- - uses : actions/download-artifact@v3
247+ - uses : actions/download-artifact@v4
320248 with :
321249 name : compiled-rn
322250 path : compiled-rn/
@@ -365,7 +293,7 @@ jobs:
365293 git add .
366294 - name : Signing files
367295 if : steps.check_should_commit.outputs.should_commit == 'true'
368- uses : actions/github-script@v6
296+ uses : actions/github-script@v7
369297 with :
370298 script : |
371299 // TODO: Move this to a script file.
@@ -456,10 +384,10 @@ jobs:
456384 uses : stefanzweifel/git-auto-commit-action@v4
457385 with :
458386 commit_message : |
459- ${{ github.event.head_commit.message }}
387+ ${{ github.event.workflow_run. head_commit.message }}
460388
461- DiffTrain build for commit https://github.com/facebook/react/commit/${{ github.sha }}.
389+ DiffTrain build for commit https://github.com/facebook/react/commit/${{ github.event.workflow_run.head_sha }}.
462390 branch : builds/facebook-fbsource
463- commit_user_name : ${{ github.actor }}
464- commit_user_email : ${{ github.actor }} @users.noreply.github.com
391+ commit_user_name : ${{ github.event.workflow_run.triggering_actor.login }}
392+ commit_user_email : ${{ github.event.workflow_run.triggering_actor.email || format('{0} @users.noreply.github.com', github.event.workflow_run.triggering_actor.login) }}
465393 create_branch : true
0 commit comments