Skip to content

Commit 60e2cb6

Browse files
removendo comentarios de debug
1 parent 17ccafa commit 60e2cb6

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

entrypoint.sh

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/sh
22
set -e
33

4-
# Constants
54
CODENARC_RESULT="result.txt"
65
LINE_VIOLATIONS="line_violations.txt"
76
FILE_VIOLATIONS="file_violations.txt"
@@ -52,57 +51,44 @@ run_reviewdog_with_config() {
5251
}
5352

5453
separate_violations() {
55-
echo "🔍 DEBUG: Conteúdo completo do CODENARC_RESULT:"
56-
echo "--- INÍCIO ---"
57-
cat "$CODENARC_RESULT"
58-
echo "--- FIM ---"
59-
60-
# Capturar violações line-based (formato: arquivo:linha:regra)
6154
grep -E ':[0-9]+:' "$CODENARC_RESULT" > "$LINE_VIOLATIONS" || true
62-
63-
# Capturar violações file-based (ambos os formatos: :null: e ||)
6455
grep -E ':null:|\|\|' "$CODENARC_RESULT" > "$FILE_VIOLATIONS" || true
65-
66-
echo "🔍 DEBUG: Line violations encontradas:"
67-
[ -s "$LINE_VIOLATIONS" ] && head -3 "$LINE_VIOLATIONS" || echo "Nenhuma"
68-
echo "🔍 DEBUG: File violations encontradas:"
69-
[ -s "$FILE_VIOLATIONS" ] && head -3 "$FILE_VIOLATIONS" || echo "Nenhuma"
7056
}
7157

7258
run_reviewdog() {
7359
echo "📤 Enviando resultados para reviewdog..."
7460

7561
separate_violations
7662

77-
# Violações line-based com reporter configurado
7863
if [ -s "$LINE_VIOLATIONS" ]; then
79-
echo "📤 Enviando violações com linha (${INPUT_REPORTER:-github-pr-check})..."
64+
echo "📤 Enviando violações line-based (${INPUT_REPORTER:-github-pr-check})..."
8065
run_reviewdog_with_config "$LINE_VIOLATIONS" "%f:%l:%m" \
8166
"${INPUT_REPORTER:-github-pr-check}" "codenarc" \
8267
"${INPUT_FILTER_MODE}" "${INPUT_LEVEL}"
8368
fi
8469

85-
# Violações file-based forçando github-pr-check
8670
if [ -s "$FILE_VIOLATIONS" ]; then
87-
echo "📤 Enviando violações file-based (github-pr-check)..."
88-
89-
# Criar arquivo temporário com formato correto para reviewdog
9071
> "${FILE_VIOLATIONS}.formatted"
9172
while read -r violation; do
9273
if echo "$violation" | grep -q '||'; then
93-
# Formato CI: arquivo||regra mensagem -> arquivo::regra mensagem
9474
echo "$violation" | sed 's/||/::/'
9575
else
96-
# Formato local: arquivo:null:regra mensagem -> arquivo::regra mensagem
9776
echo "$violation" | sed 's/:null:/::/'
9877
fi
9978
done < "$FILE_VIOLATIONS" > "${FILE_VIOLATIONS}.formatted"
10079

101-
run_reviewdog_with_config "${FILE_VIOLATIONS}.formatted" "%f::%m" \
102-
"github-pr-check" "codenarc" "nofilter" "warning"
80+
if [ "${INPUT_REPORTER}" = "local" ]; then
81+
echo "📤 Enviando violações file-based (local)..."
82+
run_reviewdog_with_config "${FILE_VIOLATIONS}.formatted" "%f::%m" \
83+
"local" "codenarc" "nofilter" "${INPUT_LEVEL}"
84+
else
85+
echo "📤 Enviando violações file-based (github-pr-check)..."
86+
run_reviewdog_with_config "${FILE_VIOLATIONS}.formatted" "%f::%m" \
87+
"github-pr-check" "codenarc" "nofilter" "warning"
88+
fi
10389
fi
10490

105-
# Fallback se não houver violações categorizadas
91+
# fallback se nao houver violacoes categorizadas
10692
if [ ! -s "$LINE_VIOLATIONS" ] && [ ! -s "$FILE_VIOLATIONS" ]; then
10793
echo "📝 Executando reviewdog padrão..."
10894
run_reviewdog_with_config "$CODENARC_RESULT" "%f:%l:%m" \
@@ -199,20 +185,19 @@ check_blocking_rules() {
199185
[ ! -f "$CODENARC_RESULT" ] && echo "❌ Resultado não encontrado" && return 1
200186

201187
p1_count=$(get_p1_count)
202-
echo "📊 Total de P1: $p1_count"
188+
echo "📊 Total de P1 encontradas: $p1_count"
203189

204-
[ "$p1_count" -eq 0 ] && echo "✅ Nenhuma P1 → merge permitido" && return 0
190+
[ "$p1_count" -eq 0 ] && echo "✅ Nenhuma P1 detectada → merge permitido" && return 0
205191

206192
echo "⚠️ Verificando P1s em linhas alteradas..."
207193
build_changed_lines_cache
208194

209195
allowed_patterns=$(get_allowed_patterns)
210-
[ -n "$allowed_patterns" ] && echo "🧩 Filtrando por INPUT_SOURCE_FILES"
196+
[ -n "$allowed_patterns" ] && echo "🧩 Analisando apenas arquivos filtrados por INPUT_SOURCE_FILES"
211197

212198
echo "0" > "$VIOLATIONS_FLAG"
213199

214200
grep -E ':[0-9]+:|:null:|\|\|' "$CODENARC_RESULT" | while IFS=: read -r file line rest; do
215-
# Tratar formato || (ambiente CI)
216201
if echo "$file" | grep -q '||'; then
217202
file=$(echo "$file" | cut -d'|' -f1)
218203
line=""
@@ -236,19 +221,17 @@ check_blocking_rules() {
236221
echo "🔧 Exit desabilitado temporariamente para monitoramento"
237222
# exit 1
238223
else
239-
echo "✅ P1s existem mas FORA das linhas alteradas → merge permitido"
224+
echo "✅ P1s existem mas fora das linhas alteradas → merge permitido"
240225
fi
241226
}
242227

243-
# Setup
244228
if [ -n "${GITHUB_WORKSPACE}" ]; then
245229
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
246230
git config --global --add safe.directory "$GITHUB_WORKSPACE"
247231
fi
248232

249233
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
250234

251-
# Execute pipeline
252235
run_codenarc
253236
run_reviewdog
254237
check_blocking_rules

0 commit comments

Comments
 (0)