Skip to content

Commit

Permalink
feat(ci): add orphans check with cargo-modules
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <[email protected]>
  • Loading branch information
dorimedini-starkware committed Sep 22, 2024
1 parent 602ec6f commit c2a2e55
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ jobs:
- name: Run Machete (detect unused dependencies)
uses: bnjbvr/cargo-machete@main

cargo-modules:
runs-on: starkware-ubuntu-20-04-medium
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install_rust
with:
components: cargo-modules
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-ubuntu-20.04"
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_orphan_test.py
run-workspace-tests:
runs-on: starkware-ubuntu-latest-small
Expand Down
20 changes: 20 additions & 0 deletions scripts/run_orphan_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess
from tests_utils import get_workspace_tree


def verify_no_orphans():
crates = get_workspace_tree()
for crate in crates:
print(f"Checking for orphans in {crate}...")
command = f"cargo modules orphans --all-features --cfg-test --package {crate}"
try:
subprocess.check_output(args=command, shell=True).decode("utf-8")
except subprocess.CalledProcessError:
print(
"ERROR, possibly due to both binary and library in crate. Analyzing only library..."
)
subprocess.check_output(args=command + " --lib", shell=True).decode("utf-8")


if __name__ == "__main__":
verify_no_orphans()

0 comments on commit c2a2e55

Please sign in to comment.