Skip to content

Commit 3a4add1

Browse files
committed
fix: stabilize CI checks for Android snapshot caching
1 parent ea6ff4f commit 3a4add1

4 files changed

Lines changed: 70 additions & 4 deletions

File tree

actions/shared/index.cjs

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,6 +4551,66 @@ var getConfig = async (dir) => {
45514551
// src/shared/index.ts
45524552
var import_node_path6 = __toESM(require("path"));
45534553
var import_node_fs6 = __toESM(require("fs"));
4554+
var getHostAndroidSystemImageArch = () => {
4555+
switch (process.arch) {
4556+
case "arm64":
4557+
return "arm64-v8a";
4558+
case "arm":
4559+
return "armeabi-v7a";
4560+
case "x64":
4561+
default:
4562+
return "x86_64";
4563+
}
4564+
};
4565+
var resolveAvdCachingEnabled = ({
4566+
snapshotEnabled
4567+
}) => {
4568+
const override = process.env.HARNESS_AVD_CACHING;
4569+
const requestedValue = override == null ? snapshotEnabled : override.toLowerCase() === "true";
4570+
return requestedValue === true;
4571+
};
4572+
var getNormalizedAvdCacheConfig = ({
4573+
emulator,
4574+
hostArch
4575+
}) => {
4576+
const avd = emulator.avd;
4577+
if (!avd) {
4578+
return null;
4579+
}
4580+
return {
4581+
name: emulator.name,
4582+
apiLevel: avd.apiLevel,
4583+
arch: hostArch,
4584+
profile: avd.profile.trim().toLowerCase(),
4585+
diskSize: avd.diskSize.trim().toLowerCase(),
4586+
heapSize: avd.heapSize.trim().toLowerCase()
4587+
};
4588+
};
4589+
var getResolvedRunner = (runner) => {
4590+
if (runner.platformId !== "android" || runner.config.device.type !== "emulator") {
4591+
return runner;
4592+
}
4593+
const avdCachingEnabled = resolveAvdCachingEnabled({
4594+
snapshotEnabled: runner.config.device.avd?.snapshot?.enabled
4595+
});
4596+
return {
4597+
...runner,
4598+
config: {
4599+
...runner.config,
4600+
device: {
4601+
...runner.config.device,
4602+
avd: runner.config.device.avd
4603+
}
4604+
},
4605+
action: {
4606+
avdCachingEnabled,
4607+
avdCacheConfig: getNormalizedAvdCacheConfig({
4608+
emulator: runner.config.device,
4609+
hostArch: getHostAndroidSystemImageArch()
4610+
})
4611+
}
4612+
};
4613+
};
45544614
var run = async () => {
45554615
try {
45564616
const projectRootInput = process.env.INPUT_PROJECTROOT;
@@ -4560,7 +4620,9 @@ var run = async () => {
45604620
}
45614621
const projectRoot = projectRootInput ? import_node_path6.default.resolve(projectRootInput) : process.cwd();
45624622
console.info(`Loading React Native Harness config from: ${projectRoot}`);
4563-
const { config, projectRoot: resolvedProjectRoot } = await getConfig(projectRoot);
4623+
const { config, projectRoot: resolvedProjectRoot } = await getConfig(
4624+
projectRoot
4625+
);
45644626
const runner = config.runners.find((runner2) => runner2.name === runnerInput);
45654627
if (!runner) {
45664628
throw new Error(`Runner ${runnerInput} not found in config`);
@@ -4569,8 +4631,11 @@ var run = async () => {
45694631
if (!githubOutput) {
45704632
throw new Error("GITHUB_OUTPUT environment variable is not set");
45714633
}
4634+
const resolvedRunner = getResolvedRunner(runner);
45724635
const relativeProjectRoot = import_node_path6.default.relative(process.cwd(), resolvedProjectRoot) || ".";
4573-
const output = `config=${JSON.stringify(runner)}
4636+
const output = `config=${JSON.stringify(
4637+
resolvedRunner
4638+
)}
45744639
projectRoot=${relativeProjectRoot}
45754640
`;
45764641
import_node_fs6.default.appendFileSync(githubOutput, output);

packages/platform-android/src/instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
ensureAndroidEmulatorEnvironment,
3131
getHostAndroidSystemImageArch,
3232
} from './environment.js';
33-
import { isInteractive } from '../../tools/src/isInteractive.js';
33+
import { isInteractive } from '@react-native-harness/tools';
3434
import fs from 'node:fs';
3535

3636
const androidInstanceLogger = logger.child('android-instance');

packages/tools/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export * from './events.js';
99
export * from './packages.js';
1010
export * from './crash-artifacts.js';
1111
export * from './regex.js';
12+
export * from './isInteractive.js';

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "rspress build",
6+
"build": "rm -rf build && rspress build",
77
"dev": "rspress dev",
88
"preview": "rspress preview"
99
},

0 commit comments

Comments
 (0)