From 0b20c6c2598dbc03fa82009405d99775be584809 Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Tue, 9 Dec 2025 12:38:56 -0300 Subject: [PATCH 1/6] feat: bloquear merge em violacoes bloqueantes do codenarc no grails 4 --- entrypoint.sh | 80 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 21 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 98d4fdf..24ba25c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,34 +1,72 @@ #!/bin/sh set -e +trap 'rm -f result.txt >/dev/null 2>&1' EXIT -if [ -n "${GITHUB_WORKSPACE}" ] ; then - cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit - git config --global --add safe.directory "$GITHUB_WORKSPACE" || exit -fi +# --- auxiliares ------------------------------------------------------- -export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" +run_codenarc() { + local report="${INPUT_REPORT:-compact:stdout}" + local includes_arg="" + + if [ -n "$INPUT_SOURCE_FILES" ]; then + includes_arg="-includes=${INPUT_SOURCE_FILES}" + fi -if [ -n "$INPUT_SOURCE_FILES" ]; then + echo "πŸ” Executando CodeNarc..." java -jar /lib/codenarc-all.jar \ - -report="${INPUT_REPORT:-compact:stdout}" \ + -report="$report" \ -rulesetfiles="${INPUT_RULESETFILES}" \ -basedir="." \ - -includes="${INPUT_SOURCE_FILES}" \ - > result.txt -else - java -jar /lib/codenarc-all.jar \ - -report="${INPUT_REPORT:-compact:stdout}" \ - -rulesetfiles="${INPUT_RULESETFILES}" \ + $includes_arg \ > result.txt +} + +run_reviewdog() { + echo "πŸ“€ Enviando resultados para reviewdog..." + < result.txt reviewdog -efm="%f:%l:%m" -efm="%f:%r:%m" \ + -name="codenarc" \ + -reporter="${INPUT_REPORTER:-github-pr-check}" \ + -filter-mode="${INPUT_FILTER_MODE}" \ + -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -level="${INPUT_LEVEL}" \ + ${INPUT_REVIEWDOG_FLAGS} +} + +check_blocking_rules() { + if [ "${INPUT_GRAILS_VERSION}" = "4" ]; then + echo "πŸ”Ž Verificando violacoes bloqueantes (priority 1 ou 2)..." + + local p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | tail -1) + local p2_count=$(grep -Eo "p2=[0-9]+" result.txt | cut -d'=' -f2 | tail -1) + + p1_count=${p1_count:-0} + p2_count=${p2_count:-0} + + echo "πŸ“Š Resumo CodeNarc -> p1=${p1_count}, p2=${p2_count}" + + if [ "$p1_count" -gt 0 ] || [ "$p2_count" -gt 0 ]; then + echo "β›” Encontradas violacoes bloqueantes (priority 1 ou 2)." + echo "πŸ’‘ Corrija as violacoes ou faca bypass autorizado." + exit 1 + else + echo "βœ… Nenhuma violacao bloqueante encontrada." + fi + else + echo "ℹ️ Modo Grails 2 detectado (sem bloqueio automatico)." + fi +} + +# --- principal ------------------------------------------------------- + +if [ -n "${GITHUB_WORKSPACE}" ] ; then + cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit + git config --global --add safe.directory "$GITHUB_WORKSPACE" fi +export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" -< result.txt reviewdog -efm="%f:%l:%m" -efm="%f:%r:%m" \ - -name="codenarc" \ - -reporter="${INPUT_REPORTER:-github-pr-check}" \ - -filter-mode="${INPUT_FILTER_MODE}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ - -level="${INPUT_LEVEL}" \ - ${INPUT_REVIEWDOG_FLAGS} +run_codenarc +run_reviewdog +check_blocking_rules -rm result.txt \ No newline at end of file +echo "🏁 Finalizado com sucesso." From d2613737fae37e9924507f42bfabb01510854a82 Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Wed, 10 Dec 2025 11:53:08 -0300 Subject: [PATCH 2/6] ajustes de code review --- entrypoint.sh | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 24ba25c..007b725 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,10 +3,9 @@ set -e trap 'rm -f result.txt >/dev/null 2>&1' EXIT # --- auxiliares ------------------------------------------------------- - run_codenarc() { - local report="${INPUT_REPORT:-compact:stdout}" - local includes_arg="" + report="${INPUT_REPORT:-compact:stdout}" + includes_arg="" if [ -n "$INPUT_SOURCE_FILES" ]; then includes_arg="-includes=${INPUT_SOURCE_FILES}" @@ -14,30 +13,30 @@ run_codenarc() { echo "πŸ” Executando CodeNarc..." java -jar /lib/codenarc-all.jar \ - -report="$report" \ - -rulesetfiles="${INPUT_RULESETFILES}" \ - -basedir="." \ - $includes_arg \ - > result.txt + -report="$report" \ + -rulesetfiles="${INPUT_RULESETFILES}" \ + -basedir="." \ + $includes_arg \ + > result.txt } run_reviewdog() { echo "πŸ“€ Enviando resultados para reviewdog..." < result.txt reviewdog -efm="%f:%l:%m" -efm="%f:%r:%m" \ - -name="codenarc" \ - -reporter="${INPUT_REPORTER:-github-pr-check}" \ - -filter-mode="${INPUT_FILTER_MODE}" \ - -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ - -level="${INPUT_LEVEL}" \ - ${INPUT_REVIEWDOG_FLAGS} + -name="codenarc" \ + -reporter="${INPUT_REPORTER:-github-pr-check}" \ + -filter-mode="${INPUT_FILTER_MODE}" \ + -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ + -level="${INPUT_LEVEL}" \ + ${INPUT_REVIEWDOG_FLAGS} } check_blocking_rules() { if [ "${INPUT_GRAILS_VERSION}" = "4" ]; then echo "πŸ”Ž Verificando violacoes bloqueantes (priority 1 ou 2)..." - local p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | tail -1) - local p2_count=$(grep -Eo "p2=[0-9]+" result.txt | cut -d'=' -f2 | tail -1) + p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | head -1) + p2_count=$(grep -Eo "p2=[0-9]+" result.txt | cut -d'=' -f2 | head -1) p1_count=${p1_count:-0} p2_count=${p2_count:-0} @@ -58,7 +57,7 @@ check_blocking_rules() { # --- principal ------------------------------------------------------- -if [ -n "${GITHUB_WORKSPACE}" ] ; then +if [ -n "${GITHUB_WORKSPACE}" ]; then cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit git config --global --add safe.directory "$GITHUB_WORKSPACE" fi From 00cf0f0c41d7444a2a2e21f8d70ed32c3fb397ec Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Thu, 11 Dec 2025 11:34:49 -0300 Subject: [PATCH 3/6] ajustando a priority --- entrypoint.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 007b725..1791e3e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -32,31 +32,23 @@ run_reviewdog() { } check_blocking_rules() { - if [ "${INPUT_GRAILS_VERSION}" = "4" ]; then - echo "πŸ”Ž Verificando violacoes bloqueantes (priority 1 ou 2)..." + echo "πŸ”Ž Verificando violacoes bloqueantes (priority 1)..." - p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | head -1) - p2_count=$(grep -Eo "p2=[0-9]+" result.txt | cut -d'=' -f2 | head -1) + p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | head -1) + p1_count=${p1_count:-0} - p1_count=${p1_count:-0} - p2_count=${p2_count:-0} + echo "πŸ“Š Resumo CodeNarc -> priorityβ€―1=${p1_count}" - echo "πŸ“Š Resumo CodeNarc -> p1=${p1_count}, p2=${p2_count}" - - if [ "$p1_count" -gt 0 ] || [ "$p2_count" -gt 0 ]; then - echo "β›” Encontradas violacoes bloqueantes (priority 1 ou 2)." - echo "πŸ’‘ Corrija as violacoes ou faca bypass autorizado." - exit 1 - else - echo "βœ… Nenhuma violacao bloqueante encontrada." - fi + if [ "$p1_count" -gt 0 ]; then + echo "β›” Foram encontradas violacoes bloqueantes (priority 1)." + echo "πŸ’‘ Corrija as violacoes ou use o bypass autorizado pelo coordenador." + exit 1 else - echo "ℹ️ Modo Grails 2 detectado (sem bloqueio automatico)." + echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada." fi } # --- principal ------------------------------------------------------- - if [ -n "${GITHUB_WORKSPACE}" ]; then cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit git config --global --add safe.directory "$GITHUB_WORKSPACE" From f6f54ad3769b9b4f5268962ecff15a53bfa49978 Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Fri, 12 Dec 2025 11:12:45 -0300 Subject: [PATCH 4/6] =?UTF-8?q?feat(DVT=E2=80=91730):=20adicionar=20flag?= =?UTF-8?q?=20block=5Fon=5Fviolation=20para=20controlar=20bloqueio=20do=20?= =?UTF-8?q?merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entrypoint.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1791e3e..0c84876 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,15 +37,17 @@ check_blocking_rules() { p1_count=$(grep -Eo "p1=[0-9]+" result.txt | cut -d'=' -f2 | head -1) p1_count=${p1_count:-0} - echo "πŸ“Š Resumo CodeNarc -> priorityβ€―1=${p1_count}" + echo "πŸ“Š Resumo CodeNarc β†’ priorityβ€―1=${p1_count}" - if [ "$p1_count" -gt 0 ]; then + block_on_violation=$(echo "${INPUT_BLOCK_ON_VIOLATION}" | tr '[:upper:]' '[:lower:]' | xargs) + + if [ "$block_on_violation" = "true" ] && [ "$p1_count" -gt 0 ]; then echo "β›” Foram encontradas violacoes bloqueantes (priority 1)." echo "πŸ’‘ Corrija as violacoes ou use o bypass autorizado pelo coordenador." exit 1 - else - echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada." fi + + echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada ou flag de bloqueio desativada (block_on_violation=false)." } # --- principal ------------------------------------------------------- From 611d3ca59e6024227d6a928300b7b178cd464440 Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Fri, 12 Dec 2025 11:15:31 -0300 Subject: [PATCH 5/6] removendo comentarios --- entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0c84876..5a19c06 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,6 @@ set -e trap 'rm -f result.txt >/dev/null 2>&1' EXIT -# --- auxiliares ------------------------------------------------------- run_codenarc() { report="${INPUT_REPORT:-compact:stdout}" includes_arg="" @@ -50,7 +49,6 @@ check_blocking_rules() { echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada ou flag de bloqueio desativada (block_on_violation=false)." } -# --- principal ------------------------------------------------------- if [ -n "${GITHUB_WORKSPACE}" ]; then cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit git config --global --add safe.directory "$GITHUB_WORKSPACE" From f93d2f18288489cba6e531331fdeade385a8cb51 Mon Sep 17 00:00:00 2001 From: "ana.alves" Date: Fri, 12 Dec 2025 14:52:28 -0300 Subject: [PATCH 6/6] =?UTF-8?q?revert(DVT=E2=80=91730):=20remover=20flag?= =?UTF-8?q?=20block=5Fon=5Fviolation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5a19c06..e2086cd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -38,15 +38,13 @@ check_blocking_rules() { echo "πŸ“Š Resumo CodeNarc β†’ priorityβ€―1=${p1_count}" - block_on_violation=$(echo "${INPUT_BLOCK_ON_VIOLATION}" | tr '[:upper:]' '[:lower:]' | xargs) - - if [ "$block_on_violation" = "true" ] && [ "$p1_count" -gt 0 ]; then + if [ "$p1_count" -gt 0 ]; then echo "β›” Foram encontradas violacoes bloqueantes (priority 1)." echo "πŸ’‘ Corrija as violacoes ou use o bypass autorizado pelo coordenador." exit 1 + else + echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada." fi - - echo "βœ… Nenhuma violacao bloqueante (priority 1) encontrada ou flag de bloqueio desativada (block_on_violation=false)." } if [ -n "${GITHUB_WORKSPACE}" ]; then