Skip to content

Commit 3c087fc

Browse files
rubennortefacebook-github-bot
authored andcommitted
Small refactor of Fantom global setup (#52766)
Summary: Pull Request resolved: #52766 Changelog: [internal] Just a minor refactor so adding more logic that should work both at Meta and in OSS is easier in the next diff Reviewed By: christophpurrer Differential Revision: D78741904 fbshipit-source-id: 3abda5d5b7be157bf381e26dad2fd4b064a0f556
1 parent fec6a0a commit 3c087fc

4 files changed

Lines changed: 46 additions & 33 deletions

File tree

private/react-native-fantom/config/jest.config.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
const baseConfig = require('../../../jest.config');
1414
const path = require('path');
1515

16-
const isCI =
17-
Boolean(process.env.SANDCASTLE) || Boolean(process.env.GITHUB_ACTIONS);
18-
19-
// In CI, we want to prewarm the caches/builds before running the tests so
20-
// that time isn't attributed to the first test that runs.
21-
const globalSetup /*: ?string */ = isCI
22-
? '<rootDir>/private/react-native-fantom/runner/warmup/index.js'
23-
: null;
24-
2516
module.exports = {
2617
displayName: 'fantom',
2718
rootDir: path.resolve(__dirname, '../../..') /*:: as string */,
@@ -42,5 +33,6 @@ module.exports = {
4233
transformIgnorePatterns: ['.*'],
4334
testRunner: '<rootDir>/private/react-native-fantom/runner/index.js',
4435
watchPathIgnorePatterns: ['<rootDir>/private/react-native-fantom/build/'],
45-
globalSetup,
36+
globalSetup:
37+
'<rootDir>/private/react-native-fantom/runner/global-setup/setup.js',
4638
};

private/react-native-fantom/runner/warmup/warmup.js renamed to private/react-native-fantom/runner/global-setup/build.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @format
99
*/
1010

11+
import {isCI} from '../EnvironmentOptions';
1112
import {
1213
getBuckModesForPlatform,
1314
getDebugInfoFromCommandResult,
@@ -37,28 +38,27 @@ async function tryOrLog(
3738
}
3839
}
3940

40-
export default async function warmUp(
41-
globalConfig: {...},
42-
projectConfig: {...},
43-
): Promise<void> {
44-
await tryOrLog(
45-
() => warmUpHermesCompiler(false),
46-
'Error warming up Hermes compiler (dev)',
47-
);
48-
await tryOrLog(
49-
() => warmUpHermesCompiler(true),
50-
'Error warming up Hermes compiler (opt)',
51-
);
52-
await tryOrLog(
53-
() => warmUpRNTesterCLI(false),
54-
'Error warming up RN Tester CLI (dev)',
55-
);
56-
await tryOrLog(
57-
() => warmUpRNTesterCLI(true),
58-
'Error warming up RN Tester CLI (opt)',
59-
);
60-
await tryOrLog(() => warmUpMetro(false), 'Error warming up Metro (dev)');
61-
await tryOrLog(() => warmUpMetro(true), 'Error warming up Metro (opt)');
41+
export default async function build(): Promise<void> {
42+
if (isCI) {
43+
await tryOrLog(
44+
() => warmUpHermesCompiler(false),
45+
'Error warming up Hermes compiler (dev)',
46+
);
47+
await tryOrLog(
48+
() => warmUpHermesCompiler(true),
49+
'Error warming up Hermes compiler (opt)',
50+
);
51+
await tryOrLog(
52+
() => warmUpRNTesterCLI(false),
53+
'Error warming up RN Tester CLI (dev)',
54+
);
55+
await tryOrLog(
56+
() => warmUpRNTesterCLI(true),
57+
'Error warming up RN Tester CLI (opt)',
58+
);
59+
await tryOrLog(() => warmUpMetro(false), 'Error warming up Metro (dev)');
60+
await tryOrLog(() => warmUpMetro(true), 'Error warming up Metro (opt)');
61+
}
6262
}
6363

6464
async function warmUpMetro(isOptimizedMode: boolean): Promise<void> {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
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+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import {isOSS} from '../EnvironmentOptions';
12+
import build from './build';
13+
14+
export default async function globalSetup(
15+
globalConfig: {...},
16+
projectConfig: {...},
17+
): Promise<void> {
18+
if (!isOSS) {
19+
await build();
20+
}
21+
}

private/react-native-fantom/runner/warmup/index.js renamed to private/react-native-fantom/runner/global-setup/setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
require('../../../../scripts/shared/babelRegister').registerForMonorepo();
1212

13-
module.exports = require('./warmup');
13+
module.exports = require('./globalSetup');

0 commit comments

Comments
 (0)