Skip to content
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

[Draft] Puppeteer tests on CI #2132

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/daily_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ jobs:
working-directory: webdev
- name: "Notify failure"
if: "always() && steps.dwds_daily_tests.conclusion == 'failure' || steps.webdev_daily_tests.conclusion == 'failure'"
run: |
curl -H "Content-Type: application/json" -X POST -d \
"{'text':'Daily DWDS tests failed! ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}'}" \
"${{ secrets.WEBDEV_NOTIFICATION_CHAT_WEBHOOK }}"
- id: webdev_pub_upgrade
name: ; dart pub upgrade
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: dwds
- id: dwds_daily_tests
name: "dwds; dart test --tags=daily"
run: "dart test --tags=daily"
if: "always() && steps.dwds_pub_upgrade.conclusion == 'success'"
working-directory: dwds
- name: "Notify failure"
if: "always() && steps.dwds_daily_tests.conclusion == 'failure'"
run: |
curl -H "Content-Type: application/json" -X POST -d \
"{'text':'Daily Webdev tests failed! ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}'}" \
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/puppeteer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Puppeteer tests
on:
pull_request:
push:
branches:
- master
jobs:
test:
name: Run tests ${{matrix.sdk}} on ${{matrix.os}}
runs-on: macos-latest
steps:
- name: Set up Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: dev
- id: checkout
name: Checkout repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
- name: Get deps for dwds
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: dwds
- name: Get deps for debug extension
run: dart pub upgrade
if: "always() && steps.checkout.conclusion == 'success'"
working-directory: dwds/debug_extension_mv3
- name: Download Chromium
run: dart test/puppeteer/download_chromium.dart
working-directory: dwds
- name: Run Puppeteer tests
run: dart test test/puppeteer/extension_test_mv2.dart --no-retry --platform vm
working-directory: dwds
3 changes: 2 additions & 1 deletion dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ dependencies:

dev_dependencies:
build: ^2.0.0
build_runner: ^2.4.0
# TODO(https://github.com/dart-lang/build/issues/3531) Remove pin once fixed.
build_runner: 2.4.3
built_collection: ^5.0.0
built_value_generator: ^8.3.0
build_web_compilers: ^4.0.4
Expand Down
13 changes: 11 additions & 2 deletions dwds/debug_extension_mv3/tool/build_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main(List<String> arguments) async {
..addFlag(_mv3Flag, negatable: true, defaultsTo: false);
final argResults = parser.parse(arguments);

exitCode = await run(
final exitCode = await run(
isProd: argResults[_prodFlag] as bool,
isMV3: argResults[_mv3Flag] as bool,
);
Expand All @@ -43,7 +43,16 @@ Future<int> run({required bool isProd, required bool isMV3}) async {
_logInfo('Compiling extension with dart2js to /compiled directory');
final compileStep = await Process.start(
'dart',
['run', 'build_runner', 'build', 'web', '--output', 'build', '--release'],
[
'run',
'build_runner',
'build',
'web',
'--output',
'build',
'--release',
'--delete-conflicting-outputs'
],
);
final compileExitCode = await _handleProcess(compileStep);
// Terminate early if compilation failed:
Expand Down
7 changes: 7 additions & 0 deletions dwds/debug_extension_mv3/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import 'messaging.dart';
import 'storage.dart';
import 'utils.dart';

// Note: The extension tests wait for this string to be logged to the console to
// ensure that the Dart app has been detected:
const dartAppDetectedMsg = 'Dart app detected.';

void main() {
_registerListeners();
}
Expand Down Expand Up @@ -210,6 +214,9 @@ Future<void> _updateIcon(int activeTabId) async {
tabId: activeTabId,
);
multipleApps == null ? _setDebuggableIcon() : _setWarningIcon();
// Do not remove. This is required by the tests to wait for detection of the
// Dart app:
debugLog(dartAppDetectedMsg);
}

void _setDebuggableIcon() {
Expand Down
6 changes: 6 additions & 0 deletions dwds/test/puppeteer/download_chromium.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:puppeteer/puppeteer.dart';

void main() async {
final chromePath = await downloadChrome();
print('DOWNLOADED CHROME: ${chromePath.executablePath}');
}
Loading
Loading