diff --git a/.github/workflows/pull_request_code_warning.yml b/.github/workflows/pull_request_code_warning.yml new file mode 100644 index 0000000000..29b0997750 --- /dev/null +++ b/.github/workflows/pull_request_code_warning.yml @@ -0,0 +1,76 @@ +name: "[PR] Code Warning" + +on: + pull_request: + types: [opened, synchronize, reopened] + path-ignores: + - '.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@v3 + + - name: Check for TODOs + id: check_todo + run: | + echo "Checking for TODOs..." + TODO_FILES=$(grep -rl "TODO" . --exclude-dir={node_modules,.git} || 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) + else + echo "No TODOs found." + fi + echo "::warning:: Found $TODO_COUNT file(s) with TODO." + echo "todo_count=$TODO_COUNT" >> $GITHUB_ENV + + - name: Check for console.log + id: check_console_log + run: | + echo "Checking for console.log..." + LOG_FILES=$(grep -rl "console.log" . --exclude-dir={node_modules,.git} || 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) + else + echo "No console.log found." + fi + echo "::warning:: Found $LOG_COUNT file(s) with console.log." + echo "console_log_count=$LOG_COUNT" >> $GITHUB_ENV + + - name: Fail if issues found + run: | + echo "TODO Count: $todo_count" + echo "console.log Count: $console_log_count" + if [ "$todo_count" -gt 0 ] || [ "$console_log_count" -gt 0 ]; then + echo "::warning:: Workflow failed. TODO count: $todo_count, console.log count: $console_log_count" + exit 1 + else + echo "No issues found. Workflow passed." + fi