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 Apr 16, 2024
2 parents 7ac2613 + 9203992 commit 8ba406b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ class PushGoldStatusToGithub extends ApiRequestHandler<Body> {
continue;
}

final String defaultBranch = Config.defaultBranch(slug);
if (pr.base!.ref != defaultBranch) {
log.fine('This change is not staged to land on $defaultBranch, skipping.');
if (!Config.doesSkiaGoldRunOnBranch(slug, pr.base!.ref)) {
log.fine('This change\'s destination, ${pr.base!.ref}, does not run Skia Gold checks, skipping.');
// This is potentially a release branch, or another change not landing
// on master, we don't need a Gold check.
continue;
Expand Down
9 changes: 9 additions & 0 deletions app_dart/lib/src/service/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ class Config {
flutterSlug,
};

static bool doesSkiaGoldRunOnBranch(gh.RepositorySlug slug, String? branch) {
if (slug == engineSlug) {
final RegExp releaseRegex = RegExp(r'flutter-\d?\.\d?-candidate\.\d?');
return defaultBranch(slug) == branch || (branch != null && releaseRegex.hasMatch(branch));
} else {
return defaultBranch(slug) == branch;
}
}

/// The tip of tree branch for [slug].
static String defaultBranch(gh.RepositorySlug slug) {
final Map<gh.RepositorySlug, String> defaultBranches = <gh.RepositorySlug, String>{
Expand Down
2 changes: 1 addition & 1 deletion app_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies:
github: 9.24.0
googleapis: 12.0.0
googleapis_auth: 1.6.0
gql: 1.0.1-alpha+1696717343881
gql: 1.0.1-alpha+1709845491443
graphql: 5.2.0-beta.7
grpc: 3.2.4
http: 1.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,70 @@ void main() {
);
});

test('runs on engine release branches', () async {
// New commit
final PullRequest pr = newPullRequest(123, 'abc', 'flutter-3.8-candidate.8');
enginePrsFromGitHub = <PullRequest>[pr];
final GithubGoldStatusUpdate status = newStatusUpdate(engineSlug, pr, '', '', '');
db.values[status.key] = status;
githubGoldStatusEngine = newGithubGoldStatus(engineSlug, pr, '', '', '');

// All checks completed
engineCheckRuns = <dynamic>[
<String, String>{'name': 'Linux linux_web_engine', 'status': 'completed', 'conclusion': 'success'},
];

// Change detected by Gold
mockHttpClient = MockClient((http.Request request) async {
if (request.url.toString() ==
'https://flutter-engine-gold.skia.org/json/v1/changelist_summary/github/${pr.number}') {
return http.Response(tryjobDigests(pr), HttpStatus.ok);
}
throw const HttpException('Unexpected http request');
});
handler = PushGoldStatusToGithub(
config: config,
authenticationProvider: auth,
datastoreProvider: (DatastoreDB db) {
return DatastoreService(
config.db,
5,
retryOptions: retryOptions,
);
},
goldClient: mockHttpClient,
ingestionDelay: Duration.zero,
);

// Have not already commented for this commit.
when(issuesService.listCommentsByIssue(engineSlug, pr.number!)).thenAnswer(
(_) => Stream<IssueComment>.value(
IssueComment()..body = 'some other comment',
),
);

final Body body = await tester.get<Body>(handler);
expect(body, same(Body.empty));

verify(
issuesService.addLabelsToIssue(
engineSlug,
pr.number!,
<String>[
kGoldenFileLabel,
],
),
).called(1);

verify(
issuesService.createComment(
engineSlug,
pr.number!,
argThat(contains(config.flutterGoldCommentID(pr))),
),
).called(1);
});

test('does nothing for branches not staged to land on main/master', () async {
// New commit
final PullRequest pr = newPullRequest(123, 'abc', 'release');
Expand Down

0 comments on commit 8ba406b

Please sign in to comment.