From a3091366e70b37aa4c7fbe0487c66b6253acc30b Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:39:51 +0200 Subject: [PATCH 1/6] 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 From 8b6e2df8f51d6e9d860083f5a8952b8c48cfe493 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:44:14 +0200 Subject: [PATCH 2/6] Fix CI deps Signed-off-by: Oliver Tale-Yazdi --- .github/workflows/checks-quick.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks-quick.yml b/.github/workflows/checks-quick.yml index 153ad29bf257..1f4f2137de6e 100644 --- a/.github/workflows/checks-quick.yml +++ b/.github/workflows/checks-quick.yml @@ -87,7 +87,7 @@ jobs: - name: install python deps run: | sudo apt-get update && sudo apt-get install -y python3-pip python3 - pip3 install toml + pip3 install toml "cargo-workspace>=1.2.5" - name: check integrity run: > python3 .github/scripts/check-workspace.py . From c92354510caf147f089ba7cc07c68c24572a49f9 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:45:56 +0200 Subject: [PATCH 3/6] DNM test CI with bad dep Signed-off-by: Oliver Tale-Yazdi --- substrate/primitives/trie/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/primitives/trie/Cargo.toml b/substrate/primitives/trie/Cargo.toml index 45459c180d40..58c1e3dfb546 100644 --- a/substrate/primitives/trie/Cargo.toml +++ b/substrate/primitives/trie/Cargo.toml @@ -44,6 +44,7 @@ criterion = "0.5.1" trie-bench = "0.39.0" trie-standardmap = "0.16.0" sp-runtime = { path = "../runtime" } +bandersnatch_vrfs = { git = "https://github.com/w3f/ring-vrf", rev = "e9782f9", default-features = false, features = ["substrate-curves"], optional = true } [features] default = ["std"] From 780ea1373221ee0f827b4be63dd3bbcb9d3d752f Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:49:40 +0200 Subject: [PATCH 4/6] Revert "DNM test CI with bad dep" This reverts commit c92354510caf147f089ba7cc07c68c24572a49f9. --- substrate/primitives/trie/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/primitives/trie/Cargo.toml b/substrate/primitives/trie/Cargo.toml index 58c1e3dfb546..45459c180d40 100644 --- a/substrate/primitives/trie/Cargo.toml +++ b/substrate/primitives/trie/Cargo.toml @@ -44,7 +44,6 @@ criterion = "0.5.1" trie-bench = "0.39.0" trie-standardmap = "0.16.0" sp-runtime = { path = "../runtime" } -bandersnatch_vrfs = { git = "https://github.com/w3f/ring-vrf", rev = "e9782f9", default-features = false, features = ["substrate-curves"], optional = true } [features] default = ["std"] From 598b9620f674659086b64ea40b893a999b4fc371 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 20:50:47 +0200 Subject: [PATCH 5/6] Shorten Signed-off-by: Oliver Tale-Yazdi --- .github/scripts/deny-git-deps.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/scripts/deny-git-deps.py b/.github/scripts/deny-git-deps.py index e2ac2e3bc8ae..fb80dfeb63b4 100644 --- a/.github/scripts/deny-git-deps.py +++ b/.github/scripts/deny-git-deps.py @@ -1,11 +1,11 @@ """ -Script to deny Git dependencies in the Cargo workspace. +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 argparse import os import sys @@ -18,9 +18,8 @@ } root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() -workspace = Workspace.from_path(root) -for crate in workspace.crates: +for crate in Workspace.from_path(root).crates: for dep in crate.dependencies: if dep.location != DependencyLocation.GIT: continue From 8fadc214a64ac24ca55fd1350ef527e5165f93f2 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 24 May 2024 22:45:00 +0200 Subject: [PATCH 6/6] Also check workspace deps Signed-off-by: Oliver Tale-Yazdi --- .github/scripts/deny-git-deps.py | 27 ++++++++++++++++++--------- .github/workflows/checks-quick.yml | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/scripts/deny-git-deps.py b/.github/scripts/deny-git-deps.py index fb80dfeb63b4..4b831c9347f7 100644 --- a/.github/scripts/deny-git-deps.py +++ b/.github/scripts/deny-git-deps.py @@ -18,14 +18,23 @@ } root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() +workspace = Workspace.from_path(root) -for crate in Workspace.from_path(root).crates: +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: - 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) + check_dep(dep, crate.name) diff --git a/.github/workflows/checks-quick.yml b/.github/workflows/checks-quick.yml index 1f4f2137de6e..cd9baf0d1bc2 100644 --- a/.github/workflows/checks-quick.yml +++ b/.github/workflows/checks-quick.yml @@ -87,7 +87,7 @@ jobs: - name: install python deps run: | sudo apt-get update && sudo apt-get install -y python3-pip python3 - pip3 install toml "cargo-workspace>=1.2.5" + pip3 install toml "cargo-workspace>=1.2.6" - name: check integrity run: > python3 .github/scripts/check-workspace.py .