Skip to content

Conversation

@keyonghan
Copy link
Contributor

This is part of flutter/flutter#51807

Instead of assuming only one branch exists for each commit in cirrus, we here consider all branches. When updating cirrus status in cocoon, we consider the branch property as well.

Copy link
Contributor

@Piinks Piinks Mar 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will only apply the flutter-gold status to pre-submit checks that will be landing on master?

When Gold is able to support branching in the future (still TBD), I think we will want the flutter-gold check to work on these branched pre-submit checks. Right now individual pre-submit tests with golden files will not fail since they rely on this flutter-gold check.

Can you add a TODO here to explain that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It will check only master branch based on the above logic.
I see your comment: flutter/flutter#51807 (comment)
Do you mind create corresponding issue, and then I will add a TODO pointing to that issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a branch passed as a parameter instead of fixing it to master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this logic can be abstracted to a utility function that can be used everywhere(I've seen this logic replicated in several places).

Ideally something like:

List branches = await getSupportedBranches();
for (Branch branch in branches) { ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite this part as suggested. Now multiple APIs call this shared logic defined in utils.dart. Additionally merged the /request_handler/utils.dart with /foundation/utils.dart.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a constant for this limit? it can make it easier to change in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we have too much logic in a single method, can we split the functionality into multiple methods? This will also simplify tests for specific functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added two sub functions: _getStatuses and _getNewTaskStatus to simply.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the retries wrapper? everything related with datastore has a high failure rate.

Copy link
Contributor Author

@keyonghan keyonghan Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. I filed an issue to track retry implementation for all cocoon backend days ago: flutter/flutter#52427.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also tests that used a branch different than master? My assumption is that master is hardcoded everywhere and we may miss some places that need changes if we use master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason we fix master here is that check for waiting pull requests applied to master only. As suggested, I have added one more test to consider the case with a different branch name, for which we will ignore cirrus statues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a test for a matching branch different than master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


final HttpClient client = branchHttpClientProvider();
try {
for (int attempt = 0; attempt < 3; attempt++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify this function removing the for loop and the try..catch by using "retry" with retryIf.

Copy link
Contributor Author

@keyonghan keyonghan Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a TODO as mentioned in the above issue: flutter/flutter#52427. Since this PR is big already, do you think it would be good to finish this in a separate PR later? I am a little bit concerned about that too many changes in a single shot may make it easy to break and difficult to triage/debug if any issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the TODO here to ensure we don't forget about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, and pointed to the above issue.

log.warning(
'Attempt to download branch_regexps.txt failed (HTTP $status)');
}
} catch (error, stackTrace) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is possible to use specific errors rather than catching all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

client.close(force: true);
}
log.error('GitHub not responding; giving up');
return <String>['master'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can potentially hide errors, I'd suggest throwing an error rather than logging and then defaulting to master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

return Body.empty;
}

String _getNewTaskStatus(List<String> statuses, FullTask task) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docs will be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

return newTaskStatus;
}

List<String> _getStatuses(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docs will be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

Copy link
Contributor

@godofredoc godofredoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after adding TODO to simplify loadBranchRegExps

@keyonghan
Copy link
Contributor Author

LGTM after adding TODO to simplify loadBranchRegExps

Thank you for all the detailed comments!

@keyonghan keyonghan merged commit 1868e39 into flutter:master Mar 18, 2020
@keyonghan keyonghan deleted the cirrus_branch branch March 13, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants