Skip to content

Commit

Permalink
Avoid early-abort and report all collected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Jul 11, 2023
1 parent 15cf9c4 commit 44e6513
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions ci/order-crates-for-publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,44 @@ def load_metadata():
# This script follows the same safe discarding logic to exclude these
# special-cased dev dependencies from its `dependency_graph` and further
# processing.
def is_self_dev_dep_with_dev_context_only_utils(package, dependency):
def is_self_dev_dep_with_dev_context_only_utils(package, dependency, wrong_self_dev_dependencies):
no_explicit_version = '*'

is_special_cased = False
if (dependency['kind'] == 'dev' and
dependency['name'] == package['name'] and
'dev-context-only-utils' in dependency['features'] and
'path' in dependency):
if dependency['req'] == no_explicit_version:
is_special_cased = True
else:
is_special_cased = True
if dependency['req'] != no_explicit_version:
# it's likely `{ workspace = true, ... }` is used, which implicitly pulls the
# version in...
sys.exit(
'Error: wrong dev-context-only-utils circular dependency. try: ' +
'{} = {{ path = ".", features = {} }}\n'
.format(dependency['name'], json.dumps(dependency['features']))
)
wrong_self_dev_dependencies.append(dependency)

return is_special_cased

def should_add(package, dependency):
is_related_to_solana = dependency['name'].startswith('solana')
return (
is_related_to_solana and not is_self_dev_dep_with_dev_context_only_utils(package, dependency)
def should_add(package, dependency, wrong_self_dev_dependencies):
related_to_solana = dependency['name'].startswith('solana')
self_dev_dep_with_dev_context_only_utils = is_self_dev_dep_with_dev_context_only_utils(
package, dependency, wrong_self_dev_dependencies
)

return related_to_solana and not self_dev_dep_with_dev_context_only_utils

def get_packages():
metadata = load_metadata()

manifest_path = dict()

# Build dictionary of packages and their immediate solana-only dependencies
dependency_graph = dict()
wrong_self_dev_dependencies = list()

for pkg in metadata['packages']:
manifest_path[pkg['name']] = pkg['manifest_path'];
dependency_graph[pkg['name']] = [x['name'] for x in pkg['dependencies'] if should_add(pkg, x)];
dependency_graph[pkg['name']] = [
x['name'] for x in pkg['dependencies'] if should_add(pkg, x, wrong_self_dev_dependencies)
];

# Check for direct circular dependencies
circular_dependencies = set()
Expand All @@ -94,8 +95,13 @@ def get_packages():

for dependency in circular_dependencies:
sys.stderr.write('Error: Circular dependency: {}\n'.format(dependency))
for dependency in wrong_self_dev_dependencies:
sys.stderr.write('Error: wrong dev-context-only-utils circular dependency. try: ' +
'{} = {{ path = ".", features = {} }}\n'
.format(dependency['name'], json.dumps(dependency['features']))
)

if len(circular_dependencies) != 0:
if len(circular_dependencies) != 0 or len(wrong_self_dev_dependencies) != 0:
sys.exit(1)

# Order dependencies
Expand Down

0 comments on commit 44e6513

Please sign in to comment.