Skip to content

Commit a9d9cc2

Browse files
sadatsajidclaude
andcommitted
Merge main into fix/generated-types-strict-lib-check
Resolve the ReactNativeApi.d.ts conflict by regenerating it with `yarn build-types`, keeping both the usePressability signature from this branch and useVerticalBarEdgeIOS from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 parents 4290277 + a1b2862 commit a9d9cc2

243 files changed

Lines changed: 9466 additions & 1793 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.eslintrc.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ module.exports = {
6161
files: ['package.json'],
6262
parser: 'jsonc-eslint-parser',
6363
},
64+
{
65+
// Generated bundles carry `@nolint`, which this lint run does not honor.
66+
files: ['private/eslint-plugin-monorepo/rules/sort-imports.js'],
67+
rules: {
68+
'ft-flow/require-valid-file-annotation': 'off',
69+
},
70+
},
6471
{
6572
files: ['flow-typed/**/*.js', 'packages/react-native/flow/**/*'],
6673
rules: {

‎.flowconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ untyped-import
9797
untyped-type-import
9898

9999
[version]
100-
^0.338.0
100+
^0.340.0

‎.github/workflow-scripts/__tests__/visual-compare-test.js‎

Lines changed: 94 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
*/
1010

1111
const {compareCapture, compareImages, policyFor} = require('../visual/compare');
12-
const {resolveContext, stageBaseline} = require('../visual/compare-run');
12+
const {
13+
comparePlatform,
14+
resolveContext,
15+
stageBaseline,
16+
} = require('../visual/compare-run');
1317
const {buildManifest, sha256} = require('../visual/manifest');
1418
const {readPngDimensions} = require('../visual/png');
1519
const {validateCapture} = require('../visual/validate');
@@ -281,36 +285,107 @@ describe('visual comparison', () => {
281285
});
282286
});
283287

288+
describe('comparePlatform', () => {
289+
afterEach(() => {
290+
jest.restoreAllMocks();
291+
});
292+
293+
test('reads expected images from blobs for a blobs baseline', async () => {
294+
const captureDir = path.join(directory, 'capture');
295+
const white = makePng(4, 4);
296+
const black = makePng(4, 4, () => [0, 0, 0, 255]);
297+
const manifest = writeCapture(captureDir, {
298+
'text/changed/default': black,
299+
});
300+
const baselineManifest = {
301+
...manifest,
302+
imageStore: 'blobs',
303+
images: [{id: 'text/changed/default', sha256: sha256(white)}],
304+
};
305+
const objects = new Map([
306+
[
307+
`baselines/${manifest.environmentKey}/${SHA_B}/manifest.json`,
308+
Buffer.from(JSON.stringify(baselineManifest)),
309+
],
310+
[`blobs/${sha256(white)}.png`, white],
311+
]);
312+
const fetched = [];
313+
jest.spyOn(global, 'fetch').mockImplementation(async url => {
314+
const key = url.replace('https://bucket.test/', '');
315+
fetched.push(key);
316+
const body = objects.get(key);
317+
return body == null
318+
? new Response(null, {status: 404})
319+
: new Response(body, {status: 200});
320+
});
321+
322+
const result = await comparePlatform({
323+
github: {
324+
isOnBranch: async () => true,
325+
ancestry: async () => [SHA_B],
326+
},
327+
context: {headSha: SHA_A, defaultBranch: 'main'},
328+
captureDir,
329+
config: null,
330+
publicBaseUrl: 'https://bucket.test',
331+
outDir: path.join(directory, 'out'),
332+
prefix: 'reports/test',
333+
});
334+
335+
expect(fetched).toContain(`blobs/${sha256(white)}.png`);
336+
expect(result.baseline).toEqual({
337+
sha: SHA_B,
338+
distance: 0,
339+
imageStore: 'blobs',
340+
});
341+
expect(result.results.map(r => [r.id, r.status])).toEqual([
342+
['text/changed/default', 'changed'],
343+
]);
344+
});
345+
});
346+
284347
describe('stageBaseline', () => {
285-
test('leaves out unstable screenshots', () => {
348+
test('stages blobs not yet uploaded and a manifest that refers to them', async () => {
286349
const captureDir = path.join(directory, 'capture');
287350
const outDir = path.join(directory, 'out');
351+
const white = makePng(4, 4);
352+
const black = makePng(4, 4, () => [0, 0, 0, 255]);
353+
const grey = makePng(4, 4, () => [128, 128, 128, 255]);
288354
const manifest = writeCapture(captureDir, {
289-
'text/stable/default': makePng(4, 4),
290-
'text/unstable/default': makePng(4, 4),
355+
'text/uploaded/default': white,
356+
'text/new/default': black,
357+
'text/new/same': black,
358+
'text/unstable/default': grey,
359+
});
360+
manifest.images.find(
361+
image => image.id === 'text/unstable/default',
362+
).unstable = true;
363+
await stageBaseline({
364+
outDir,
365+
captureDir,
366+
manifest,
367+
sha: SHA_A,
368+
blobExists: async key => key === `blobs/${sha256(white)}.png`,
291369
});
292-
manifest.images[1].unstable = true;
293-
stageBaseline({outDir, captureDir, manifest, sha: SHA_A});
294-
const prefix = `baselines/${manifest.environmentKey}/${SHA_A}`;
295370
const staged = JSON.parse(
296371
fs.readFileSync(
297-
path.join(outDir, 'baseline-manifests', prefix, 'manifest.json'),
372+
path.join(
373+
outDir,
374+
'baseline-manifests',
375+
`baselines/${manifest.environmentKey}/${SHA_A}/manifest.json`,
376+
),
298377
'utf8',
299378
),
300379
);
301-
expect(staged.images.map(image => image.id)).toEqual([
302-
'text/stable/default',
380+
expect(staged.imageStore).toBe('blobs');
381+
expect(staged.images.map(image => image.id).sort()).toEqual([
382+
'text/new/default',
383+
'text/new/same',
384+
'text/uploaded/default',
303385
]);
304386
expect(
305-
fs.existsSync(
306-
path.join(
307-
outDir,
308-
'baseline-images',
309-
prefix,
310-
'text/unstable/default.png',
311-
),
312-
),
313-
).toBe(false);
387+
fs.readdirSync(path.join(outDir, 'baseline-blobs', 'blobs')),
388+
).toEqual([`${sha256(black)}.png`]);
314389
});
315390
});
316391

‎.github/workflow-scripts/__tests__/visual-report-test.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const {
2020
} = require('../visual/report');
2121
const {
2222
approvalKey,
23+
baselineImageKey,
2324
baselinePrefix,
25+
blobKey,
2426
publicUrl,
2527
reportPrefix,
2628
} = require('../visual/storage');
@@ -48,8 +50,21 @@ describe('visual reports and approval', () => {
4850
);
4951
});
5052

53+
test.each([
54+
['blobs', `blobs/${'a'.repeat(64)}.png`],
55+
[null, `baselines/ios-x-0123abcd/${SHA_A}/text/basic/default.png`],
56+
])('finds a baseline image with imageStore %p', (imageStore, key) => {
57+
expect(
58+
baselineImageKey(
59+
{environmentKey: 'ios-x-0123abcd', sha: SHA_A, imageStore},
60+
{id: 'text/basic/default', sha256: 'a'.repeat(64)},
61+
),
62+
).toBe(key);
63+
});
64+
5165
test.each([
5266
[() => baselinePrefix('k', 'main')],
67+
[() => blobKey('../x')],
5368
[
5469
() =>
5570
reportPrefix({prNumber: -1, headSha: SHA_A, runId: 1, runAttempt: 1}),
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Copies Test All's test results for one run attempt to GCS, for
8+
# upload-test-results.yml. Artifacts, including those from forks, are treated
9+
# as inert data: only each one's results.json is copied, after validation, and
10+
# nothing in them is executed.
11+
#
12+
# upload-test-results.sh list Stage artifacts.json, and output whether
13+
# this attempt should be recorded
14+
# upload-test-results.sh collect Stage each downloaded results.json
15+
# upload-test-results.sh describe Stage run.json from $WORKFLOW_RUN
16+
# upload-test-results.sh upload Copy $DEST to $PREFIX, run.json last
17+
18+
set -euo pipefail
19+
20+
MAX_RESULTS_BYTES=1048576
21+
STATE_ARTIFACT='^e2e_[a-z]+_[a-z]+_state_[A-Za-z0-9_-]+$'
22+
# The artifacts the workflow's e2e_*_state_* download pattern matches.
23+
DOWNLOAD_PATTERN='^e2e_.*_state_'
24+
25+
retry() {
26+
for attempt in 1 2 3; do
27+
"$@" && return 0
28+
echo "Attempt $attempt failed"
29+
sleep $((attempt * 10))
30+
done
31+
return 1
32+
}
33+
34+
list_artifacts() {
35+
gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts?per_page=100" --jq '.artifacts[]' > /tmp/artifacts.jsonl
36+
}
37+
38+
list() {
39+
mkdir -p "$DEST"
40+
retry list_artifacts
41+
# A rerun replaces the per-flow state of the jobs it reruns, so once a later
42+
# attempt has replaced any, this attempt's results are gone and it isn't
43+
# recorded.
44+
if jq -e --slurp --arg pattern "$DOWNLOAD_PATTERN" '[.[] | select(.created_at > env.RUN_UPDATED_AT and (.name | test($pattern)))] | length > 0' /tmp/artifacts.jsonl > /dev/null; then
45+
echo "A later attempt replaced this attempt's test state, so it isn't recorded"
46+
echo "record=false" >> "$GITHUB_OUTPUT"
47+
return
48+
fi
49+
# Every artifact from this attempt, so recordings and logs can be linked.
50+
jq --slurp --arg base "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts" '[.[]
51+
| select(.created_at <= env.RUN_UPDATED_AT)
52+
| {id, name, sizeInBytes: .size_in_bytes, createdAt: .created_at, expiresAt: .expires_at, expired, url: "\($base)/\(.id)"}]' \
53+
/tmp/artifacts.jsonl > "$DEST/artifacts.json"
54+
echo "record=true" >> "$GITHUB_OUTPUT"
55+
}
56+
57+
# Stages one artifact's results.json, if it's a regular file of valid JSON
58+
# within the size limit.
59+
copy_results() {
60+
local name=$1 file=$2
61+
if [[ "$name" =~ $STATE_ARTIFACT && -f "$file" && ! -L "$file" ]] &&
62+
(( $(wc -c < "$file") <= MAX_RESULTS_BYTES )) && jq empty "$file" 2>/dev/null; then
63+
mkdir -p "$DEST/artifacts/$name"
64+
cp "$file" "$DEST/artifacts/$name/results.json"
65+
else
66+
echo "Skipping ${name:-artifact}: no results.json, too large or not JSON"
67+
fi
68+
}
69+
70+
collect() {
71+
mkdir -p "$DEST/artifacts"
72+
# download-artifact extracts a single matching artifact without a directory
73+
# of its own.
74+
if [[ -e "$DOWNLOADS/results.json" ]]; then
75+
copy_results "$(jq -r --arg pattern "$DOWNLOAD_PATTERN" '[.[].name | select(test($pattern))] | if length == 1 then .[0] else "" end' "$DEST/artifacts.json")" "$DOWNLOADS/results.json"
76+
else
77+
for dir in "$DOWNLOADS"/*/; do
78+
if [[ -d "$dir" ]]; then
79+
copy_results "$(basename "$dir")" "$dir/results.json"
80+
fi
81+
done
82+
fi
83+
find "$DEST" -type f
84+
}
85+
86+
describe() {
87+
# pull_requests omits fork PRs and can list unrelated PRs on a push, so only
88+
# PRs into this repository are kept, and only for pull request runs. The head
89+
# repository and branch identify a fork PR.
90+
jq --argjson repoId "$REPO_ID" '{
91+
repository: .repository.full_name,
92+
runId: .id,
93+
runAttempt: .run_attempt,
94+
event,
95+
conclusion,
96+
headSha: .head_sha,
97+
headBranch: .head_branch,
98+
headRepository: .head_repository.full_name,
99+
pullRequests: (if .event == "pull_request"
100+
then [.pull_requests[] | select(.base.repo.id == $repoId) | .number]
101+
else [] end),
102+
createdAt: .created_at,
103+
runStartedAt: .run_started_at,
104+
updatedAt: .updated_at,
105+
url: .html_url
106+
}' <<< "$WORKFLOW_RUN" > "$DEST/run.json"
107+
cat "$DEST/run.json"
108+
}
109+
110+
upload() {
111+
if [[ -n "$(ls -A "$DEST/artifacts")" ]]; then
112+
retry gcloud storage cp --recursive --no-clobber "$DEST/artifacts" "$PREFIX/"
113+
fi
114+
retry gcloud storage cp --no-clobber "$DEST/artifacts.json" "$PREFIX/artifacts.json"
115+
# A run is complete once its run.json exists, so it goes last.
116+
retry gcloud storage cp --no-clobber "$DEST/run.json" "$PREFIX/run.json"
117+
}
118+
119+
case "${1:-}" in
120+
list | collect | describe | upload) "$1" ;;
121+
*)
122+
echo "Usage: $0 list|collect|describe|upload" >&2
123+
exit 1
124+
;;
125+
esac

0 commit comments

Comments
 (0)