Skip to content

chore: monitor structure of the project #6291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/project_structure.yml
Original file line number Diff line number Diff line change
@@ -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
...
27 changes: 27 additions & 0 deletions check_structure.py
Original file line number Diff line number Diff line change
@@ -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)
Loading