forked from admirerr/DSA-Collection
-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (156 loc) · 6.86 KB
/
structure-validation.yml
File metadata and controls
185 lines (156 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: 📋 Repository Structure Validation
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
jobs:
validate-structure:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔍 Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
- name: 📁 Validate directory structure
run: |
echo "📁 Validating repository structure..."
structure_issues=()
# Check for language directories (C, CPP, Java, Python, etc.)
for lang_dir in */; do
lang_name="${lang_dir%/}"
# Ignore hidden directories and non-language directories
if [[ "$lang_name" =~ ^(\.github|\.git|node_modules)$ ]]; then
continue
fi
if [ -d "$lang_name" ]; then
echo "🔍 Checking language directory: $lang_name"
# Check for README.md in language directory
if [ ! -f "$lang_name/README.md" ]; then
structure_issues+=("Missing README.md in $lang_name/")
fi
# Check for topic subdirectories
topic_dirs=$(find "$lang_name" -mindepth 1 -maxdepth 1 -type d)
if [ -z "$topic_dirs" ]; then
structure_issues+=("Language directory '$lang_name' is empty or contains no topic subdirectories.")
else
echo "Found topic directories in $lang_name: $(basename -a $topic_dirs | tr '\n' ' ')"
fi
fi
done
# Report issues
if [ ${#structure_issues[@]} -gt 0 ]; then
echo "⚠️ Structure issues found:"
printf '%s\n' "${structure_issues[@]}"
# exit 1 # Optionally fail the build
else
echo "✅ Language directory structure looks good!"
fi
- name: 🏗️ Validate algorithm organization
run: |
echo "🏗️ Validating algorithm organization..."
# Check for algorithms in correct directories
misplaced_algorithms=()
# Search for common algorithm patterns
search_patterns=(
"search:searching"
"sort:sorting"
"graph:graph_algorithms"
"string:string_algorithms"
"tree:trees"
"stack:stacks"
"queue:queues"
"heap:heaps"
"link:linked_lists"
"dynamic:dynamic_programming"
)
for pattern in "${search_patterns[@]}"; do
keyword="${pattern%%:*}"
expected_dir="${pattern##*:}"
# Find files containing the keyword
files_with_keyword=($(find . -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.py" -o -name "*.js" -o -name "*.go" -o -name "*.rs" | xargs grep -l -i "$keyword" 2>/dev/null || true))
for file in "${files_with_keyword[@]}"; do
# Check if file is in expected directory
if [[ "$file" != *"/$expected_dir/"* ]] && [[ "$file" != *"$expected_dir"* ]]; then
# Skip if it's just a comment or documentation
if grep -q -i "$keyword" "$file" && ! grep -q -E "//.*$keyword|#.*$keyword|/\*.*$keyword" "$file"; then
misplaced_algorithms+=("$file: Contains '$keyword' but not in $expected_dir directory")
fi
fi
done
done
if [ ${#misplaced_algorithms[@]} -gt 0 ]; then
echo "💡 Algorithm organization suggestions:"
printf '%s\n' "${misplaced_algorithms[@]}"
else
echo "✅ Algorithm organization looks good!"
fi
- name: 📝 Check documentation completeness
run: |
echo "📝 Checking documentation completeness..."
missing_docs=()
# Check main repository documentation
required_docs=("README.md" "CONTRIBUTING.md" "HALL_OF_FAME.md")
for doc in "${required_docs[@]}"; do
if [ ! -f "$doc" ]; then
missing_docs+=("Missing main documentation: $doc")
else
echo "✅ Found $doc"
fi
done
# Check language-specific documentation
for lang_dir in */; do
lang_name="${lang_dir%/}"
# Skip hidden directories and non-language directories
if [[ "$lang_name" =~ ^\. ]] || [[ "$lang_name" =~ ^(node_modules|\.git|\.github)$ ]]; then
continue
fi
# Check for language README
if [ -d "$lang_dir" ] && [ ! -f "$lang_dir/README.md" ]; then
# Only report if directory contains code files
code_files=($(find "$lang_dir" -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.py" -o -name "*.js" -o -name "*.go" -o -name "*.rs" 2>/dev/null))
if [ ${#code_files[@]} -gt 0 ]; then
missing_docs+=("Language directory $lang_dir is missing README.md")
fi
elif [ -f "$lang_dir/README.md" ]; then
echo "✅ Found $lang_dir/README.md"
fi
done
if [ ${#missing_docs[@]} -gt 0 ]; then
echo "📝 Documentation suggestions:"
printf '%s\n' "${missing_docs[@]}"
else
echo "✅ Documentation is complete!"
fi
- name: 🎯 Generate structure report
run: |
echo "🎯 Repository Structure Report"
echo "=============================="
echo ""
echo "📊 Language Distribution:"
for dir in */; do
if [[ -d "$dir" ]] && [[ ! "$dir" =~ ^\. ]] && [[ ! "$dir" =~ ^(node_modules|\.git|\.github)$ ]]; then
lang_name="${dir%/}"
file_count=$(find "$dir" -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.py" -o -name "*.js" -o -name "*.go" -o -name "*.rs" -o -name "*.kt" -o -name "*.swift" -o -name "*.php" -o -name "*.rb" -o -name "*.cs" -o -name "*.dart" -o -name "*.scala" \) 2>/dev/null | wc -l)
echo " 📁 $lang_name: $file_count files"
fi
done
echo ""
echo "🏗️ Algorithm Categories:"
categories=("searching" "sorting" "graph_algorithms" "string_algorithms")
for category in "${categories[@]}"; do
count=$(find . -path "*/$category/*" -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.py" -o -name "*.js" -o -name "*.go" -o -name "*.rs" \) 2>/dev/null | wc -l)
echo " 🔍 $category: $count implementations"
done
echo ""
echo "🏗️ Data Structure Categories:"
ds_categories=("trees" "stacks" "queues" "graphs" "heaps" "linked_lists")
for category in "${ds_categories[@]}"; do
count=$(find . -path "*/$category/*" -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.py" -o -name "*.js" -o -name "*.go" -o -name "*.rs" \) 2>/dev/null | wc -l)
echo " 🏗️ $category: $count implementations"
done
echo ""
echo "✅ Structure validation completed!"