Create packages only for release builds, and publish when created. (#14476)
This changes the publishing of archives so that it happens on the chrome_infra bots when they build a packaged branch instead of as part of the dev_roll process. It uses the tagged version in the branch, and leaves the git repo that it clones checked out on the branch and hash used to build the package. It updates metadata located at gs://flutter_infra/releases/releases_.json (where is one of macos, linux, or windows) once published, since it would be complex to do the proper locking to keep them all in one shared .json file safely. A separate [change to the chrome_infra bots](https://chromium-review.googlesource.com/c/chromium/tools/build/+/902823) was made to instruct them to build packaged for the dev, beta, and release branches (but not master anymore).
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
// Copyright 2018 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:test/test.dart';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../lib/archive_publisher.dart';
|
||||
import 'fake_process_manager.dart';
|
||||
|
||||
void main() {
|
||||
group('ArchivePublisher', () {
|
||||
final List<String> emptyStdout = <String>[''];
|
||||
FakeProcessManager processManager;
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
processManager = new FakeProcessManager();
|
||||
tempDir = await Directory.systemTemp.createTemp('flutter_');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
// On Windows, the directory is locked and not able to be deleted, because it is a
|
||||
// temporary directory. So we just leave some (very small, because we're not actually
|
||||
// building archives here) trash around to be deleted at the next reboot.
|
||||
if (!Platform.isWindows) {
|
||||
await tempDir.delete(recursive: true);
|
||||
}
|
||||
});
|
||||
|
||||
test('calls the right processes', () {
|
||||
final Map<String, List<String>> calls = <String, List<String>>{
|
||||
'gsutil acl get gs://flutter_infra/releases/releases.json': emptyStdout,
|
||||
'gsutil cp gs://flutter_infra/flutter/deadbeef/flutter_linux_deadbeef.tar.xz '
|
||||
'gs://flutter_infra/releases/dev/linux/flutter_linux_1.2.3-dev.tar.xz': emptyStdout,
|
||||
'gsutil cp gs://flutter_infra/flutter/deadbeef/flutter_mac_deadbeef.tar.xz '
|
||||
'gs://flutter_infra/releases/dev/mac/flutter_mac_1.2.3-dev.tar.xz': emptyStdout,
|
||||
'gsutil cp gs://flutter_infra/flutter/deadbeef/flutter_win_deadbeef.zip '
|
||||
'gs://flutter_infra/releases/dev/win/flutter_win_1.2.3-dev.zip': emptyStdout,
|
||||
'gsutil cat gs://flutter_infra/releases/releases.json': <String>[
|
||||
'''{
|
||||
"base_url": "https://storage.googleapis.com/flutter_infra/releases",
|
||||
"current_beta": "6da8ec6bd0c4801b80d666869e4069698561c043",
|
||||
"current_dev": "f88c60b38c3a5ef92115d24e3da4175b4890daba",
|
||||
"releases": {
|
||||
"6da8ec6bd0c4801b80d666869e4069698561c043": {
|
||||
"linux_archive": "beta/linux/flutter_linux_0.21.0-beta.tar.xz",
|
||||
"mac_archive": "beta/mac/flutter_mac_0.21.0-beta.tar.xz",
|
||||
"windows_archive": "beta/win/flutter_win_0.21.0-beta.tar.xz",
|
||||
"release_date": "2017-12-19T10:30:00,847287019-08:00",
|
||||
"release_notes": "beta/release_notes_0.21.0-beta.html",
|
||||
"version": "0.21.0-beta"
|
||||
},
|
||||
"f88c60b38c3a5ef92115d24e3da4175b4890daba": {
|
||||
"linux_archive": "dev/linux/flutter_linux_0.22.0-dev.tar.xz",
|
||||
"mac_archive": "dev/mac/flutter_mac_0.22.0-dev.tar.xz",
|
||||
"windows_archive": "dev/win/flutter_win_0.22.0-dev.tar.xz",
|
||||
"release_date": "2018-01-19T13:30:09,728487019-08:00",
|
||||
"release_notes": "dev/release_notes_0.22.0-dev.html",
|
||||
"version": "0.22.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
'''],
|
||||
'gsutil cp ${tempDir.path}/releases.json gs://flutter_infra/releases/releases.json':
|
||||
emptyStdout,
|
||||
};
|
||||
processManager.setResults(calls);
|
||||
new ArchivePublisher('deadbeef', '1.2.3', Channel.dev,
|
||||
processManager: processManager, tempDir: tempDir)
|
||||
..publishArchive();
|
||||
processManager.verifyCalls(calls.keys);
|
||||
final File outputFile = new File(path.join(tempDir.path, 'releases.json'));
|
||||
expect(outputFile.existsSync(), isTrue);
|
||||
final String contents = outputFile.readAsStringSync();
|
||||
expect(contents, contains('"current_dev": "deadbeef"'));
|
||||
expect(contents, contains('"deadbeef": {'));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
// Copyright 2018 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:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
/// A mock that can be used to fake a process manager that runs commands
|
||||
/// and returns results.
|
||||
///
|
||||
/// Call [setResults] to provide a list of results that will return from
|
||||
/// each command line (with arguments).
|
||||
///
|
||||
/// Call [verifyCalls] to verify that each desired call occurred.
|
||||
class FakeProcessManager extends Mock implements ProcessManager {
|
||||
FakeProcessManager({this.stdinResults}) {
|
||||
_setupMock();
|
||||
}
|
||||
|
||||
/// The callback that will be called each time stdin input is supplied to
|
||||
/// a call.
|
||||
final StringReceivedCallback stdinResults;
|
||||
|
||||
/// The list of results that will be sent back, organized by the command line
|
||||
/// that will produce them. Each command line has a list of returned stdout
|
||||
/// output that will be returned on each successive call.
|
||||
Map<String, List<ProcessResult>> fakeResults = <String, List<ProcessResult>>{};
|
||||
|
||||
/// The list of invocations that occurred, in the order they occurred.
|
||||
List<Invocation> invocations = <Invocation>[];
|
||||
|
||||
/// Verify that the given command lines were called, in the given order.
|
||||
void verifyCalls(List<String> calls) {
|
||||
int index = 0;
|
||||
expect(invocations.length, equals(calls.length));
|
||||
for (String call in calls) {
|
||||
expect(call.split(' '), orderedEquals(invocations[index].positionalArguments[0]));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the list of results that will be returned from each successive call.
|
||||
void setResults(Map<String, List<String>> results) {
|
||||
final Map<String, List<ProcessResult>> resultCodeUnits = <String, List<ProcessResult>>{};
|
||||
for (String key in results.keys) {
|
||||
resultCodeUnits[key] =
|
||||
results[key].map((String result) => new ProcessResult(0, 0, result, '')).toList();
|
||||
}
|
||||
fakeResults = resultCodeUnits;
|
||||
}
|
||||
|
||||
ProcessResult _popResult(String key) {
|
||||
expect(fakeResults, isNotEmpty);
|
||||
expect(fakeResults, contains(key));
|
||||
expect(fakeResults[key], isNotEmpty);
|
||||
return fakeResults[key].removeAt(0);
|
||||
}
|
||||
|
||||
FakeProcess _popProcess(String key) =>
|
||||
new FakeProcess(_popResult(key), stdinResults: stdinResults);
|
||||
|
||||
Future<Process> _nextProcess(Invocation invocation) async {
|
||||
invocations.add(invocation);
|
||||
return new Future<Process>.value(_popProcess(invocation.positionalArguments[0].join(' ')));
|
||||
}
|
||||
|
||||
ProcessResult _nextResultSync(Invocation invocation) {
|
||||
invocations.add(invocation);
|
||||
return _popResult(invocation.positionalArguments[0].join(' '));
|
||||
}
|
||||
|
||||
Future<ProcessResult> _nextResult(Invocation invocation) async {
|
||||
invocations.add(invocation);
|
||||
return new Future<ProcessResult>.value(_popResult(invocation.positionalArguments[0].join(' ')));
|
||||
}
|
||||
|
||||
void _setupMock() {
|
||||
// Note that not all possible types of invocations are covered here, just the ones
|
||||
// expected to be called.
|
||||
// TODO(gspencer): make this more general so that any call will be captured.
|
||||
when(
|
||||
start(
|
||||
typed(captureAny),
|
||||
environment: typed(captureAny, named: 'environment'),
|
||||
workingDirectory: typed(captureAny, named: 'workingDirectory'),
|
||||
),
|
||||
).thenAnswer(_nextProcess);
|
||||
|
||||
when(
|
||||
start(
|
||||
typed(captureAny),
|
||||
),
|
||||
).thenAnswer(_nextProcess);
|
||||
|
||||
when(
|
||||
run(
|
||||
typed(captureAny),
|
||||
environment: typed(captureAny, named: 'environment'),
|
||||
workingDirectory: typed(captureAny, named: 'workingDirectory'),
|
||||
),
|
||||
).thenAnswer(_nextResult);
|
||||
|
||||
when(
|
||||
run(
|
||||
typed(captureAny),
|
||||
),
|
||||
).thenAnswer(_nextResult);
|
||||
|
||||
when(
|
||||
runSync(
|
||||
typed(captureAny),
|
||||
environment: typed(captureAny, named: 'environment'),
|
||||
workingDirectory: typed(captureAny, named: 'workingDirectory'),
|
||||
),
|
||||
).thenAnswer(_nextResultSync);
|
||||
|
||||
when(
|
||||
runSync(
|
||||
typed(captureAny),
|
||||
),
|
||||
).thenAnswer(_nextResultSync);
|
||||
|
||||
when(killPid(typed(captureAny), typed(captureAny))).thenReturn(true);
|
||||
|
||||
when(
|
||||
canRun(captureAny,
|
||||
workingDirectory: typed(
|
||||
captureAny,
|
||||
named: 'workingDirectory',
|
||||
)),
|
||||
).thenReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// A fake process that can be used to interact with a process "started" by the FakeProcessManager.
|
||||
class FakeProcess extends Mock implements Process {
|
||||
FakeProcess(ProcessResult result, {void stdinResults(String input)})
|
||||
: stdoutStream = new Stream<List<int>>.fromIterable(<List<int>>[result.stdout.codeUnits]),
|
||||
stderrStream = new Stream<List<int>>.fromIterable(<List<int>>[result.stderr.codeUnits]),
|
||||
desiredExitCode = result.exitCode,
|
||||
stdinSink = new IOSink(new StringStreamConsumer(stdinResults)) {
|
||||
_setupMock();
|
||||
}
|
||||
|
||||
final IOSink stdinSink;
|
||||
final Stream<List<int>> stdoutStream;
|
||||
final Stream<List<int>> stderrStream;
|
||||
final int desiredExitCode;
|
||||
|
||||
void _setupMock() {
|
||||
when(kill(typed(captureAny))).thenReturn(true);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> get exitCode => new Future<int>.value(desiredExitCode);
|
||||
|
||||
@override
|
||||
int get pid => 0;
|
||||
|
||||
@override
|
||||
IOSink get stdin => stdinSink;
|
||||
|
||||
@override
|
||||
Stream<List<int>> get stderr => stderrStream;
|
||||
|
||||
@override
|
||||
Stream<List<int>> get stdout => stdoutStream;
|
||||
}
|
||||
|
||||
/// Callback used to receive stdin input when it occurs.
|
||||
typedef void StringReceivedCallback(String received);
|
||||
|
||||
/// A stream consumer class that consumes UTF8 strings as lists of ints.
|
||||
class StringStreamConsumer implements StreamConsumer<List<int>> {
|
||||
StringStreamConsumer(this.sendString);
|
||||
|
||||
List<Stream<List<int>>> streams = <Stream<List<int>>>[];
|
||||
List<StreamSubscription<List<int>>> subscriptions = <StreamSubscription<List<int>>>[];
|
||||
List<Completer<dynamic>> completers = <Completer<dynamic>>[];
|
||||
|
||||
/// The callback called when this consumer receives input.
|
||||
StringReceivedCallback sendString;
|
||||
|
||||
@override
|
||||
Future<dynamic> addStream(Stream<List<int>> value) {
|
||||
streams.add(value);
|
||||
completers.add(new Completer<dynamic>());
|
||||
subscriptions.add(value.listen((List<int> data) {
|
||||
sendString(utf8.decode(data));
|
||||
}));
|
||||
subscriptions.last.onDone(() => completers.last.complete(null));
|
||||
return new Future<dynamic>.value(null);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> close() async {
|
||||
for (Completer<dynamic> completer in completers) {
|
||||
await completer.future;
|
||||
}
|
||||
completers.clear();
|
||||
streams.clear();
|
||||
subscriptions.clear();
|
||||
return new Future<dynamic>.value(null);
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
// Copyright 2018 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:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'fake_process_manager.dart';
|
||||
|
||||
void main() {
|
||||
group('ArchivePublisher', () {
|
||||
FakeProcessManager processManager;
|
||||
final List<String> stdinCaptured = <String>[];
|
||||
|
||||
void _captureStdin(String item) {
|
||||
stdinCaptured.add(item);
|
||||
}
|
||||
|
||||
setUp(() async {
|
||||
processManager = new FakeProcessManager(stdinResults: _captureStdin);
|
||||
});
|
||||
|
||||
tearDown(() async {});
|
||||
|
||||
test('start works', () async {
|
||||
final Map<String, List<String>> calls = <String, List<String>>{
|
||||
'gsutil acl get gs://flutter_infra/releases/releases.json': <String>['output1'],
|
||||
'gsutil cat gs://flutter_infra/releases/releases.json': <String>['test'],
|
||||
};
|
||||
processManager.setResults(calls);
|
||||
for (String key in calls.keys) {
|
||||
final Process process = await processManager.start(key.split(' '));
|
||||
String output = '';
|
||||
process.stdout.listen((List<int> item) {
|
||||
output += utf8.decode(item);
|
||||
});
|
||||
await process.exitCode;
|
||||
expect(output, equals(calls[key][0]));
|
||||
}
|
||||
processManager.verifyCalls(calls.keys);
|
||||
});
|
||||
|
||||
test('run works', () async {
|
||||
final Map<String, List<String>> calls = <String, List<String>>{
|
||||
'gsutil acl get gs://flutter_infra/releases/releases.json': <String>['output1'],
|
||||
'gsutil cat gs://flutter_infra/releases/releases.json': <String>['test'],
|
||||
};
|
||||
processManager.setResults(calls);
|
||||
for (String key in calls.keys) {
|
||||
final ProcessResult result = await processManager.run(key.split(' '));
|
||||
expect(result.stdout, equals(calls[key][0]));
|
||||
}
|
||||
processManager.verifyCalls(calls.keys);
|
||||
});
|
||||
|
||||
test('runSync works', () async {
|
||||
final Map<String, List<String>> calls = <String, List<String>>{
|
||||
'gsutil acl get gs://flutter_infra/releases/releases.json': <String>['output1'],
|
||||
'gsutil cat gs://flutter_infra/releases/releases.json': <String>['test'],
|
||||
};
|
||||
processManager.setResults(calls);
|
||||
for (String key in calls.keys) {
|
||||
final ProcessResult result = processManager.runSync(key.split(' '));
|
||||
expect(result.stdout, equals(calls[key][0]));
|
||||
}
|
||||
processManager.verifyCalls(calls.keys);
|
||||
});
|
||||
|
||||
test('captures stdin', () async {
|
||||
final Map<String, List<String>> calls = <String, List<String>>{
|
||||
'gsutil acl get gs://flutter_infra/releases/releases.json': <String>['output1'],
|
||||
'gsutil cat gs://flutter_infra/releases/releases.json': <String>['test'],
|
||||
};
|
||||
processManager.setResults(calls);
|
||||
for (String key in calls.keys) {
|
||||
final Process process = await processManager.start(key.split(' '));
|
||||
String output = '';
|
||||
process.stdout.listen((List<int> item) {
|
||||
output += utf8.decode(item);
|
||||
});
|
||||
final String testInput = '${calls[key][0]} input';
|
||||
process.stdin.add(testInput.codeUnits);
|
||||
await process.exitCode;
|
||||
expect(output, equals(calls[key][0]));
|
||||
expect(stdinCaptured.last, equals(testInput));
|
||||
}
|
||||
processManager.verifyCalls(calls.keys);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user