-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Pre-Submit Tryjobs for Flutter Gold #44474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fe1cad6
8692295
b456402
37a93fa
384c42b
fd89364
5c8ad4e
dcd2a49
cf2a0dd
8dd9b4c
c842c61
25bd67e
7a16e81
7d8952a
d500303
78eeb3f
f25cb08
ba42d36
7283501
c93b7ec
5f6e29f
ef219ee
2413496
01c7667
7d837da
73ac621
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,6 +129,11 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator { | |
| Uri getTestUri(Uri key, int version) => key; | ||
|
|
||
| /// Calculate the appropriate basedir for the current test context. | ||
Piinks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// | ||
| /// The optional [suffix] argument is used by the | ||
| /// [FlutterSkiaGoldFileComparator] and the [FlutterPreSubmitFileComparator]. | ||
| /// These [FlutterGoldenFileComparators] randomize their base directories to | ||
| /// maintain thread safety while using the `goldctl` tool. | ||
|
Comment on lines
+133
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why aren't we just using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When run locally, we want the files to be accessible to see diffs etc.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh. I'm a bit curious about whether we'd hit collisions at some point using math.random, but it's probably fine.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so too, but then realized we only run 2-3 processes concurrently on ci, and only ~130/~4500 tests are golden file tests, so I feel like a collision would be incredibly rare in how this is written. |
||
| @protected | ||
| @visibleForTesting | ||
| static Directory getBaseDirectory(LocalFileComparator defaultComparator, Platform platform, {String suffix = ''}) { | ||
|
|
@@ -217,10 +222,7 @@ class FlutterSkiaGoldFileComparator extends FlutterGoldenFileComparator { | |
| platform, | ||
| suffix: '${math.Random().nextInt(10000)}', | ||
| ); | ||
|
|
||
| if(!baseDirectory.existsSync()) { | ||
| baseDirectory.createSync(recursive: true); | ||
| } | ||
| baseDirectory.createSync(recursive: true); | ||
|
|
||
| goldens ??= SkiaGoldClient(baseDirectory); | ||
| await goldens.auth(); | ||
|
|
@@ -299,47 +301,23 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator { | |
| final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory( | ||
| defaultComparator, | ||
| platform, | ||
| suffix: '${math.Random().nextInt(10000)}', | ||
| ); | ||
|
|
||
| if(!baseDirectory.existsSync()) { | ||
| baseDirectory.createSync(recursive: true); | ||
| } | ||
| baseDirectory.createSync(recursive: true); | ||
|
|
||
| goldens ??= SkiaGoldClient(baseDirectory); | ||
| await goldens.getExpectations(); | ||
|
|
||
| await goldens.auth(); | ||
| await goldens.tryjobInit(); | ||
| return FlutterPreSubmitFileComparator(baseDirectory.uri, goldens); | ||
| } | ||
|
|
||
| @override | ||
| Future<bool> compare(Uint8List imageBytes, Uri golden) async { | ||
| golden = _addPrefix(golden); | ||
| final String testName = skiaClient.cleanTestName(golden.path); | ||
| final List<String> testExpectations = skiaClient.expectations[testName]; | ||
|
|
||
| if (testExpectations == null) { | ||
| // There is no baseline for this test | ||
| return true; | ||
| } | ||
Piinks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ComparisonResult result; | ||
| for (String expectation in testExpectations) { | ||
| final List<int> goldenBytes = await skiaClient.getImageBytes(expectation); | ||
|
|
||
| result = GoldenFileComparator.compareLists( | ||
| imageBytes, | ||
| goldenBytes, | ||
| ); | ||
|
|
||
| if (result.passed) { | ||
| return true; | ||
| } | ||
| } | ||
| await update(golden, imageBytes); | ||
| final File goldenFile = getGoldenFile(golden); | ||
|
|
||
| return skiaClient.testIsIgnoredForPullRequest( | ||
| platform.environment['CIRRUS_PR'] ?? '', | ||
| golden.path, | ||
| ); | ||
| return skiaClient.tryjobAdd(golden.path, goldenFile); | ||
| } | ||
|
|
||
| /// Decides based on the current environment whether goldens tests should be | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,37 +169,6 @@ String digestResponseTemplate({ | |
| '''; | ||
| } | ||
|
|
||
| /// Json response template for Skia Gold ignore request: | ||
| /// https://flutter-gold.skia.org/json/ignores | ||
| String ignoreResponseTemplate({ | ||
| String pullRequestNumber = '0000', | ||
| String testName = 'flutter.golden_test.1', | ||
| String otherTestName = 'flutter.golden_test.1', | ||
| String expires = '2019-09-06T21:28:18.815336Z', | ||
| String otherExpires = '2019-09-06T21:28:18.815336Z', | ||
| }) { | ||
| return ''' | ||
| [ | ||
| { | ||
| "id": "7579425228619212078", | ||
| "name": "[email protected]", | ||
| "updatedBy": "[email protected]", | ||
| "expires": "$expires", | ||
| "query": "ext=png&name=$testName", | ||
| "note": "https://github.com/flutter/flutter/pull/$pullRequestNumber" | ||
| }, | ||
| { | ||
| "id": "7579425228619212078", | ||
| "name": "[email protected]", | ||
| "updatedBy": "[email protected]", | ||
| "expires": "$otherExpires", | ||
| "query": "ext=png&name=$otherTestName", | ||
| "note": "https://github.com/flutter/flutter/pull/99999" | ||
| } | ||
| ] | ||
| '''; | ||
| } | ||
|
|
||
| /// Json response template for Skia Gold image request: | ||
| /// https://flutter-gold.skia.org/img/images/[imageHash].png | ||
| List<List<int>> imageResponseTemplate() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is a trivial 80 character line limit correction in keeping with the style guide, and to also trigger the relevant framework tests confirming tryjob execution.