diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index c5f512fb..5d3681b1 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.5.5 +# Created with package:mono_repo v6.5.6 name: Dart CI on: push: diff --git a/mono_repo/CHANGELOG.md b/mono_repo/CHANGELOG.md index da5e3c4f..cb254769 100644 --- a/mono_repo/CHANGELOG.md +++ b/mono_repo/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.5.6 + +- Restore the previous ordering behavior for jobs by using a secondary sort + based on the insertion order (this matches the listed configuration order). + ## 6.5.5 - Add the pub package topics `tool` and `repository-management`. diff --git a/mono_repo/lib/src/ci_shared.dart b/mono_repo/lib/src/ci_shared.dart index 6366368d..968d70c6 100644 --- a/mono_repo/lib/src/ci_shared.dart +++ b/mono_repo/lib/src/ci_shared.dart @@ -246,28 +246,38 @@ List calculateOrderedStages( ); } - // Running strongly connected components lets us detect cycles (which aren't - // allowed), and gives us the reverse order of what we ultimately want. - final components = stronglyConnectedComponents(edges.keys, (n) => edges[n]!); - for (var component in components) { - if (component.length > 1) { - final items = component.map((e) => '`$e`').join(', '); - throw UserException( - 'Not all packages agree on `stages` ordering, found ' - 'a cycle between the following stages: $items.', - ); - } + final List components; + try { + // Build up a map of the keys to their index in `edges.keys`, which we use + // as a secondary sort. This is an intuitive secondary sort order as it + // follows the order given in configuration files. + final keys = edges.keys.toList(); + final edgeIndexes = { + for (var i = 0; i < keys.length; i++) keys[i]: i, + }; + + // Orders by dependencies first, and detect cycles (which aren't allowed). + // Our edges here are actually reverse edges already, so a topological sort + // gives us the right thing. + components = topologicalSort( + keys, + (n) => edges[n]!, + secondarySort: (a, b) => edgeIndexes[b]!.compareTo(edgeIndexes[a]!), + ); + } on CycleException catch (e) { + final items = e.cycle.map((e) => '`$e`').join(', '); + throw UserException( + 'Not all packages agree on `stages` ordering, found ' + 'a cycle between the following stages: $items.', + ); } - final orderedStages = - components.map((c) => c.first).toList().reversed.toList(); - if (rootConfig.monoConfig.selfValidateStage != null && - !orderedStages.contains(rootConfig.monoConfig.selfValidateStage)) { - orderedStages.insert(0, rootConfig.monoConfig.selfValidateStage!); + !components.contains(rootConfig.monoConfig.selfValidateStage)) { + components.insert(0, rootConfig.monoConfig.selfValidateStage!); } - return orderedStages; + return components; } List _travisTasks(Iterable configs) => diff --git a/mono_repo/lib/src/version.dart b/mono_repo/lib/src/version.dart index 7033cdb3..9050f6d6 100644 --- a/mono_repo/lib/src/version.dart +++ b/mono_repo/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '6.5.5'; +const packageVersion = '6.5.6'; diff --git a/mono_repo/pubspec.yaml b/mono_repo/pubspec.yaml index 77064e7e..b658a3ba 100644 --- a/mono_repo/pubspec.yaml +++ b/mono_repo/pubspec.yaml @@ -2,7 +2,7 @@ name: mono_repo description: >- CLI tools to make it easier to manage a single source repository containing multiple Dart packages. -version: 6.5.5 +version: 6.5.6 repository: https://github.com/google/mono_repo.dart topics: - tool @@ -15,7 +15,7 @@ dependencies: args: ^2.0.0 checked_yaml: ^2.0.0 collection: ^1.14.3 - graphs: ^2.0.0 + graphs: ^2.2.0 io: ^1.0.0 json_annotation: ^4.8.0 meta: ^1.0.0 diff --git a/tool/ci.sh b/tool/ci.sh index 29b9e436..0c226d03 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Created with package:mono_repo v6.5.5 +# Created with package:mono_repo v6.5.6 # Support built in commands on windows out of the box. # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")