Skip to content

feat(revision): add Day 02 - Strings (Longest Substring, Minimum Window) #524

feat(revision): add Day 02 - Strings (Longest Substring, Minimum Window)

feat(revision): add Day 02 - Strings (Longest Substring, Minimum Window) #524

Workflow file for this run

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!"