Skip to content

[web] enable CanvasKit tests using a local bundle fetched from CIPD - #92134

Merged
yjbanov merged 1 commit into
flutter:masterfrom
yjbanov:ck-tests
Oct 21, 2021
Merged

yjbanov merged 1 commit into
flutter:masterfrom
yjbanov:ck-tests

Conversation

@yjbanov

@yjbanov yjbanov commented Oct 19, 2021 •

Copy link
Copy Markdown
Contributor
  • Fetch CanvasKit from CIPD to the Flutter SDK cache.
  • Copy CanvasKit files to build/web/canvaskit during flutter build web.
  • Use the local CanvasKit copy (instead of unpkg.com) when running unit-tests.
  • Add test shards that run currently passing tests in CanvasKit mode (which is the vast majority).
  • Golden tests use the ("WebRenderer": "canvaskit") key/value pair to distinguish the goldens from the HTML ones.

Fixes #71604
Fixes #70101

@flutter-dashboard flutter-dashboard Bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Oct 19, 2021
@google-cla google-cla Bot added the cla: yes label Oct 19, 2021
@yjbanov
yjbanov force-pushed the ck-tests branch 3 times, most recently from e5a82ca to 371987b Compare October 19, 2021 23:49
@yjbanov
yjbanov marked this pull request as ready for review October 20, 2021 19:52
Comment thread dev/bots/test.dart Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: update comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@CaseyHillers CaseyHillers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.ci.yaml lgtm

Comment thread .ci.yaml Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reasoning for these being strings instead of numbers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Technically all subshard names are strings, but some shards have a custom convention. Web shards use the numeric convention that uses subshard number ("0", "1", etc) for all subshards except the last one, which uses "_last" suffix (e.g. 7_last).

Having said that I totally botched the convention and now I fixed it. Unfortunately, because .ci.yaml changes do not take effect immediately it's easy to make mistakes like that..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice!

@christopherfujino christopherfujino Oct 20, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Avoid adding new calls to globals in tests. I suggest doing something like:

for (final FileSystemStyle style in <FileSystemStyle>[FileSystemStyle.posix, FileSystemStyle.windows]) {
  test('WebServiceWorker generates a service_worker for a web resource folder for ${style == FileSystemStyle.posix ? 'posix' : 'windows'}', () {
    final FileSystem fileSystem = MemoryFileSystem(style: style);
    ...
  });
}

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After an offline discussion, reverted to globals.fs. The test is using TestBed and Environment which are setup to use globals.fs. This file overall needs a separate clean-ups to stop depending on globals.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

avoid adding globals to tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@christopherfujino christopherfujino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some nits about the tests, but otherwise the tools change LGTM

@keyonghan keyonghan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with test ownership.

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the test shards that are being added show up in CI here? They do not appear to be listed as checks, and without running them, Gold is not seeing this new info.

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to https://flutter-gold.skia.org/search?crs=github&issue=92134&patchsets=1&positive=true
these are the only builds that are sending info to Gold:

  • Windows framework_tests_widgets
  • Windows framework_tests_libraries
  • Linux web_tests_5
  • Linux web_tests_4
  • Linux web_tests_3
  • Linux web_tests_2
  • Mac framework_tests_widgets
  • Linux web_tests_1
  • Linux web_tests_7_last
  • Linux web_tests_6
  • Linux framework_tests_widgets
  • Linux web_tests_0
  • Linux framework_tests_libraries
  • Mac framework_tests_libraries

@yjbanov

yjbanov commented Oct 20, 2021

Copy link
Copy Markdown
Contributor Author

@Piinks good question. Unfortunately, the new shards do not show up right away. More details here, but the tl;dr is that new test shards are added as bringup: true and submitted. They take time to propagate to LUCI and start running without failing the build. Once we confirm that everything is working (perhaps with follow-up fixes), then we can make them build blocking.

1 similar comment
@yjbanov

yjbanov commented Oct 20, 2021

Copy link
Copy Markdown
Contributor Author

@Piinks good question. Unfortunately, the new shards do not show up right away. More details here, but the tl;dr is that new test shards are added as bringup: true and submitted. They take time to propagate to LUCI and start running without failing the build. Once we confirm that everything is working (perhaps with follow-up fixes), then we can make them build blocking.

@yjbanov

yjbanov commented Oct 20, 2021

Copy link
Copy Markdown
Contributor Author

(sorry for duplicate posts; Github is giving me errors when I post but is actually posting my comments)

@Piinks

Piinks commented Oct 20, 2021

Copy link
Copy Markdown
Contributor

Ah I see, ok! In that case it sounds like we would validate later that Gold is receiving the data correctly. Would that testing happen in post submit then? Currently the Gold flow checks images in during presubmit. It may cause some issues temporarily if these are run in post submit first, not sure though since we haven't done that before. 🙃

@yjbanov

yjbanov commented Oct 20, 2021

Copy link
Copy Markdown
Contributor Author

Ah I see, ok! In that case it sounds like we would validate later that Gold is receiving the data correctly. Would that testing happen in post submit then? Currently the Gold flow checks images in during presubmit. It may cause some issues temporarily if these are run in post submit first, not sure though since we haven't done that before. upside_down_face

Oh no! Catch-22. @CaseyHillers save us!

@CaseyHillers

Copy link
Copy Markdown
Contributor

Oh no! Catch-22. @CaseyHillers save us!

@Piinks if we're not running in presubmit, I don't think there would be a way for gold to block PRs. This should be safe to land. If there's a breakage, that's a bug and we'll need to fix the process to adhere with the tree's flaky test policy.

Comment thread dev/bots/test.dart Outdated
Comment on lines 860 to 866

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: There's no need for async/await here.

Suggested change
Future<void> _runWebHtmlUnitTests() async {
await _runWebUnitTests('html');
}
Future<void> _runWebCanvasKitUnitTests() async {
await _runWebUnitTests('canvaskit');
}
Future<void> _runWebHtmlUnitTests() {
return _runWebUnitTests('html');
}
Future<void> _runWebCanvasKitUnitTests() {
return _runWebUnitTests('canvaskit');
}

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious, why not:

final File target = environment.outputDir.childDirectory('canvaskit').childFile(relativePath);
await file.copy(target.path);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

childFile takes a basename, not a sub-path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/directory directory/directory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Piinks

Piinks commented Oct 21, 2021

Copy link
Copy Markdown
Contributor

@Piinks if we're not running in presubmit, I don't think there would be a way for gold to block PRs. This should be safe to land. If there's a breakage, that's a bug and we'll need to fix the process to adhere with the tree's flaky test policy.

SGTM!

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - Gold changes look fine, but will need to confirm and triage all of the images with the new key set once these shards are actually running.

@yjbanov

yjbanov commented Oct 21, 2021

Copy link
Copy Markdown
Contributor Author

LGTM - Gold changes look fine, but will need to confirm and triage all of the images with the new key set once these shards are actually running.

Thanks! I might need some handholding to see it through. Might need help from you, @Piinks, and from @CaseyHillers.

@abelokon0711

Copy link
Copy Markdown

Could you explain me please how exactly does this solve #70101?

@P-B1101

P-B1101 commented Jul 2, 2022

Copy link
Copy Markdown

I think this command will use bundled canvaskit from your build folder.
flutter build web --dart-define=FLUTTER_WEB_CANVASKIT_URL=/canvaskit/
I test it using IIS from my localhost and it's worked. I think it will work on any other host too.

auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 1, 2026
Part of flutter/flutter#92134

It seems the issue is already closed and fixed, so I'm attempting to remove this TODO

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
Part of flutter/flutter#92134

It seems the issue is already closed and fixed, so I'm attempting to remove this TODO

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
Part of flutter/flutter#92134

It seems the issue is already closed and fixed, so I'm attempting to remove this TODO

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Most canvaskit framework tests are failing [web] support bundling CanvasKit instead of CDN

8 participants