Kadaneβs Algorithm (C++) with Description and Complexity #36
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 for proper naming conventions (Allow snake_case, camelCase, or PascalCase) | |
| case "$file" in | |
| *.c|*.cpp|*.py) | |
| # Allow snake_case, camelCase, or PascalCase for C/C++/Python | |
| if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then | |
| invalid_files+=("$file: Use alphanumeric characters and underscores only (e.g., binary_search.cpp, maxRectangle.cpp)") | |
| fi | |
| ;; | |
| *.java) | |
| # Should use PascalCase for Java classes | |
| if [[ ! "$filename" =~ ^[A-Z][a-zA-Z0-9]*\.java$ ]]; then | |
| invalid_files+=("$file: Java files should use PascalCase (e.g., BinarySearch.java, MaxRectangle.java)") | |
| fi | |
| ;; | |
| *.js|*.ts|*.go|*.rs|*.kt|*.swift|*.php|*.rb|*.cs|*.dart|*.scala) | |
| # Allow flexible naming for other languages | |
| if [[ ! "$filename" =~ ^[a-zA-Z0-9_]+\.[a-z]+$ ]]; then | |
| invalid_files+=("$file: Use alphanumeric characters and underscores only") | |
| fi | |
| ;; | |
| esac | |
| # Check directory structure | |
| 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!" |