Skip to content

Commit

Permalink
Ignore .saturn dir for registering-* examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Jul 15, 2024
1 parent f920f3c commit 8be6c2f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions .ci/validate-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
EXAMPLES_DIR = ARGS.examples_dir
SKIP_IMAGE_CHECK = ARGS.skip_image_check

EXCLUDE_SATURN_DIR_CHECK = ["registering-images", "registering-users"]

# This points to a json file in the saturncloud/recipe repo.
# The BASE_URL is there just to ensure the URL fits on one line and doesn't break the link validator
with open("RECIPE_SCHEMA_VERSION", "r") as f:
Expand Down Expand Up @@ -376,23 +378,26 @@ def _lint_python_cell(file_name: str, code_lines: List[str]) -> List[str]:
msg = f"Every example must have a README.md. '{full_dir}' does not."
ERRORS.add(msg)

ignore_saturn_dir = example_dir in EXCLUDE_SATURN_DIR_CHECK
# each example must have a .saturn/ folder
saturn_dir = os.path.join(full_dir, SATURN_DIR_NAME)
if not os.path.isdir(saturn_dir):
if not ignore_saturn_dir and not os.path.isdir(saturn_dir):
msg = f"'{full_dir}' does not include a '{SATURN_DIR_NAME}/' directory"
ERRORS.add(msg)

saturn_json = os.path.join(saturn_dir, SATURN_JSON_NAME)
if not os.path.isfile(saturn_json):
msg = f"Did not find saturn.json in '{saturn_dir}'. This file is required."
ERRORS.add(msg)
continue

try:
validate_recipe(schema, instance_type_options, saturn_json, example_dir)
except ValidationError as e:
msg = f"'{saturn_json}' has the following schema issues: {str(e)}"
ERRORS.add(msg)
continue
has_saturn_json = os.path.isfile(saturn_json)
if not has_saturn_json:
if not ignore_saturn_dir:
msg = f"Did not find saturn.json in '{saturn_dir}'. This file is required."
ERRORS.add(msg)
continue
else:
try:
validate_recipe(schema, instance_type_options, saturn_json, example_dir)
except ValidationError as e:
msg = f"'{saturn_json}' has the following schema issues: {str(e)}"
ERRORS.add(msg)
continue

ERRORS.report()

0 comments on commit 8be6c2f

Please sign in to comment.