mirror of
https://github.com/flutter/flutter
synced 2024-09-20 00:32:02 +00:00
Make Web shard count configurable via WEB_SHARD_COUNT (#54678)
This commit is contained in:
parent
ee43de0476
commit
14cceefe2b
|
@ -5,6 +5,7 @@ web_shard_template: &WEB_SHARD_TEMPLATE
|
|||
only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''"
|
||||
environment:
|
||||
# As of March 2020, the Web shards needed 16G of RAM and 4 CPUs to run all framework tests with goldens without flaking.
|
||||
WEB_SHARD_COUNT: 8
|
||||
CPU: 4
|
||||
MEMORY: 16G
|
||||
CHROME_NO_SANDBOX: true
|
||||
|
|
|
@ -47,11 +47,16 @@ const int kDeviceLabShardCount = 4;
|
|||
|
||||
/// The number of Cirrus jobs that run Web tests in parallel.
|
||||
///
|
||||
/// The default is 8 shards. Typically .cirrus.yml would define the
|
||||
/// WEB_SHARD_COUNT environment variable rather than relying on the default.
|
||||
///
|
||||
/// WARNING: if you change this number, also change .cirrus.yml
|
||||
/// and make sure it runs _all_ shards.
|
||||
///
|
||||
/// The last shard also runs the Web plugin tests.
|
||||
const int kWebShardCount = 8;
|
||||
int get webShardCount => Platform.environment.containsKey('WEB_SHARD_COUNT')
|
||||
? int.parse(Platform.environment['WEB_SHARD_COUNT'])
|
||||
: 8;
|
||||
|
||||
/// Tests that we don't run on Web for various reasons.
|
||||
//
|
||||
|
@ -539,12 +544,12 @@ Future<void> _runWebUnitTests() async {
|
|||
// We use a constant seed for repeatability.
|
||||
..shuffle(math.Random(0));
|
||||
|
||||
assert(kWebShardCount >= 1);
|
||||
final int testsPerShard = (allTests.length / kWebShardCount).ceil();
|
||||
assert(testsPerShard * kWebShardCount >= allTests.length);
|
||||
assert(webShardCount >= 1);
|
||||
final int testsPerShard = (allTests.length / webShardCount).ceil();
|
||||
assert(testsPerShard * webShardCount >= allTests.length);
|
||||
|
||||
// This for loop computes all but the last shard.
|
||||
for (int index = 0; index < kWebShardCount - 1; index += 1) {
|
||||
for (int index = 0; index < webShardCount - 1; index += 1) {
|
||||
subshards['$index'] = () => _runFlutterWebTest(
|
||||
flutterPackageDirectory.path,
|
||||
allTests.sublist(
|
||||
|
@ -558,11 +563,11 @@ Future<void> _runWebUnitTests() async {
|
|||
//
|
||||
// We make sure the last shard ends in _last so it's easier to catch mismatches
|
||||
// between `.cirrus.yml` and `test.dart`.
|
||||
subshards['${kWebShardCount - 1}_last'] = () async {
|
||||
subshards['${webShardCount - 1}_last'] = () async {
|
||||
await _runFlutterWebTest(
|
||||
flutterPackageDirectory.path,
|
||||
allTests.sublist(
|
||||
(kWebShardCount - 1) * testsPerShard,
|
||||
(webShardCount - 1) * testsPerShard,
|
||||
allTests.length,
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue