Walks through all sample directories Returns: A list of directories
(dir: Path, search_for_changed_files: bool)
| 34 | |
| 35 | |
| 36 | def walk_through_owlbot_dirs(dir: Path, search_for_changed_files: bool) -> list[str]: |
| 37 | """ |
| 38 | Walks through all sample directories |
| 39 | Returns: |
| 40 | A list of directories |
| 41 | """ |
| 42 | owlbot_dirs: list[str] = [] |
| 43 | packages_to_exclude = _EXCLUDED_DIRS |
| 44 | if search_for_changed_files: |
| 45 | try: |
| 46 | # Need to run this step first in the post processor since we only clone |
| 47 | # the branch the PR is on in the Docker container |
| 48 | output = subprocess.run( |
| 49 | ["git", "fetch", "origin", "main:main", "--deepen=200"], check=False |
| 50 | ) |
| 51 | output.check_returncode() |
| 52 | except subprocess.CalledProcessError as error: |
| 53 | if error.returncode == 128: |
| 54 | logger.info(f"Error: ${error.output}; skipping fetching main") |
| 55 | else: |
| 56 | raise error |
| 57 | for path_object in dir.glob("**/package.json"): |
| 58 | object_dir = str(Path(path_object).parents[0]) |
| 59 | if ( |
| 60 | path_object.is_file() |
| 61 | and object_dir != str(dir) |
| 62 | and not re.search( |
| 63 | "(?:% s)" % "|".join(packages_to_exclude), str(Path(path_object)) |
| 64 | ) |
| 65 | ): |
| 66 | if search_for_changed_files: |
| 67 | if ( |
| 68 | subprocess.run( |
| 69 | ["git", "diff", "--quiet", "main...", object_dir], check=False |
| 70 | ).returncode |
| 71 | == 1 |
| 72 | ): |
| 73 | owlbot_dirs.append(object_dir) |
| 74 | else: |
| 75 | owlbot_dirs.append(object_dir) |
| 76 | for path_object in dir.glob("owl-bot-staging/*"): |
| 77 | owlbot_dirs.append( |
| 78 | f"{Path(path_object).parents[1]}/packages/{Path(path_object).name}" |
| 79 | ) |
| 80 | return owlbot_dirs |
| 81 | |
| 82 | |
| 83 | def typeless_samples_hermetic(targets: str, hide_output: bool = False) -> list[str]: |