Skip to content

Commit

Permalink
Merge branch 'main' into merge-term_glyph-package
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem authored Dec 17, 2024
2 parents 1d99aaa + 4dcd4d9 commit 983e272
Show file tree
Hide file tree
Showing 112 changed files with 2,564 additions and 910 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/test_reflective_loader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:test_reflective_loader"
about: "Create a bug or file a feature request against package:test_reflective_loader."
labels: "package:test_reflective_loader"
---
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/timing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:timing"
about: "Create a bug or file a feature request against package:timing."
labels: "package:timing"
---
8 changes: 8 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/term_glyph/**'

'package:test_reflective_loader':
- changed-files:
- any-glob-to-any-file: 'pkgs/test_reflective_loader/**'

'package:timing':
- changed-files:
- any-glob-to-any-file: 'pkgs/timing/**'

'package:unified_analytics':
- changed-files:
- any-glob-to-any-file: 'pkgs/unified_analytics/**'
2 changes: 2 additions & 0 deletions .github/workflows/bazel_worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- run: dart pub get
- run: "dart format --output=none --set-exit-if-changed ."
if: ${{ matrix.sdk == 'dev' }}
- name: Test
run: ./tool/travis.sh
43 changes: 43 additions & 0 deletions .github/workflows/test_reflective_loader.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: package:test_reflective_loader

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/test_reflective_loader.yaml'
- 'pkgs/test_reflective_loader/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/test_reflective_loader.yaml'
- 'pkgs/test_reflective_loader/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github

defaults:
run:
working-directory: pkgs/test_reflective_loader/

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev, 3.1]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}

- run: dart pub get
- name: dart format
run: dart format --output=none --set-exit-if-changed .
- run: dart analyze --fatal-infos
- run: dart test
67 changes: 67 additions & 0 deletions .github/workflows/timing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: package:timing

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/timing.yaml'
- 'pkgs/timing/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/timing.yaml'
- 'pkgs/timing/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/timing/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [3.4, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
run: dart pub get
- run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev, 2.2.0
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.4, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
run: dart pub get
- run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ don't naturally belong to other topic monorepos (like
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
| [term_glyph](pkgs/term_glyph/) | Useful Unicode glyphs and ASCII substitutes. | [![package issues](https://img.shields.io/badge/package:term_glyph-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aterm_glyph) | [![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) |
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
| [timing](pkgs/timing/) | A simple package for tracking the performance of synchronous and asynchronous actions. | [![package issues](https://img.shields.io/badge/package:timing-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atiming) | [![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing) |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |

## Publishing automation
Expand Down
19 changes: 11 additions & 8 deletions pkgs/bazel_worker/benchmark/benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ Future<void> main() async {
var path = 'blaze-bin/some/path/to/a/file/that/is/an/input/$i';
workRequest
..arguments.add('--input=$path')
..inputs.add(Input(
path: '',
digest: List.filled(70, 0x11),
));
..inputs.add(Input(path: '', digest: List.filled(70, 0x11)));
}

// Serialize it.
Expand All @@ -24,14 +21,20 @@ Future<void> main() async {
print('Request has $length requestBytes.');

// Add the length in front base 128 encoded as in the worker protocol.
requestBytes =
Uint8List.fromList(requestBytes.toList()..insertAll(0, _varInt(length)));
requestBytes = Uint8List.fromList(
requestBytes.toList()..insertAll(0, _varInt(length)),
);

// Split into 10000 byte chunks.
var lists = <Uint8List>[];
for (var i = 0; i < requestBytes.length; i += 10000) {
lists.add(Uint8List.sublistView(
requestBytes, i, min(i + 10000, requestBytes.length)));
lists.add(
Uint8List.sublistView(
requestBytes,
i,
min(i + 10000, requestBytes.length),
),
);
}

// Time `AsyncMessageGrouper` and deserialization.
Expand Down
5 changes: 4 additions & 1 deletion pkgs/bazel_worker/e2e_test/bin/async_worker_in_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import 'package:e2e_test/forwards_to_isolate_async_worker.dart';
Future main(List<String> args, [SendPort? message]) async {
var receivePort = ReceivePort();
await Isolate.spawnUri(
Uri.file('async_worker.dart'), [], receivePort.sendPort);
Uri.file('async_worker.dart'),
[],
receivePort.sendPort,
);

var worker = await ForwardsToIsolateAsyncWorker.create(receivePort);
await worker.run();
Expand Down
5 changes: 1 addition & 4 deletions pkgs/bazel_worker/e2e_test/lib/async_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class ExampleAsyncWorker extends AsyncWorkerLoop {

@override
Future<WorkResponse> performRequest(WorkRequest request) async {
return WorkResponse(
exitCode: 0,
output: request.arguments.join('\n'),
);
return WorkResponse(exitCode: 0, output: request.arguments.join('\n'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ class ForwardsToIsolateAsyncWorker extends AsyncWorkerLoop {
final IsolateDriverConnection _isolateDriverConnection;

static Future<ForwardsToIsolateAsyncWorker> create(
ReceivePort receivePort) async {
ReceivePort receivePort,
) async {
return ForwardsToIsolateAsyncWorker(
await IsolateDriverConnection.create(receivePort));
await IsolateDriverConnection.create(receivePort),
);
}

ForwardsToIsolateAsyncWorker(this._isolateDriverConnection);
Expand Down
2 changes: 1 addition & 1 deletion pkgs/bazel_worker/e2e_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:

dev_dependencies:
cli_util: ^0.4.2
dart_flutter_team_lints: ^1.0.0
dart_flutter_team_lints: ^3.0.0
path: ^1.8.0
test: ^1.16.0
18 changes: 11 additions & 7 deletions pkgs/bazel_worker/e2e_test/test/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ import 'package:test/test.dart';

void main() {
var dart = p.join(sdkPath, 'bin', 'dart');
runE2eTestForWorker('sync worker',
() => Process.start(dart, [p.join('bin', 'sync_worker.dart')]));
runE2eTestForWorker('async worker',
() => Process.start(dart, [p.join('bin', 'async_worker.dart')]));
runE2eTestForWorker(
'async worker in isolate',
() =>
Process.start(dart, [p.join('bin', 'async_worker_in_isolate.dart')]));
'sync worker',
() => Process.start(dart, [p.join('bin', 'sync_worker.dart')]),
);
runE2eTestForWorker(
'async worker',
() => Process.start(dart, [p.join('bin', 'async_worker.dart')]),
);
runE2eTestForWorker(
'async worker in isolate',
() => Process.start(dart, [p.join('bin', 'async_worker_in_isolate.dart')]),
);
}

void runE2eTestForWorker(String groupName, SpawnWorker spawnWorker) {
Expand Down
12 changes: 8 additions & 4 deletions pkgs/bazel_worker/example/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import 'package:bazel_worker/driver.dart';
void main() async {
var scratchSpace = await Directory.systemTemp.createTemp();
var driver = BazelWorkerDriver(
() => Process.start(Platform.resolvedExecutable,
[Platform.script.resolve('worker.dart').toFilePath()],
workingDirectory: scratchSpace.path),
maxWorkers: 4);
() => Process.start(
Platform.resolvedExecutable,
[
Platform.script.resolve('worker.dart').toFilePath(),
],
workingDirectory: scratchSpace.path),
maxWorkers: 4,
);
var response = await driver.doWork(WorkRequest(arguments: ['foo']));
if (response.exitCode != EXIT_CODE_OK) {
print('Worker request failed');
Expand Down
17 changes: 11 additions & 6 deletions pkgs/bazel_worker/lib/src/async_message_grouper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ class AsyncMessageGrouper implements MessageGrouper {
// Copy as much as possible from the input buffer. Limit is the
// smaller of the remaining length to fill in the message and the
// remaining length in the buffer.
var lengthToCopy = min(_message.length - _messagePos,
_inputBuffer.length - _inputBufferPos);
var lengthToCopy = min(
_message.length - _messagePos,
_inputBuffer.length - _inputBufferPos,
);
_message.setRange(
_messagePos,
_messagePos + lengthToCopy,
_inputBuffer.sublist(
_inputBufferPos, _inputBufferPos + lengthToCopy));
_messagePos,
_messagePos + lengthToCopy,
_inputBuffer.sublist(
_inputBufferPos,
_inputBufferPos + lengthToCopy,
),
);
_messagePos += lengthToCopy;
_inputBufferPos += lengthToCopy;

Expand Down
Loading

0 comments on commit 983e272

Please sign in to comment.