forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Deny adding git deps (paritytech#4572)
Adds a small CI check to match the existing Git deps agains a known-bad list. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,40 @@ | ||
""" | ||
Script to deny Git dependencies in the Cargo workspace. Can be passed one optional argument for the | ||
root folder. If not provided, it will use the cwd. | ||
## Usage | ||
python3 .github/scripts/deny-git-deps.py polkadot-sdk | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
from cargo_workspace import Workspace, DependencyLocation | ||
|
||
KNOWN_BAD_GIT_DEPS = { | ||
'simple-mermaid': ['xcm-docs'], | ||
# Fix in <https://github.com/paritytech/polkadot-sdk/issues/2922> | ||
'bandersnatch_vrfs': ['sp-core'], | ||
} | ||
|
||
root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() | ||
workspace = Workspace.from_path(root) | ||
|
||
def check_dep(dep, used_by): | ||
if dep.location != DependencyLocation.GIT: | ||
return | ||
|
||
if used_by in KNOWN_BAD_GIT_DEPS.get(dep.name, []): | ||
print(f'🤨 Ignoring git dependency {dep.name} in {used_by}') | ||
else: | ||
print(f'🚫 Found git dependency {dep.name} in {used_by}') | ||
sys.exit(1) | ||
|
||
# Check the workspace dependencies that can be inherited: | ||
for dep in workspace.dependencies: | ||
check_dep(dep, "workspace") | ||
|
||
# And the dependencies of each crate: | ||
for crate in workspace.crates: | ||
for dep in crate.dependencies: | ||
check_dep(dep, crate.name) |
This file contains 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