Skip to content

Enable filtering builders based on changed files in PRs#917

Merged
keyonghan merged 3 commits intoflutter:masterfrom
keyonghan:file_filter_builder
Aug 21, 2020
Merged

Enable filtering builders based on changed files in PRs#917
keyonghan merged 3 commits intoflutter:masterfrom
keyonghan:file_filter_builder

Conversation

@keyonghan
Copy link
Contributor

This is to solve flutter/flutter#62841

Copy link
Contributor

Choose a reason for hiding this comment

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

Update? given that functions in this library are made for reusability let's add complete docs. E.g parameters received, return value and an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

How do we support * and **?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Existing cirrus seems to use ** only, do we have the use case of a single *?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add * support.

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 call it glob instead of dirs? dirs is confusing as it can be a file a folder or a glob, glob matches all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced.

Copy link
Contributor

Choose a reason for hiding this comment

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

How do we differentiate from a full path and wildcards, e.g:

/a/b file in a
and
/a/bc/a ?

Should we implement the functionality using regexes? e.g * replaced with '[a-zA-Z_]*' and ** as[a-zA-Z_/]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this list of files already available in the PR event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't seem so. Based on CheckSuiteEvent, we can track down to CheckSuite, then PullRequest, where changedFilesCount is available, but there is no changedFiles though.

Copy link
Contributor

Choose a reason for hiding this comment

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

we'll need tests for the wildcards * and **

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.

It would be really helpful to fix the unreadable, non-type-safe Map<String, dynamic> everywhere with a @JsonSerializable annotated class.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 a list of map of maps is prone to errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Updating to use annotated class will affect quite some files. Created TODO (flutter/flutter#64286) to update that in a separate PR.

@keyonghan keyonghan force-pushed the file_filter_builder branch from 0cd591b to 1a4e7f4 Compare August 20, 2020 00:15
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 a list of map of maps is prone to errors.

/// "repo":"flutter",
/// "taskName":"zzz",
/// "enabled":true,
/// "run_if":["a/b/", "c/d/**"]
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 single files?

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 case of single files has been covered. Please refer to the test below. Updated the doc to include a case of a single file and a case of single *

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 call it glob instead of dirs? dirs is confusing as it can be a file a folder or a glob, glob matches all of them.

});

test('returns builders when run_if matches files with both * and **', () async {
builders =
Copy link
Contributor

Choose a reason for hiding this comment

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

We need one more test for file and folder with the same name "a" and a/b/c. E.g a run_if = ["a"] does not match a files changes "a/b/c"

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, let's land and monitor to ensure builders are triggered correctly.

@keyonghan
Copy link
Contributor Author

LGTM, let's land and monitor to ensure builders are triggered correctly.

Will keep an eye on this tomorrow morning.
With flutter/flutter#64180, new PRs in flutter repo should be triggered based on run_if after a new deployment.

@keyonghan keyonghan merged commit bcc04f5 into flutter:master Aug 21, 2020
@keyonghan keyonghan deleted the file_filter_builder branch March 13, 2024 20:14
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