feat: enhance CloudService models with improved handling #60
This file contains 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: "[Pull Request] Code Warning" | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths-ignore: | |
- '.github/**' | |
- '**/deploy/**' | |
- '**/Dockerfile' | |
- '**/*.dockerfile' | |
- '**/*.dockerignore' | |
- '**/LICENSE' | |
- '**/AUTHORS' | |
- '**/.husky/**' | |
- '**/commitlint.config.js' | |
- '**/.lintstagedrc.js' | |
- '**/*.md' | |
- '**/*.env' | |
branches: | |
- master | |
- feature-* | |
workflow_dispatch: | |
jobs: | |
review: | |
runs-on: ubuntu-latest | |
env: | |
NODE_ENV: 'development' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# checkout only the files we need | |
sparse-checkout: | | |
apps | |
packages | |
# fetch all history so we can check diff between PR and base branch | |
fetch-depth: 0 | |
- name: Copy changed files to specific directory | |
run: | | |
mkdir -p changed_files | |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 | |
git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }} | while read file; do | |
if [ -f "$file" ]; then | |
rsync -R "$file" changed_files/ | |
else | |
echo "Skipping missing file: $file" | |
fi | |
done | |
- name: Display changed files | |
run: | | |
echo "Changed files copied to 'changed_files' directory:" | |
find changed_files -type f | |
- name: Check for TODOs | |
id: check_todo | |
working-directory: changed_files | |
run: | | |
echo "Checking for TODOs..." | |
TODO_FILES=$(grep -rl "// TODO" . --exclude-dir=.git --exclude=apps/web/public/lottie.js || true) | |
TODO_COUNT=0 | |
if [ -n "$TODO_FILES" ]; then | |
echo "The following files contain TODO:" | |
echo "$TODO_FILES" | |
TODO_COUNT=$(echo "$TODO_FILES" | wc -l) | |
echo "::warning:: Found $TODO_COUNT file(s) with TODO." | |
else | |
echo "No TODOs found." | |
fi | |
echo "todo_count=$TODO_COUNT" >> $GITHUB_ENV | |
- name: Check for console.log | |
id: check_console_log | |
working-directory: changed_files | |
run: | | |
echo "Checking for console.log..." | |
LOG_FILES=$(find . -type f \ | |
! -path "./.git/*" \ | |
! -path "./**/tests/**/*.spec.ts" \ | |
! -path "./**/__tests__/**/*.test.ts" \ | |
! -path "./apps/web/build/*" \ | |
! -path "./apps/web/public/*" \ | |
! -path "./apps/web/vite.config.js" \ | |
! -path "./apps/web/src/lib/site-analytics/*" \ | |
! -path "./packages/mirinae/scripts/*" \ | |
! -path "./packages/mirinae/cli/*" \ | |
! -path "./**/*.stories.ts" \ | |
-exec grep -l "console\.log" {} + || true) | |
LOG_COUNT=0 | |
if [ -n "$LOG_FILES" ]; then | |
echo "The following files contain console.log:" | |
echo "$LOG_FILES" | |
LOG_COUNT=$(echo "$LOG_FILES" | wc -l) | |
echo "::warning:: Found $LOG_COUNT file(s) with console.log." | |
else | |
echo "No console.log found." | |
fi | |
echo "console_log_count=$LOG_COUNT" >> $GITHUB_ENV | |
- name: Check for console.debug | |
id: check_console_debug | |
working-directory: changed_files | |
run: | | |
echo "Checking for console.debug..." | |
DEBUG_FILES=$(find . -type f \ | |
! -path "./.git/*" \ | |
! -path "./**/tests/**/*.spec.ts" \ | |
! -path "./**/__tests__/**/*.test.ts" \ | |
! -path "./apps/web/build/*" \ | |
! -path "./apps/web/public/*" \ | |
! -path "./apps/web/src/store/display/display-store.ts" \ | |
! -path "./apps/web/src/lib/config/index.ts" \ | |
! -path "./packages/mirinae/scripts/*" \ | |
! -path "./packages/mirinae/cli/*" \ | |
! -path "./packages/core-lib/src/space-connector/token-api.ts" \ | |
! -path "./**/*.stories.ts" \ | |
-exec grep -l "console\.debug" {} + || true) | |
DEBUG_COUNT=0 | |
if [ -n "$DEBUG_FILES" ]; then | |
echo "The following files contain console.debug:" | |
echo "$DEBUG_FILES" | |
DEBUG_COUNT=$(echo "$DEBUG_FILES" | wc -l) | |
echo "::warning:: Found $DEBUG_COUNT file(s) with console.debug." | |
else | |
echo "No console.debug found." | |
fi | |
echo "console_debug_count=$DEBUG_COUNT" >> $GITHUB_ENV | |
- name: Fail if issues found | |
run: | | |
echo "TODO Count: $todo_count" | |
echo "console.log Count: $console_log_count" | |
echo "console.debug Count: $console_debug_count" | |
if [ "$todo_count" -gt 0 ] || [ "$console_log_count" -gt 0 ] || [ "$console_debug_count" -gt 0 ]; then | |
echo "::error:: Workflow failed. TODO count: $todo_count, console.log count: $console_log_count, console.debug count: $console_debug_count" | |
exit 1 | |
else | |
echo "No issues found. Workflow passed." | |
fi |