Skip to content

Commit

Permalink
Update workflow names and minor update to structure check
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Oct 16, 2024
1 parent b0999f6 commit 715fe2a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/check_project_structure.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Structure Check

name: Check Project Structure
on:
push:
branches: [main]
Expand All @@ -12,13 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Run check_project_structure.py
working-directory: ./src/scribe_data/check
run: python check_project_structure.py
- name: Run check_project_structure.py
working-directory: ./src/scribe_data/check
run: python check_project_structure.py

- name: Post-run status
if: failure()
run: echo "Check failed. Please fix the errors."
- name: Post-run status
if: failure()
run: echo "Project structure check failed. Please fix the reported errors."
2 changes: 1 addition & 1 deletion .github/workflows/check_query_identifiers.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: check_query_identifiers
name: Check Query Identifiers
on:
push:
branches: [main]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pr_ci
name: CI
on:
push:
branches: [main]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_maintainer_checklist.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pr_maintainer_checklist
name: PR Maintainer Checklist
on:
pull_request_target:
branches:
Expand Down
24 changes: 13 additions & 11 deletions src/scribe_data/check/check_project_structure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

# Expected languages and data types
# Expected languages and data types.
LANGUAGES = {
"Arabic",
"English",
Expand Down Expand Up @@ -58,7 +58,7 @@
"verbs",
}

# Sub-subdirectories expected for specific languages
# Sub-subdirectories expected for specific languages.
SUB_DIRECTORIES = {
"Chinese": ["Mandarin"],
"Hindustani": ["Urdu", "Hindi"],
Expand All @@ -68,12 +68,13 @@
}


# Base directory path
# Base directory path.
BASE_DIR = "../language_data_extraction"


def validate_project_structure():
"""Validate that all directories follow the expected project structure and check for unexpected files and directories."""
"""
Validate that all directories follow the expected project structure and check for unexpected files and directories."""
errors = []

if not os.path.exists(BASE_DIR):
Expand Down Expand Up @@ -134,25 +135,26 @@ def validate_project_structure():
errors.append(
f"Unexpected file found in {language}/{subdir}: {item}"
)

elif os.path.isdir(item_path) and item not in DATA_TYPES:
errors.append(
f"Unexpected directory found in {language}/{subdir}: {item}"
)
else:
unexpected_data_types = found_subdirs - DATA_TYPES
if unexpected_data_types:
errors.append(
f"Unexpected subdirectories in '{language}': {unexpected_data_types}"
)

elif unexpected_data_types := found_subdirs - DATA_TYPES:
errors.append(
f"Unexpected subdirectories in '{language}': {unexpected_data_types}"
)

if errors:
print("Errors found:")
for error in errors:
print(f" - {error}")
exit(1)

else:
print(
"All directories are correctly named and organized, and no unexpected files or directories were found."
"All directories and files are correctly named and organized, and no unexpected files or directories were found."
)


Expand Down

0 comments on commit 715fe2a

Please sign in to comment.