-
Notifications
You must be signed in to change notification settings - Fork 664
CI - Do some basic checks that crates are publishable #2660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0e8a469
[bfops/check-deps]: Check for dependencies that might break publishing
bfops b5ca1ab
[bfops/check-deps]: [bfops/check-deps]: augment to check for other fi…
bfops 65dc672
[bfops/check-deps]: fix?
bfops 76325aa
[bfops/check-deps]: use shared crate
bfops e81fa6c
[bfops/check-deps]: review
bfops 0a578bd
[bfops/check-deps]: review
bfops d71a577
[bfops/check-deps]: fix?
bfops 88c68cb
[bfops/check-deps]: review
bfops 2c74d73
[bfops/check-deps]: review
bfops c9bdc0a
[bfops/check-deps]: remove license from schema
bfops 00cb434
[bfops/check-deps]: fix
bfops e2b0ab1
[bfops/check-deps]: revert
bfops d8f746f
[bfops/check-deps]: fix
bfops 11c58d4
[bfops/check-deps]: review
bfops d3eb996
[bfops/check-deps]: revert
bfops c19926e
[bfops/check-deps]: permissions
bfops 3cc4a19
[bfops/check-deps]: fix
bfops 429279b
[bfops/check-deps]: improve message
bfops 6cee1d4
[bfops/check-deps]: revert crates
bfops b1bfd96
[bfops/check-deps]: improve message
bfops e50e4ab
[bfops/check-deps]: improve message
bfops 9f6bc0a
[bfops/check-deps]: fix crates again
bfops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import toml | ||
| import argparse | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| def find_non_path_spacetimedb_deps(dev_deps): | ||
| non_path_spacetimedb = [] | ||
| for name, details in dev_deps.items(): | ||
| if not name.startswith("spacetimedb"): | ||
| continue | ||
|
|
||
| if isinstance(details, dict): | ||
| if "path" not in details: | ||
| non_path_spacetimedb.append(name) | ||
| else: | ||
| # String dependency = version from crates.io | ||
| non_path_spacetimedb.append(name) | ||
| return non_path_spacetimedb | ||
|
|
||
| def check_cargo_metadata(data): | ||
| package = data.get("package", {}) | ||
| missing_fields = [] | ||
|
|
||
| # Accept either license OR license-file | ||
| if "license" not in package and "license-file" not in package: | ||
| missing_fields.append("license/license-file") | ||
|
|
||
| if "description" not in package: | ||
| missing_fields.append("description") | ||
|
|
||
| return missing_fields | ||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description="Check Cargo.toml for metadata and dev-dependencies.") | ||
| parser.add_argument("directory", help="Directory to search for Cargo.toml") | ||
|
|
||
| args = parser.parse_args() | ||
| cargo_toml_path = Path(args.directory) / "Cargo.toml" | ||
|
|
||
| try: | ||
| if not cargo_toml_path.exists(): | ||
| raise FileNotFoundError(f"{cargo_toml_path} not found.") | ||
|
|
||
| data = toml.load(cargo_toml_path) | ||
|
|
||
| # Check dev-dependencies | ||
| dev_deps = data.get("dev-dependencies", {}) | ||
| bad_deps = find_non_path_spacetimedb_deps(dev_deps) | ||
|
|
||
| # Check license/license-file and description | ||
| missing_fields = check_cargo_metadata(data) | ||
|
|
||
| exit_code = 0 | ||
|
|
||
| if bad_deps: | ||
| print(f"❌ These dev-dependencies in {cargo_toml_path} must be converted to use `path` in order to not impede crate publishing:") | ||
| for dep in bad_deps: | ||
| print(f" - {dep}") | ||
| exit_code = 1 | ||
|
|
||
| if missing_fields: | ||
| print(f"❌ Missing required fields in [package] of {cargo_toml_path}: {', '.join(missing_fields)}") | ||
| exit_code = 1 | ||
|
|
||
| if exit_code == 0: | ||
| print(f"✅ {cargo_toml_path} passed all checks.") | ||
|
|
||
| sys.exit(exit_code) | ||
|
|
||
| except Exception as e: | ||
| print(f"⚠️ Error: {e}") | ||
| sys.exit(2) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.