From a3091366e70b37aa4c7fbe0487c66b6253acc30b Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:39:51 +0200 Subject: [PATCH] Deny git dependencies Signed-off-by: Oliver Tale-Yazdi --- .github/scripts/deny-git-deps.py | 32 ++++++++++++++++++++++++++++++ .github/workflows/checks-quick.yml | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 .github/scripts/deny-git-deps.py diff --git a/.github/scripts/deny-git-deps.py b/.github/scripts/deny-git-deps.py new file mode 100644 index 000000000000..e2ac2e3bc8ae --- /dev/null +++ b/.github/scripts/deny-git-deps.py @@ -0,0 +1,32 @@ +""" +Script to deny Git dependencies in the Cargo workspace. + +## Usage + python3 .github/scripts/deny-git-deps.py polkadot-sdk +""" + +import argparse +import os +import sys + +from cargo_workspace import Workspace, DependencyLocation + +KNOWN_BAD_GIT_DEPS = { + 'simple-mermaid': ['xcm-docs'], + # Fix in + 'bandersnatch_vrfs': ['sp-core'], +} + +root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() +workspace = Workspace.from_path(root) + +for crate in workspace.crates: + for dep in crate.dependencies: + if dep.location != DependencyLocation.GIT: + continue + + if crate.name in KNOWN_BAD_GIT_DEPS.get(dep.name, []): + print(f'🤨 Ignoring bad git dependency {dep.name} of {crate.name}') + else: + print(f'🚫 Found git dependency {dep.name} of {crate.name}') + sys.exit(1) diff --git a/.github/workflows/checks-quick.yml b/.github/workflows/checks-quick.yml index 3888928311a2..153ad29bf257 100644 --- a/.github/workflows/checks-quick.yml +++ b/.github/workflows/checks-quick.yml @@ -94,6 +94,8 @@ jobs: --exclude "substrate/frame/contracts/fixtures/build" "substrate/frame/contracts/fixtures/contracts/common" + - name: deny git deps + run: python3 .github/scripts/deny-git-deps.py . check-markdown: runs-on: ubuntu-latest timeout-minutes: 10