From 8c09f75c6f9b5d4c59b24441f87849bccf5f7ff8 Mon Sep 17 00:00:00 2001 From: vil02 <65706193+vil02@users.noreply.github.com> Date: Wed, 11 Jun 2025 23:48:27 +0200 Subject: [PATCH 1/2] chore: monitor structure of the project --- .github/workflows/project_structure.yml | 22 ++++++++++++++++++++ check_structure.py | 27 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/project_structure.yml create mode 100644 check_structure.py diff --git a/.github/workflows/project_structure.yml b/.github/workflows/project_structure.yml new file mode 100644 index 000000000000..da14682615b8 --- /dev/null +++ b/.github/workflows/project_structure.yml @@ -0,0 +1,22 @@ +--- +name: ProjectStructure + +'on': + workflow_dispatch: + push: + branches: + - master + pull_request: + +jobs: + check_structure: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Check project structure + run: python3 check_structure.py +... diff --git a/check_structure.py b/check_structure.py new file mode 100644 index 000000000000..914f64369207 --- /dev/null +++ b/check_structure.py @@ -0,0 +1,27 @@ +import pathlib +import sys + + +def _is_java_file_properly_located(java_file: pathlib.Path) -> bool: + main_parents = java_file.parent.parents + return ( + pathlib.Path("src/main/java/com/thealgorithms/") in main_parents + or pathlib.Path("src/test/java/com/thealgorithms/") in main_parents + ) + + +def _find_misplaced_java_files() -> list[pathlib.Path]: + return [ + java_file + for java_file in pathlib.Path(".").rglob("*.java") + if not _is_java_file_properly_located(java_file) + ] + + +if __name__ == "__main__": + misplaced_files = _find_misplaced_java_files() + if misplaced_files: + print("The following java files are not located in the correct directory:") + for _ in misplaced_files: + print(_) + sys.exit(1) From 41cd3d4c2a407333c8577e9348e7820f2b52071e Mon Sep 17 00:00:00 2001 From: vil02 <65706193+vil02@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:05:32 +0200 Subject: [PATCH 2/2] style: do not clutter the root directory --- .github/workflows/project_structure.yml | 2 +- .../workflows/scripts/check_structure.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename check_structure.py => .github/workflows/scripts/check_structure.py (100%) diff --git a/.github/workflows/project_structure.yml b/.github/workflows/project_structure.yml index da14682615b8..def01554a4f8 100644 --- a/.github/workflows/project_structure.yml +++ b/.github/workflows/project_structure.yml @@ -18,5 +18,5 @@ jobs: python-version: '3.13' - name: Check project structure - run: python3 check_structure.py + run: python3 .github/workflows/scripts/check_structure.py ... diff --git a/check_structure.py b/.github/workflows/scripts/check_structure.py similarity index 100% rename from check_structure.py rename to .github/workflows/scripts/check_structure.py