Skip to content

Commit b2e37c6

Browse files
author
Casey Hillers
authored
[conductor] Tag engine versions (#120419)
* [conductor] Tag engine versions * Move tag to repository
1 parent 25c2c22 commit b2e37c6

File tree

3 files changed

+76
-27
lines changed

3 files changed

+76
-27
lines changed

dev/conductor/core/lib/src/next.dart

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,33 @@ class NextContext extends Context {
264264
case pb.ReleasePhase.PUBLISH_VERSION:
265265
stdio.printStatus('Please ensure that you have merged your framework PR and that');
266266
stdio.printStatus('post-submit CI has finished successfully.\n');
267-
final Remote upstream = Remote(
267+
final Remote frameworkUpstream = Remote(
268268
name: RemoteName.upstream,
269269
url: state.framework.upstream.url,
270270
);
271271
final FrameworkRepository framework = FrameworkRepository(
272272
checkouts,
273273
// We explicitly want to check out the merged version from upstream
274-
initialRef: '${upstream.name}/${state.framework.candidateBranch}',
275-
upstreamRemote: upstream,
274+
initialRef: '${frameworkUpstream.name}/${state.framework.candidateBranch}',
275+
upstreamRemote: frameworkUpstream,
276276
previousCheckoutLocation: state.framework.checkoutPath,
277277
);
278-
final String headRevision = await framework.reverseParse('HEAD');
278+
final String frameworkHead = await framework.reverseParse('HEAD');
279+
final Remote engineUpstream = Remote(
280+
name: RemoteName.upstream,
281+
url: state.engine.upstream.url,
282+
);
283+
final EngineRepository engine = EngineRepository(
284+
checkouts,
285+
// We explicitly want to check out the merged version from upstream
286+
initialRef: '${engineUpstream.name}/${state.engine.candidateBranch}',
287+
upstreamRemote: engineUpstream,
288+
previousCheckoutLocation: state.engine.checkoutPath,
289+
);
290+
final String engineHead = await engine.reverseParse('HEAD');
279291
if (autoAccept == false) {
280292
final bool response = await prompt(
281-
'Are you ready to tag commit $headRevision as ${state.releaseVersion}\n'
293+
'Are you ready to tag commit $frameworkHead as ${state.releaseVersion}\n'
282294
'and push to remote ${state.framework.upstream.url}?',
283295
);
284296
if (!response) {
@@ -287,7 +299,8 @@ class NextContext extends Context {
287299
return;
288300
}
289301
}
290-
await framework.tag(headRevision, state.releaseVersion, upstream.name);
302+
await framework.tag(frameworkHead, state.releaseVersion, frameworkUpstream.name);
303+
await engine.tag(engineHead, state.releaseVersion, engineUpstream.name);
291304
break;
292305
case pb.ReleasePhase.PUBLISH_CHANNEL:
293306
final Remote upstream = Remote(

dev/conductor/core/lib/src/repository.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,27 @@ abstract class Repository {
319319
);
320320
}
321321

322+
/// Tag [commit] and push the tag to the remote.
323+
Future<void> tag(String commit, String tagName, String remote) async {
324+
assert(commit.isNotEmpty);
325+
assert(tagName.isNotEmpty);
326+
assert(remote.isNotEmpty);
327+
stdio.printStatus('About to tag commit $commit as $tagName...');
328+
await git.run(
329+
<String>['tag', tagName, commit],
330+
'tag the commit with the version label',
331+
workingDirectory: (await checkoutDirectory).path,
332+
);
333+
stdio.printStatus('Tagging successful.');
334+
stdio.printStatus('About to push $tagName to remote $remote...');
335+
await git.run(
336+
<String>['push', remote, tagName],
337+
'publish the tag to the repo',
338+
workingDirectory: (await checkoutDirectory).path,
339+
);
340+
stdio.printStatus('Tag push successful.');
341+
}
342+
322343
/// List commits in reverse chronological order.
323344
Future<List<String>> revList(List<String> args) async {
324345
return (await git.getOutput(<String>['rev-list', ...args],
@@ -592,27 +613,6 @@ class FrameworkRepository extends Repository {
592613
);
593614
}
594615

595-
/// Tag [commit] and push the tag to the remote.
596-
Future<void> tag(String commit, String tagName, String remote) async {
597-
assert(commit.isNotEmpty);
598-
assert(tagName.isNotEmpty);
599-
assert(remote.isNotEmpty);
600-
stdio.printStatus('About to tag commit $commit as $tagName...');
601-
await git.run(
602-
<String>['tag', tagName, commit],
603-
'tag the commit with the version label',
604-
workingDirectory: (await checkoutDirectory).path,
605-
);
606-
stdio.printStatus('Tagging successful.');
607-
stdio.printStatus('About to push $tagName to remote $remote...');
608-
await git.run(
609-
<String>['push', remote, tagName],
610-
'publish the tag to the repo',
611-
workingDirectory: (await checkoutDirectory).path,
612-
);
613-
stdio.printStatus('Tag push successful.');
614-
}
615-
616616
@override
617617
Future<FrameworkRepository> cloneRepository(String? cloneName) async {
618618
assert(localUpstream);

dev/conductor/core/test/next_test.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ void main() {
758758
candidateBranch: candidateBranch,
759759
upstream: pb.Remote(url: FrameworkRepository.defaultUpstream),
760760
),
761+
engine: pb.Repository(
762+
candidateBranch: candidateBranch,
763+
upstream: pb.Remote(url: EngineRepository.defaultUpstream),
764+
),
761765
releaseVersion: releaseVersion,
762766
);
763767
platform = FakePlatform(
@@ -773,6 +777,18 @@ void main() {
773777
stdio.stdin.add('n');
774778
final FakeProcessManager processManager = FakeProcessManager.list(
775779
<FakeCommand>[
780+
// Framework checkout
781+
const FakeCommand(
782+
command: <String>['git', 'fetch', 'upstream'],
783+
),
784+
const FakeCommand(
785+
command: <String>['git', 'checkout', '$remoteName/$candidateBranch'],
786+
),
787+
const FakeCommand(
788+
command: <String>['git', 'rev-parse', 'HEAD'],
789+
stdout: revision1,
790+
),
791+
// Engine checkout
776792
const FakeCommand(
777793
command: <String>['git', 'fetch', 'upstream'],
778794
),
@@ -818,6 +834,7 @@ void main() {
818834
test('updates state.currentPhase if user responds yes', () async {
819835
stdio.stdin.add('y');
820836
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
837+
// Framework checkout
821838
const FakeCommand(
822839
command: <String>['git', 'fetch', 'upstream'],
823840
),
@@ -828,12 +845,31 @@ void main() {
828845
command: <String>['git', 'rev-parse', 'HEAD'],
829846
stdout: revision1,
830847
),
848+
// Engine checkout
849+
const FakeCommand(
850+
command: <String>['git', 'fetch', 'upstream'],
851+
),
852+
const FakeCommand(
853+
command: <String>['git', 'checkout', '$remoteName/$candidateBranch'],
854+
),
855+
const FakeCommand(
856+
command: <String>['git', 'rev-parse', 'HEAD'],
857+
stdout: revision2,
858+
),
859+
// Framework tag
831860
const FakeCommand(
832861
command: <String>['git', 'tag', releaseVersion, revision1],
833862
),
834863
const FakeCommand(
835864
command: <String>['git', 'push', remoteName, releaseVersion],
836865
),
866+
// Engine tag
867+
const FakeCommand(
868+
command: <String>['git', 'tag', releaseVersion, revision2],
869+
),
870+
const FakeCommand(
871+
command: <String>['git', 'push', remoteName, releaseVersion],
872+
),
837873
]);
838874
final FakePlatform platform = FakePlatform(
839875
environment: <String, String>{

0 commit comments

Comments
 (0)