diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c29c0b7b3..b07165ea9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/scripts/run_orphan_test.py b/scripts/run_orphan_test.py new file mode 100755 index 000000000..aefa81c9c --- /dev/null +++ b/scripts/run_orphan_test.py @@ -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()