Skip to content

Commit

Permalink
Merge branch 'flutter:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoamador authored Oct 30, 2023
2 parents 8a1c09f + c182851 commit b1ea800
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 13 deletions.
14 changes: 10 additions & 4 deletions app_dart/lib/src/request_handlers/scheduler/batch_backfiller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class BatchBackfiller extends RequestHandler {
continue;
}
final FullTask? backfillTask = _backfillTask(target, taskColumn);
final int priority = backfillPriority(taskColumn.map((e) => e.task).toList(), BatchPolicy.kBatchSize);
if (backfillTask != null) {
final int? priority = backfillPriority(taskColumn.map((e) => e.task).toList());
if (priority != null && backfillTask != null) {
backfill.add(Tuple<Target, FullTask, int>(target, backfillTask, priority));
}
}
Expand Down Expand Up @@ -200,10 +200,16 @@ class BatchBackfiller extends RequestHandler {

/// Returns priority for back filled targets.
///
/// Skips scheduling newly created targets whose available entries are
/// less than `BatchPolicy.kBatchSize`.
///
/// Uses a higher priority if there is an earlier failed build. Otherwise,
/// uses default `LuciBuildService.kBackfillPriority`
int backfillPriority(List<Task> tasks, int pastTaskNumber) {
if (shouldRerunPriority(tasks, pastTaskNumber)) {
int? backfillPriority(List<Task> tasks) {
if (tasks.length < BatchPolicy.kBatchSize) {
return null;
}
if (shouldRerunPriority(tasks, BatchPolicy.kBatchSize)) {
return LuciBuildService.kRerunPriority;
}
return LuciBuildService.kBackfillPriority;
Expand Down
2 changes: 1 addition & 1 deletion app_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dev_dependencies:
json_serializable: 6.7.1
mockito: 5.4.2
platform: 3.1.3
test: 1.24.8
test: 1.24.9

builders:
json_serializable: 3.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ void main() {
expect(scheduleBuildRequest.priority, LuciBuildService.kBackfillPriority);
});

test('does not backfill targets when number of available tasks is less than BatchPolicy.kBatchSize', () async {
final List<Task> scheduleA = <Task>[
// Linux_android A
generateTask(1, name: 'Linux_android A', status: Task.statusNew),
];
db.addOnQuery<Task>((Iterable<Task> results) => scheduleA);
await tester.get(handler);
expect(pubsub.messages.length, 0);
});

test('backfills earlier failed task with higher priority', () async {
final List<Task> allGray = <Task>[
generateTask(1, name: 'Linux_android A', status: Task.statusNew),
Expand Down Expand Up @@ -244,15 +254,19 @@ void main() {
final List<Task> scheduleA = <Task>[
// Linux_android A
generateTask(1, name: 'Linux_android A', status: Task.statusNew),
generateTask(2, name: 'Linux_android A', status: Task.statusNew),
// Linux_android B
generateTask(1, name: 'Linux_android B', status: Task.statusNew),
generateTask(2, name: 'Linux_android B', status: Task.statusNew),
// Linux_android C
generateTask(1, name: 'Linux_android C', status: Task.statusNew),
generateTask(2, name: 'Linux_android C', status: Task.statusNew),
];
db.addOnQuery<Task>((Iterable<Task> results) => scheduleA);
await tester.get(handler);
expect(pubsub.messages.length, 2);
});

group('getFilteredBackfill', () {
test('backfills high priorty targets first', () async {
final List<Tuple<Target, FullTask, int>> backfill = <Tuple<Target, FullTask, int>>[
Expand Down
2 changes: 1 addition & 1 deletion auto_submit/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dev_dependencies:
json_serializable: 6.7.1
flutter_lints: 3.0.0
mockito: 5.4.2
test: 1.24.8
test: 1.24.9

builders:
json_serializable: 3.3.0
77 changes: 77 additions & 0 deletions cipd_packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Flutter CIPD Packages

This folder contains auto built/deployed public [CIPD packages](https://chrome-infra-packages.appspot.com/p/flutter)
used by Flutter CI. These packages will be consumed from tests and auto cached to boost future runs.

Please follow these steps to add a new package.

## Creating the package build file

Create a new sub directory under this folder named with the new package. Add a `build.sh` script for Linux/Mac or
`build.bat` for Windows, and put it under a child dir `tool`. This is the main script to build this package. Add
necessary lib files if needed.

Note:

1) we do not archive the binaries in the repo, and will auto build package artifacts and upload to CIPD via the bot.
2) please add a code owner entry under section `cipd packages` in [CODEOWNERS](https://github.com/flutter/cocoon/blob/main/CODEOWNERS) file.

## Add an entry to cocoon .ci.yaml

This is to enable the auto build and upload. Please follow the following example format:
```yaml
- name: Mac <package_name>
recipe: cocoon/cipd
bringup: true
properties:
script: cipd_packages/<package_name>/tool/build.sh
cipd_name: flutter/<package_name>/mac-amd64 # Use mac-arm64 for arm64 version.
device_type: none
runIf:
- cipd_packages/<package_name>/**
- .ci.yaml
```
Start with `bringup: true`, same as any other regular new target. Once validated in CI, remove it to enable running
in the `prod` environment so that artifacts are to be uploaded to CIPD.

Note: with `bringup: true`, the target will be executed in a staging environment and it validates only the logic
and will not upload to CIPD.

## Adding a reference to the CIPD package

Until this step, artifacts are being uploaded to CIPD whenever a new commit is merged. It is useful to add a reference
to the package, so that we can use the reference in the CI recipe. This way we won’t need to change the recipe
whenever we update the package.

Googlers have default access to add a reference to a package via:
```sh
cipd set-ref flutter/PackageName/mac-amd64 -ref Reference -version InstanceID
```

* Reference: e.g. major release versions. If not specified, `latest` will be used based on the latest package instance.
* InstaneID: this can be obtained from the package page, e.g. [ruby](https://chrome-infra-packages.appspot.com/p/flutter/ruby/mac-amd64/+/TyvPskvefNRkTDmiDcwRHrdL_a2FQE_4wBojOqhxdtYC).

Note: for non-Googler contributors, please file an [infra bug](https://github.com/flutter/flutter/issues/new?assignees=&labels=team-infra&projects=&template=6_infrastructure.yml) to make a reference request.

## Supporting packages download from CI recipe

Example CL: [51547 ](https://flutter-review.googlesource.com/c/recipes/+/51547)

Refer to [CONTRIBUTING.md](https://flutter.googlesource.com/recipes/+/refs/heads/main/CONTRIBUTING.md) on how to
contribute to recipes repository.

## Adding/updating package dependency from .ci.yaml from different repositories

This is the last step to enable the package usage in the real CI. Add or update the new package to either the platform level or
target level entries for your targeted repository:
``` yaml
dependencies: >-
[
{"dependency": "chrome_and_driver", "version": "Reference"},
]
```

Note: use the `Reference` created above.

More details about configuration setup can be found in [CI_YAML.md](https://github.com/flutter/cocoon/blob/main/CI_YAML.md).
2 changes: 1 addition & 1 deletion cipd_packages/codesign/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:

dev_dependencies:
lints: 3.0.0
test: 1.24.8
test: 1.24.9
dependencies:
archive: 3.4.6
args: 2.4.2
Expand Down
6 changes: 1 addition & 5 deletions cipd_packages/device_doctor/lib/src/android_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,7 @@ class AndroidDevice implements Device {
if (packageMatch != null) {
final packageName = packageMatch.group(1);
if (packageName != null) {
if (packageName.contains('/data/app/com.example') |
packageName.contains('/data/app/com.yourcompany') |
packageName.contains('flutter')) {
packages.add(packageName);
}
packages.add(packageName);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion cipd_packages/device_doctor/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ dev_dependencies:
build_runner: 2.4.6
fake_async: 1.3.1
mockito: 5.4.2
test: 1.24.8
test: 1.24.9

0 comments on commit b1ea800

Please sign in to comment.