Skip to content

Conversation

@Piinks
Copy link
Contributor

@Piinks Piinks commented May 31, 2019

Description

Integrating Flutter golden file testing with Skia Gold
Re-worked into a phased transition from #31630

This PR keeps in place the current structure of Gold file testing via the flutter/goldens repository for local and pre-submit testing, while Skia Gold is used for post-submit testing.

Golden tests in this implementation will not turn the tree red. Instead, once this lands and is validated by CI on post-submit, commenting on associated PR's will be added as a method of notification.

Once Pre-submit testing is enabled by the Skia Gold team, the former testing structure used through flutter/goldens will be removed, with Skia Gold taking its place.

Related Issues

Dependent on:

Addresses:

Tests

Added/Relocated/Updated:

  • flutter_test/test/matchers_test.dart
    • Comparator succeeds in incorporating version number
    • Comparator succeeds with null version number
    • Comparator failure incorporates version number
    • Comparator failure with null version number
  • flutter_test/test/goldens_test.dart
    • getTestUri updates file name with version number
    • getTestUri does nothing for null version number
  • flutter_goldens/test/flutter_goldens_test.dart
    • group: GoldensClient
    • group: SkiaGoldClient
      • auth performs minimal work if already authorized
    • group: FlutterGoldensRepositoryFileComparator
      • fromDefaultComparator calculates the base directory correctly
      • group: getTestUri
        • incorporates version number
        • ignores null version number
    • group: FlutterSkiaGoldFileComparator
      • fromDefaultComparator calculates the base directory correctly
      • group: getTestUri
        • ignores version number
  • Any and all tests that have invoked matchesGoldenFile with a skip in place for platforms other than Linux.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@Piinks Piinks added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels May 31, 2019
@Piinks Piinks changed the title WIP - Part1: Skia Gold Testing WIP - Part 1: Skia Gold Testing May 31, 2019
@Piinks

This comment has been minimized.

@Piinks
Copy link
Contributor Author

Piinks commented Jun 4, 2019

Waiting on #33880 and #33865 to land and update this PR.

@Piinks Piinks added the waiting for PR to land (fixed) A fix is in flight label Jun 7, 2019
@Piinks Piinks self-assigned this Jun 12, 2019
Copy link
Contributor Author

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Ready for another go.

/// repository, nested within the `bin/cache` directory of the caller's Flutter
/// repository.
/// A base class that provides shared information to the [SkiaGoldClient] and
/// [GoldensRepositoryClient].
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do & done! :)

/// repository, nested within the `bin/cache` directory of the caller's Flutter
/// repository.
/// A base class that provides shared information to the [SkiaGoldClient] and
/// [GoldensRepositoryClient].
Copy link
Member

Choose a reason for hiding this comment

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

GoldensClient is still not abstract.


@override
Uri getTestUri(Uri key, int version) {
if (version == null)
Copy link
Member

Choose a reason for hiding this comment

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

Any way we can avoid the code duplication of this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I found a way. :)

Copy link
Contributor

@tvolkert tvolkert left a comment

Choose a reason for hiding this comment

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

LGTM.

@goderbauer will probably want to review and approve as well.

fs: fs,
platform: platform,
) {
_skiaClient = SkiaGoldClient(fs.directory(basedir));
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be set in the initializer as well and made final

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know that I can do that since the SkiaGoldClient is not a const constructor. cc/ @goderbauer for offline chat.

await goldenFile.writeAsBytes(imageBytes, flush: true);
Future<bool> compare(Uint8List imageBytes, Uri golden) async {
golden = _addPrefix(golden);
await update(golden, imageBytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we update() during compare()?

Is it that we update the version in Gold that's associated with this test run whenever we compare, and that's separate from approving which is the new golden?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We update to create the golden file that will be uploaded to Skia.

The master golden file is never downloaded or stored locally for comparison like in the flutter/goldens implementation, so the only file that exists is the current golden that needs to be compared. So when compare() is called, is calls update() to write out the bytes to file for the test.

Copy link
Contributor Author

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Addressed comments, will run another round of testing across all environments tomorrow.

await goldenFile.writeAsBytes(imageBytes, flush: true);
Future<bool> compare(Uint8List imageBytes, Uri golden) async {
golden = _addPrefix(golden);
await update(golden, imageBytes);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We update to create the golden file that will be uploaded to Skia.

The master golden file is never downloaded or stored locally for comparison like in the flutter/goldens implementation, so the only file that exists is the current golden that needs to be compared. So when compare() is called, is calls update() to write out the bytes to file for the test.

/// repository, nested within the `bin/cache` directory of the caller's Flutter
/// repository.
/// A base class that provides shared information to the [SkiaGoldClient] and
/// [GoldensRepositoryClient].
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can't be abstract since it is called in fromDefaultComparator by the FlutterSkiaGoldFileComparator to access the base information.


@override
Uri getTestUri(Uri key, int version) {
if (version == null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I found a way. :)

fs: fs,
platform: platform,
) {
_skiaClient = SkiaGoldClient(fs.directory(basedir));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know that I can do that since the SkiaGoldClient is not a const constructor. cc/ @goderbauer for offline chat.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

/// repository, nested within the `bin/cache` directory of the caller's Flutter
/// repository.
/// A base class that provides shared information to the [SkiaGoldClient] and
/// [GoldensRepositoryClient].
Copy link
Member

Choose a reason for hiding this comment

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

You never seem to instantiate a GoldensClient, though. Only its subclasses get instantiated, so you should be able to still mark this class as abstract.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

/// informed by the basedir of the [FlutterSkiaGoldFileComparator].
Future<void> auth() async {
Future<void> auth(Directory workDirectory) async {
assert(workDirectory != null);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add an error message here indicating that auth can only be called once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know that I would want to throw an error if it is already authorized, I just made it a no-op in that case.

@Piinks
Copy link
Contributor Author

Piinks commented Jul 12, 2019

tool_test_integration-{platform} presubmit tests have been timing out. I'm going to update the branch again and see if it resolves this. Just waiting on these tests to land this change.

@Piinks Piinks merged commit eb0b179 into flutter:master Jul 12, 2019
@tvolkert
Copy link
Contributor

FYI for future reference: https://github.com/flutter/flutter/wiki/Tree-hygiene#squashing-commits

(as seen in eb0b179)

Piinks added a commit that referenced this pull request Jul 12, 2019
Piinks added a commit that referenced this pull request Jul 12, 2019
This reverts commit eb0b179.
Skia Gold post-submit test were failing due to the service account not being found on Cirrus.
@Piinks Piinks mentioned this pull request Jul 12, 2019
8 tasks
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
* Fresh PR for Gold integration.

* Nits

* WIP

* Artifacts from merge

* Changed some platform dependencies for web, added library prefix notation for Skia Gold test names.

* Updating for CI implementation

* Write out service account

* Writing to skip out

* WIP

* ++

* Fixing depot tools deps

* Windows depot_tools

* Fixing setup scripts

* ++

* depot tools

* ++

* WIP

* Tracing depot_tools clone

* WIP

* ++

* analyzer

* WIP

* chrome typo

* copy artifact

* Working on tests

* Code cleanup

* ++

* Code cleanup, updated tests

* ++ review feedback

* Review

* Analyzer

* Review feedback

* Nits from review

* PRogress

* ++

* Fixing tests

* ++

* Testing repo route

* Just needing documention around new structures.

* cleanup

* Analyzer

* Documentation updates

* Documentation updates

* Cirrus updates

* cirrus nit

* Review feedback

* Review feedback

* Fixing skip comparator

* Fix base directory for Skia Gold case

* ++

* Feedback

* ++

* Fixed uri assertion

* Made GoldensClient abstract, altered SkiaGoldClient constructor

* Analyzer
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
This reverts commit eb0b179.
Skia Gold post-submit test were failing due to the service account not being found on Cirrus.
@Piinks Piinks deleted the goldIntegration branch November 22, 2019 00:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants