Skip to content

Commit

Permalink
Update release instructions and clean up update deps helper (#6320)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Sep 5, 2023
1 parent 7100e3f commit a6de07d
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 225 deletions.
1 change: 0 additions & 1 deletion packages/devtools_extensions/bin/_build_and_copy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:path/path.dart' as path;
///
/// Example usage:
///
/// dart pub global activate devtools_extensions;
/// dart run devtools_extensions build_and_copy \
/// --source=path/to/your_extension_web_app \
/// --dest=path/to/your_pub_package/extension/devtools
Expand Down
60 changes: 18 additions & 42 deletions tool/RELEASE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Make sure:
#### Verify the version changes for the Release PR

Verify the code on the release PR:
- updated the pubspecs under packages/
- updated all references to those packages
- updated the `devtools_app` and `devtools_test` pubspec versions
- updated all references to those packages in other `pubspec.yaml` files
- updated the version constant in `packages/devtools_app/lib/devtools.dart`

These packages always have their version numbers updated in lock, so we don't have to worry about versioning.
Expand Down Expand Up @@ -76,7 +76,6 @@ These packages always have their version numbers updated in lock, so we don't ha

Receive an LGTM for the PR, squash and commit.


### Tag the release
- Checkout the commit from which you want to release DevTools
- This is likely the commit, on `master`, for the PR you just landed
Expand All @@ -89,38 +88,20 @@ Receive an LGTM for the PR, squash and commit.
tool/tag_version.sh;
```

### Upload the DevTools binary to CIPD
- Use the update.sh script to build and upload the DevTools binary to CIPD:
```shell
TARGET_COMMIT_HASH=<Commit hash for the version bump commit in DevTools>
```
```shell
cd $LOCAL_DART_SDK && \
git rebase-update && \
third_party/devtools/update.sh $TARGET_COMMIT_HASH [optional --no-update-flutter];
```
For cherry pick releases that need to be built from a specific version of Flutter,
checkout the Flutter version on your local flutter repo (the Flutter SDK that
`which flutter` points to). Then when you run the `update.sh` command, include the
`--no-update-flutter` flag:
### Wait for the binary to be uploaded CIPD

```shell
third_party/devtools/update.sh $TARGET_COMMIT_HASH --no-update-flutter
```
On each DevTools commit, DevTools is built and uploaded to CIPD. You can check the
status of the builds on this [dashboard](https://ci.chromium.org/ui/p/dart-internal/builders/flutter/devtools). Within minutes, a build should be uploaded for the commit you just merged and tagged.

### Update the DevTools hash in the Dart SDK

- Create new branch for your changes:
```shell
cd $LOCAL_DART_SDK && \
git new-branch dt-release;
```
- Update the `devtools_rev` entry in the Dart SDK [DEPS file](https://github.com/dart-lang/sdk/blob/master/DEPS)
- set the `devtools_rev` entry to the `TARGET_COMMIT_HASH`.
- See this [example CL](https://dart-review.googlesource.com/c/sdk/+/215520) for reference.
Run the tool script with the commit hash you just merged and tagged:
```shell
dart run tool/bin/devtools_tool.dart update-sdk-deps -c <commit-hash>
```

This automatically creates a Gerrit CL with the DEPS update for DevTools.
Quickly test the build and then add a reviewer.

- Build the dart sdk locally

Expand All @@ -140,22 +121,17 @@ checkout the Flutter version on your local flutter repo (the Flutter SDK that
out/ReleaseX64/dart-sdk/bin/dart devtools
```

- If the version of DevTools you just published to CIPD loads properly
> You may need to hard reload and clear your browser cache in order to see the changes.
- If the version of DevTools you just published to CIPD does not load properly,
you may need to hard reload and clear your browser cache.

- push up the SDK CL for review.
```shell
git add . && \
git commit -m "Bump DevTools DEP to $NEW_DEVTOOLS_VERSION" && \
git cl upload -s;
```
- Add a reviewer and submit once approved.

### Publish package:devtools_shared on pub
### Publish DevTools pub packages

`package:devtools_shared` is the only DevTools package that is published on pub.
If `package:devtools_app_shared`, `package:devtools_extensions`, or `package:devtools_shared`
have unreleased changes, publish these packages to pub.

- From the `devtools/packages/devtools_shared` directory, run:
- From the respective `devtools/packages/devtools_*` directories, run:
```shell
flutter pub publish
```
Expand Down
2 changes: 1 addition & 1 deletion tool/bin/repo_tool.dart → tool/bin/devtools_tool.dart
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:devtools_repo/repo_tool.dart';
import 'package:devtools_tool/devtools_command_runner.dart';

void main(List<String> args) async {
final runner = DevToolsCommandRunner();
Expand Down
17 changes: 14 additions & 3 deletions tool/bots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ dart --disable-analytics
flutter --version
dart --version

# Fetch dependencies for the tool/ directory
pushd tool
flutter pub get
popd

# The `devtools_tool` executable should be available after running `flutter pub global activate`
flutter pub global activate --source path tool
export PATH="$PATH":"$HOME/.pub-cache/bin"

devtools_tool -h

# Fetch dependencies
pushd packages/devtools_app
flutter pub get
Expand Down Expand Up @@ -89,13 +100,13 @@ if [ "$BOT" = "main" ]; then
$(dirname $(which flutter))/dart format --output=none --set-exit-if-changed .

# Make sure the app versions are in sync.
repo_tool repo-check
devtools_tool repo-check

# Get packages
repo_tool packages-get
devtools_tool packages-get

# Analyze the code
repo_tool analyze
devtools_tool analyze

popd

Expand Down
6 changes: 3 additions & 3 deletions tool/build_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const argUpdatePerfetto = '--update-perfetto';
/// This script builds DevTools in release mode by running the
/// `./tool/build_release.sh` script and then serves DevTools with a locally
/// running DevTools server.
///
///
/// If [argNoBuildApp] is present, the DevTools web app will not be rebuilt.
///
///
/// If [argNoUpdateFlutter] is present, the Flutter SDK will not be updated to
/// the latest Flutter candidate. Use this flag to save the cost of updating the
/// Flutter SDK when you already have the proper SDK checked out.
///
///
/// If [argUpdatePerfetto] is present, the precompiled bits for Perfetto will
/// be updated from the [update_perfetto.sh] script as part of the DevTools
/// build process (e.g. [build_release.sh]).
Expand Down
108 changes: 108 additions & 0 deletions tool/lib/commands/update_dart_sdk_deps.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright 2023 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:io/io.dart';
import 'package:path/path.dart' as path;

import '../utils.dart';

const _argCommit = 'commit';

/// This command updates the "devtools_rev" hash in the Dart SDK DEPS file with
/// the provided commit hash, and creates a Gerrit CL for review.
///
/// This hash is the ID for a DevTools build stored in CIPD, which is
/// automatically built and uploaded to CIPD on each DevTools commit.
///
/// To run this script:
/// `dart run tool/bin/devtools_tool.dart update-sdk-deps -c <commit-hash>`
class UpdateDartSdkDepsCommand extends Command {
UpdateDartSdkDepsCommand() {
argParser.addOption(
_argCommit,
abbr: 'c',
help: 'The DevTools commit hash to release into the Dart SDK.',
mandatory: true,
);
}
@override
String get name => 'update-sdk-deps';

@override
String get description =>
'Updates the "devtools_rev" hash in the Dart SDK DEPS file with the '
'provided commit hash, and creates a Gerrit CL for review';

@override
Future run() async {
final commit = argResults![_argCommit];
final dartSdkLocation = localDartSdkLocation();
final processManager = ProcessManager();

print('Preparing a local Dart SDK branch...');
await DartSdkHelper.fetchAndCheckoutMaster(processManager);
await runAll(
processManager,
workingDirectory: dartSdkLocation,
additionalErrorMessage: DartSdkHelper.commandDebugMessage,
commands: [
CliCommand(
'git branch -D devtools-$commit',
throwOnException: false,
),
CliCommand('git new-branch devtools-$commit'),
],
);

print('Updating the DEPS file with the new DevTools hash...');
_writeToDepsFile(commit, dartSdkLocation);

print('Committing the changes and creating a Gerrit CL...');
await runAll(
processManager,
workingDirectory: dartSdkLocation,
additionalErrorMessage: DartSdkHelper.commandDebugMessage,
commands: [
CliCommand('git add .'),
CliCommand.from(
'git',
[
'commit',
'-m',
'Update DevTools rev to $commit',
],
),
// TODO(kenz): is there a way to automatically close the file that pops up
// with the commit description?
CliCommand('git cl upload -s'),
],
);

// Closes stdin for the entire program.
await sharedStdIn.terminate();
}

void _writeToDepsFile(String commit, String localDartSdkLocation) {
final depsFilePath = path.join(localDartSdkLocation, 'DEPS');
final depsFile = File(depsFilePath);
if (!depsFile.existsSync()) {
throw Exception('Count not find SDK DEPS file at: $depsFilePath');
}

final devToolsRevMarker = ' "devtools_rev":';
final newFileContent = StringBuffer();
final lines = depsFile.readAsLinesSync();
for (final line in lines) {
if (line.startsWith(devToolsRevMarker)) {
newFileContent.writeln('$devToolsRevMarker "$commit",');
} else {
newFileContent.writeln(line);
}
}
depsFile.writeAsStringSync(newFileContent.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import 'commands/list.dart';
import 'commands/packages_get.dart';
import 'commands/repo_check.dart';
import 'commands/rollback.dart';
import 'commands/update_dart_sdk_deps.dart';

class DevToolsCommandRunner extends CommandRunner {
DevToolsCommandRunner()
: super('repo_tool', 'A repo management tool for DevTools.') {
: super('devtools_tool', 'A repo management tool for DevTools.') {
addCommand(AnalyzeCommand());
addCommand(RepoCheckCommand());
addCommand(ListCommand());
addCommand(PackagesGetCommand());
addCommand(RollbackCommand());
addCommand(UpdateDartSdkDepsCommand());
}
}
Loading

0 comments on commit a6de07d

Please sign in to comment.