Skip to content

Commit

Permalink
Fix(CI): Fix run tests flow
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-dotan-starkware committed Jul 9, 2024
1 parent d59f333 commit dc47656
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 0 additions & 2 deletions crates/papyrus_storage/src/bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ This tool allows you to dump the entire `declared_classes` table from Papyrus st
```

The default value for file_path is `dump_declared_classes.json`.


39 changes: 27 additions & 12 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/env python3
from ast import arg

import argparse
import re
import subprocess
import os
Expand Down Expand Up @@ -59,21 +60,35 @@ def get_package_dependencies(package_name: str) -> Set[str]:
return deps


def run_test():
def run_test(changes_only: bool):
local_changes = get_local_changes(".")
modified_packages = get_modified_packages(local_changes)
for p in modified_packages:
deps = get_package_dependencies(p)
print(f"Running tests for {deps}")
args = []
for d in deps:
args.extend(["--package", d])
args = []
if changes_only:
for p in modified_packages:
deps = get_package_dependencies(p)
print(f"Running tests for {deps}")
for d in deps:
args.extend(["--package", d])
if len(args) == 0:
print("No changes detected.")
return
cmd = ["cargo", "test"] + args
print("Running tests...")
print(cmd)
subprocess.run(cmd)
print("Tests complete.")

def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Presubmit script.")
parser.add_argument("--changes_only", action="store_true")
return parser.parse_args()


def main():
args = parse_args()
run_test(changes_only=args.changes_only)


if __name__ == "__main__":
print("Running tests...")
run_test()
# Run tests here
print("Tests complete.")
main()

0 comments on commit dc47656

Please sign in to comment.