Skip to content
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

Adding naming convention ci #6

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Changes from all commits
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
63 changes: 63 additions & 0 deletions .github/workflows/namingConvention.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Validate File and Folder Names

on:
pull_request:
push:
branches:
- main

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install dependencies
run: npm install

- name: Validate file and folder names
run: |
#!/bin/bash
set -e

# Function to check if a string is in camelCase
function is_camel_case {
[[ $1 =~ ^[a-z]+([A-Z][a-z0-9]+)*$ ]]
}

# Validate file and folder names
validation_failed=false
validation_results=""

for file in ./pages/*; do
if [[ $file != ./pages/_* ]]; then
if [[ -f $file ]]; then
filename=$(basename "$file")
if ! is_camel_case "${filename%.*}"; then
validation_failed=true
validation_results+="File $file name $filename is not in camelCase\n"
fi
elif [[ -d $file ]]; then
dirname=$(basename "$file")
if ! is_camel_case "$dirname"; then
validation_failed=true
validation_results+="Folder $file name $dirname is not in camelCase\n"
fi
fi
fi
done

# Print validation results
if [ "$validation_failed" = true ]; then
echo -e "Validation failed:\n$validation_results"
exit 1
else
echo "All file and folder names in ./pages (excluding those starting with '_') are in camelCase"
fi
Loading