Skip to content

Commit 9430a12

Browse files
iamAbhi-916acoates-msazure-pipelines[bot]rnbotvmoroz
authored
fix: include hidden files in perf artifact upload to restore PR comments (#15893)
* fix: resolve artifact path mismatch in perf-comment workflow * fix: include hidden files in perf artifact upload * fix: auto-discover native perf results in compare report * Do not create m_childrenContainer when using a custom visual to mount children into (#15877) * Do not create m_childrenContainer when using a custom visual to mount children into * Change files * fix * RELEASE: Releasing 10 package(s) (main) (#15885) Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com> * Implement onClick (#15889) * Implement onClick * Change files * RELEASE: Releasing 10 package(s) (main) (#15891) Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com> * Fork ubroken module (#15892) * fix: auto-discover native perf results in compare report * Change files * fix: capture live run metrics in PerfJsonReporter instead of re-reading baselines * Change files * fix: use temp files for cross-process live metrics * lint fix * make touchableOpacity less noisy * Change files * codegen build fix * revert: undo codegen changes (schema version mismatch) --------- Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Co-authored-by: azure-pipelines[bot] <36771401+azure-pipelines[bot]@users.noreply.github.com> Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com> Co-authored-by: Vladimir Morozov <vmorozov@microsoft.com>
1 parent 13bd0bf commit 9430a12

17 files changed

+191
-60
lines changed

.github/workflows/perf-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
uses: actions/upload-artifact@v4
106106
with:
107107
name: perf-results
108+
include-hidden-files: true
108109
path: |
109110
packages/e2e-test-app-fabric/.perf-results/
110111
packages/e2e-test-app-fabric/.native-perf-results/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: auto-discover native perf results in compare report",
4+
"packageName": "@react-native-windows/automation",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: auto-discover native perf results in compare report",
4+
"packageName": "@react-native-windows/automation-channel",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: auto-discover native perf results in compare report",
4+
"packageName": "@react-native-windows/automation-commands",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: capture live run metrics in PerfJsonReporter instead of re-reading baselines",
4+
"packageName": "@react-native-windows/codegen",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: capture live run metrics in PerfJsonReporter instead of re-reading baselines",
4+
"packageName": "@react-native-windows/perf-testing",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: auto-discover native perf results in compare report",
4+
"packageName": "react-native-windows",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/@react-native-windows/perf-testing/src/ci/PerfJsonReporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ export class PerfJsonReporter {
7878
const suites: SuiteResult[] = [];
7979

8080
for (const suite of results.testResults) {
81-
// Load the snapshot file for this test suite (written by toMatchPerfSnapshot)
81+
// Use live run metrics captured during the test run
8282
const {file: snapshotFilePath} = SnapshotManager.getSnapshotPath(
8383
suite.testFilePath,
8484
);
85-
const snapshots = SnapshotManager.load(snapshotFilePath);
85+
const snapshots = SnapshotManager.getRunMetrics(snapshotFilePath) ?? {};
8686

8787
const passed = suite.testResults.filter(
8888
t => t.status === 'passed',

packages/@react-native-windows/perf-testing/src/matchers/snapshotManager.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import fs from '@react-native-windows/fs';
99
import * as path from 'path';
10+
import * as os from 'os';
1011
import type {PerfMetrics} from '../interfaces/PerfMetrics';
1112
import type {PerfThreshold} from '../interfaces/PerfThreshold';
1213

@@ -26,8 +27,63 @@ export type SnapshotFile = Record<string, SnapshotEntry>;
2627

2728
/**
2829
* Manages reading and writing of perf snapshot files.
30+
* Also writes live run metrics to a temp directory so the CI reporter
31+
* (which runs in the Jest main process) can access fresh results
32+
* from the worker process.
2933
*/
3034
export class SnapshotManager {
35+
/** Directory for live run metrics (cross-process via temp files). */
36+
private static readonly _runMetricsDir =
37+
process.env.PERF_RUN_METRICS_DIR ||
38+
path.join(os.tmpdir(), 'rnw-perf-run-metrics');
39+
40+
/** Record a live metric entry for the current run (written to temp file). */
41+
static recordRunMetric(
42+
snapshotFilePath: string,
43+
key: string,
44+
entry: SnapshotEntry,
45+
): void {
46+
const metricsFile = path.join(
47+
SnapshotManager._runMetricsDir,
48+
Buffer.from(snapshotFilePath).toString('base64url') + '.json',
49+
);
50+
let existing: SnapshotFile = {};
51+
if (fs.existsSync(metricsFile)) {
52+
existing = JSON.parse(
53+
fs.readFileSync(metricsFile, 'utf-8'),
54+
) as SnapshotFile;
55+
} else if (!fs.existsSync(SnapshotManager._runMetricsDir)) {
56+
fs.mkdirSync(SnapshotManager._runMetricsDir, {recursive: true});
57+
}
58+
existing[key] = entry;
59+
fs.writeFileSync(
60+
metricsFile,
61+
JSON.stringify(existing, null, 2) + '\n',
62+
'utf-8',
63+
);
64+
}
65+
66+
/** Get live run metrics for a snapshot file, or null if none were recorded. */
67+
static getRunMetrics(snapshotFilePath: string): SnapshotFile | null {
68+
const metricsFile = path.join(
69+
SnapshotManager._runMetricsDir,
70+
Buffer.from(snapshotFilePath).toString('base64url') + '.json',
71+
);
72+
if (fs.existsSync(metricsFile)) {
73+
return JSON.parse(fs.readFileSync(metricsFile, 'utf-8')) as SnapshotFile;
74+
}
75+
return null;
76+
}
77+
78+
/** Clean up temp run metrics directory. */
79+
static clearRunMetrics(): void {
80+
if (fs.existsSync(SnapshotManager._runMetricsDir)) {
81+
for (const f of fs.readdirSync(SnapshotManager._runMetricsDir)) {
82+
fs.unlinkSync(path.join(SnapshotManager._runMetricsDir, f));
83+
}
84+
}
85+
}
86+
3187
static getSnapshotPath(testFilePath: string): {
3288
dir: string;
3389
file: string;

packages/@react-native-windows/perf-testing/src/matchers/toMatchPerfSnapshot.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ expect.extend({
168168

169169
const threshold: PerfThreshold = {...DEFAULT_THRESHOLD, ...customThreshold};
170170

171+
// Always record the live metrics for the CI reporter
172+
SnapshotManager.recordRunMetric(snapshotFile, snapshotKey, {
173+
metrics: received,
174+
threshold,
175+
capturedAt: new Date().toISOString(),
176+
});
177+
171178
// UPDATE MODE or FIRST RUN: write new baseline
172179
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
173180
if (isUpdateMode || !baseline) {

0 commit comments

Comments
 (0)