Skip to content

Commit

Permalink
faster "wrong dir" checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Nov 18, 2024
1 parent 735ae68 commit 7bc6db1
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .ci_support/build_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import re
import os
from collections import OrderedDict
from pathlib import Path
import sys
import subprocess
import yaml
Expand Down Expand Up @@ -252,7 +253,7 @@ def build_folders_rattler_build(
):
config = get_config(arch, channel_urls)

# Remove the example recipes to ensure that they are not also build.
# Remove the example recipes to ensure that they are not also built.
for example_recipe in EXAMPLE_RECIPE_FOLDERS:
rmtree(os.path.join(recipes_dir, example_recipe), ignore_errors=True)

Expand Down Expand Up @@ -292,16 +293,23 @@ def build_folders_rattler_build(


def check_recipes_in_correct_dir(root_dir, correct_dir):
from pathlib import Path
for path in Path(root_dir).rglob('meta.yaml'):
path = path.absolute().relative_to(root_dir)
if path.parts[0] in ('.pixi', 'build_artifacts', 'miniforge3'):
for path in Path(root_dir).glob("*"):
path = Path(path)
if path.is_dir() and path.name.lower() in ('.pixi', 'build_artifacts', 'miniforge3'):
# ignore pkg_cache in build_artifacts
continue
if path.parts[0] != correct_dir and path.parts[0] != "broken-recipes":
raise RuntimeError(f"recipe {path.parts} in wrong directory")
if len(path.parts) != 3:
raise RuntimeError(f"recipe {path.parts} in wrong directory")
for recipe_path in path.rglob('*.yaml'):
if recipe_path.name not in ("meta.yaml", "recipe.yaml"):
continue
recipe_path = recipe_path.absolute().relative_to(root_dir)
if (
(recipe_path.parts[0] != correct_dir and recipe_path.parts[0] != "broken-recipes")
or len(recipe_path.parts) != 3
):
raise RuntimeError(
f"recipe {recipe_path} in wrong directory; "
f"must be under {correct_dir}/<name>/"
)


def read_mambabuild(recipes_dir):
Expand Down Expand Up @@ -333,8 +341,11 @@ def use_mambabuild():

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--arch', default='64',
help='target architecture (64 or 32)')
parser.add_argument(
'--arch',
default='64',
help='target architecture (second component of a subdir; e.g. 64, arm64, ppc64le)'
)
args = parser.parse_args()
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
check_recipes_in_correct_dir(root_dir, "recipes")
Expand Down

0 comments on commit 7bc6db1

Please sign in to comment.