-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[web] enable CanvasKit tests using a local bundle fetched from CIPD #92134
Conversation
e5a82ca
to
371987b
Compare
dev/bots/test.dart
Outdated
@@ -1430,8 +1497,7 @@ Future<void> _runFlutterWebTest(String workingDirectory, List<String> tests) asy | |||
'--concurrency=1', // do not parallelize on Cirrus, to reduce flakiness | |||
'-v', | |||
'--platform=chrome', | |||
// TODO(ferhatb): Run web tests with both rendering backends. | |||
'--web-renderer=html', // use html backend for web tests. | |||
'--web-renderer=$webRenderer', // use html backend for web tests. |
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.
nit: update comment
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.
Done.
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.
.ci.yaml lgtm
{"dependency": "goldctl"} | ||
] | ||
shard: web_canvaskit_tests | ||
subshard: "0" |
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.
What's the reasoning for these being strings instead of numbers?
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.
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..
@@ -365,6 +389,37 @@ class FlutterWebPlatform extends PlatformPlugin { | |||
} | |||
} | |||
|
|||
/// Serves a local build of CanvasKit, replacing the CDN build, which can |
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.
nice!
@@ -637,7 +637,7 @@ void main() { | |||
environment.outputDir.childDirectory('a').childFile('a.txt') | |||
..createSync(recursive: true) | |||
..writeAsStringSync('A'); | |||
await const WebServiceWorker().build(environment); | |||
await WebServiceWorker(globals.fs).build(environment); |
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.
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);
...
});
}
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.
Done.
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.
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
.
@@ -637,7 +637,7 @@ void main() { | |||
environment.outputDir.childDirectory('a').childFile('a.txt') | |||
..createSync(recursive: true) | |||
..writeAsStringSync('A'); | |||
await const WebServiceWorker().build(environment); | |||
await WebServiceWorker(globals.fs).build(environment); |
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.
avoid adding globals to tests
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.
Done.
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.
Some nits about the tests, but otherwise the tools change LGTM
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.
LGTM with test ownership.
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.
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.
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.
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
@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 |
1 similar comment
@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 |
(sorry for duplicate posts; Github is giving me errors when I post but is actually posting my comments) |
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. 🙃 |
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. |
dev/bots/test.dart
Outdated
Future<void> _runWebHtmlUnitTests() async { | ||
await _runWebUnitTests('html'); | ||
} | ||
|
||
Future<void> _runWebCanvasKitUnitTests() async { | ||
await _runWebUnitTests('canvaskit'); | ||
} |
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.
Suggestion: There's no need for async
/await
here.
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'); | |
} |
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.
Done.
final Directory canvasKitDirectory = flutterWebSdk.childDirectory('canvaskit'); | ||
for (final File file in canvasKitDirectory.listSync(recursive: true).whereType<File>()) { | ||
final String relativePath = fileSystem.path.relative(file.path, from: canvasKitDirectory.path); | ||
final String targetPath = fileSystem.path.join(environment.outputDir.path, 'canvaskit', relativePath); |
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.
Just curious, why not:
final File target = environment.outputDir.childDirectory('canvaskit').childFile(relativePath);
await file.copy(target.path);
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.
childFile
takes a basename, not a sub-path.
// TODO(yjbanov): https://github.com/flutter/flutter/issues/52588 | ||
// | ||
// Update this when we start building CanvasKit from sources. In the | ||
// meantime, get the Web SDK directory directory from cache rather than |
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.
s/directory directory/directory
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.
Done.
SGTM! |
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.
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. |
Could you explain me please how exactly does this solve #70101? |
I think this command will use bundled canvaskit from your build folder. |
build/web/canvaskit
duringflutter build web
.Fixes #71604
Fixes #70101