forked from Pradeepsingh61/DSA_Code
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (127 loc) Β· 4.82 KB
/
pr-validation.yml
File metadata and controls
151 lines (127 loc) Β· 4.82 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
name: π PR Validation
on:
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
jobs:
validate-pr:
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
with:
files: |
C/**
CPP/**
Java/**
Python/**
JavaScript/**
Go/**
Rust/**
Kotlin/**
Swift/**
PHP/**
Ruby/**
CSharp/**
Dart/**
Scala/**
- name: π Validate file naming conventions
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "π Checking file naming conventions..."
invalid_files=()
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Checking: $file"
# Extract filename and extension
filename=$(basename "$file")
dir=$(dirname "$file")
# Check directory structure - must contain a valid category
if [[ "$file" =~ \.(c|cpp|java|py|js|ts|go|rs|kt|swift|php|rb|cs|dart|scala)$ ]]; then
if [[ ! "$dir" =~ (algorithms|data_structures|dynamic_programming|projects) ]]; then
invalid_files+=("$file: Should be in algorithms/, data_structures/, dynamic_programming/, or projects/ subdirectory")
fi
fi
done
if [ ${#invalid_files[@]} -gt 0 ]; then
echo "β Found naming/structure violations:"
printf '%s\n' "${invalid_files[@]}"
exit 1
else
echo "β
All files follow naming conventions!"
fi
- name: π Check for required documentation
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "π Checking for documentation in code files..."
missing_docs=()
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ "$file" =~ \.(c|cpp|java|py|js|ts|go|rs|kt|swift|php|rb|cs|dart|scala)$ ]]; then
echo "Checking documentation in: $file"
# Check for basic documentation elements
if ! grep -q -i "algorithm\|description\|complexity" "$file" 2>/dev/null; then
missing_docs+=("$file: Missing algorithm description or complexity analysis")
fi
# Check for comments
if ! grep -q -E "//|#|\*|--|<!--" "$file" 2>/dev/null; then
missing_docs+=("$file: Missing comments")
fi
fi
done
if [ ${#missing_docs[@]} -gt 0 ]; then
echo "β οΈ Found documentation issues:"
printf '%s\n' "${missing_docs[@]}"
echo ""
echo "π‘ Please add:"
echo " - Algorithm description"
echo " - Time/Space complexity"
echo " - Comments explaining the code"
else
echo "β
Documentation looks good!"
fi
- name: π Check for new language directory structure
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "π Checking new language directory structures..."
# Get all language directories
new_langs=()
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
lang_dir=$(echo "$file" | cut -d'/' -f1)
# Skip known languages and non-language directories
if [[ ! "$lang_dir" =~ ^(C|CPP|Java|Python|\.github|\.git)$ ]] && [[ "$file" =~ \.(c|cpp|java|py|js|ts|go|rs|kt|swift|php|rb|cs|dart|scala)$ ]]; then
if [[ ! " ${new_langs[@]} " =~ " ${lang_dir} " ]]; then
new_langs+=("$lang_dir")
fi
fi
done
for lang in "${new_langs[@]}"; do
echo "π Checking new language: $lang"
# Check if README exists
if [[ ! -f "$lang/README.md" ]]; then
echo "β οΈ Missing $lang/README.md - Please add setup instructions for $lang"
else
echo "β
Found $lang/README.md"
fi
# Check directory structure
required_dirs=("algorithms" "data_structures" "dynamic_programming")
for req_dir in "${required_dirs[@]}"; do
if [[ ! -d "$lang/$req_dir" ]]; then
echo "βΉοΈ Consider creating $lang/$req_dir/ directory"
fi
done
done
- name: β
Validation Summary
run: |
echo "π PR Validation Complete!"
echo ""
echo "π Validation Results:"
echo "β
File naming conventions checked"
echo "β
Directory structure verified"
echo "β
Documentation requirements reviewed"
echo "β
New language support validated"
echo ""
echo "π Ready for Hacktoberfest review!"