From 715fe2aad4387c3eff491b4bb983063f07749579 Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Wed, 16 Oct 2024 13:09:33 +0200 Subject: [PATCH] Update workflow names and minor update to structure check --- .../workflows/check_project_structure.yaml | 19 +++++++-------- .../workflows/check_query_identifiers.yaml | 2 +- .github/workflows/pr_ci.yaml | 2 +- .../workflows/pr_maintainer_checklist.yaml | 2 +- .../check/check_project_structure.py | 24 ++++++++++--------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/check_project_structure.yaml b/.github/workflows/check_project_structure.yaml index f3d2bbb0f..6c131e0d8 100644 --- a/.github/workflows/check_project_structure.yaml +++ b/.github/workflows/check_project_structure.yaml @@ -1,5 +1,4 @@ -name: Structure Check - +name: Check Project Structure on: push: branches: [main] @@ -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." diff --git a/.github/workflows/check_query_identifiers.yaml b/.github/workflows/check_query_identifiers.yaml index 780da47da..3a601fe60 100644 --- a/.github/workflows/check_query_identifiers.yaml +++ b/.github/workflows/check_query_identifiers.yaml @@ -1,4 +1,4 @@ -name: check_query_identifiers +name: Check Query Identifiers on: push: branches: [main] diff --git a/.github/workflows/pr_ci.yaml b/.github/workflows/pr_ci.yaml index 0f317ee6a..9946fb02e 100644 --- a/.github/workflows/pr_ci.yaml +++ b/.github/workflows/pr_ci.yaml @@ -1,4 +1,4 @@ -name: pr_ci +name: CI on: push: branches: [main] diff --git a/.github/workflows/pr_maintainer_checklist.yaml b/.github/workflows/pr_maintainer_checklist.yaml index bee8e4f41..61566ce9c 100644 --- a/.github/workflows/pr_maintainer_checklist.yaml +++ b/.github/workflows/pr_maintainer_checklist.yaml @@ -1,4 +1,4 @@ -name: pr_maintainer_checklist +name: PR Maintainer Checklist on: pull_request_target: branches: diff --git a/src/scribe_data/check/check_project_structure.py b/src/scribe_data/check/check_project_structure.py index 20d7b0543..4dcb21e32 100644 --- a/src/scribe_data/check/check_project_structure.py +++ b/src/scribe_data/check/check_project_structure.py @@ -1,6 +1,6 @@ import os -# Expected languages and data types +# Expected languages and data types. LANGUAGES = { "Arabic", "English", @@ -58,7 +58,7 @@ "verbs", } -# Sub-subdirectories expected for specific languages +# Sub-subdirectories expected for specific languages. SUB_DIRECTORIES = { "Chinese": ["Mandarin"], "Hindustani": ["Urdu", "Hindi"], @@ -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): @@ -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." )