Files
db-sikuler/.gitea/workflows/detekt.yml
T
nillkiggers 0f40b3bf30
Detekt / Detekt analysis (push) Successful in 26s
Обновить .gitea/workflows/detekt.yml
2026-10-08 09:21:40 +00:00

138 lines
5.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Detekt
on:
push:
workflow_dispatch:
permissions:
contents: read
jobs:
detekt:
name: Detekt analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Download Detekt CLI
shell: bash
run: |
set -euo pipefail
curl -fsSL -o detekt-cli.jar \
https://github.com/detekt/detekt/releases/download/v1.23.6/detekt-cli-1.23.6-all.jar
- name: Run Detekt
id: detekt
shell: bash
run: |
set +e
java -jar detekt-cli.jar \
--input . \
--base-path . \
--report txt:detekt-report.txt \
--report checkstyle:detekt-checkstyle.xml \
> detekt-console-output.txt 2>&1
echo $? > detekt-exit-code.txt
exit 0
- name: Show readable Detekt report
if: always()
shell: bash
run: |
set +e
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ DETEKT CODE REVIEW ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
if [ ! -s detekt-report.txt ]; then
echo "✅ Нарушений не найдено."
exit 0
fi
TOTAL=$(grep -cve '^[[:space:]]*$' detekt-report.txt || true)
echo "📊 Всего нарушений: $TOTAL"
echo ""
echo "┌──────────────────────────────────────────────────────────────┐"
echo "│ Нарушения по правилам │"
echo "└──────────────────────────────────────────────────────────────┘"
awk '
{
rule=$1
count[rule]++
}
END {
for (rule in count) {
print count[rule], rule
}
}
' detekt-report.txt \
| sort -rn \
| awk '{printf " %4s %s\n", $1, $2}'
echo ""
echo "┌──────────────────────────────────────────────────────────────┐"
echo "│ Все найденные проблемы │"
echo "└──────────────────────────────────────────────────────────────┘"
echo ""
while IFS= read -r line; do
[ -z "$line" ] && continue
rule=$(echo "$line" | awk '{print $1}')
location=$(echo "$line" | sed -nE 's/.* at (.*):([0-9]+):([0-9]+).*/\1:\2:\3/p')
message=$(echo "$line" | sed -E 's/^[^ ]+ - //')
if [ -n "$location" ]; then
file=$(echo "$location" | cut -d: -f1)
line_number=$(echo "$location" | cut -d: -f2)
column_number=$(echo "$location" | cut -d: -f3)
repo_url="${{ gitea.server_url }}/${{ gitea.repository }}"
file_url="$repo_url/src/commit/${{ gitea.sha }}/$file#L$line_number"
echo "🔴 [$rule]"
echo " 📍 $file:$line_number:$column_number"
echo " 🔗 $file_url"
echo " 💬 $message"
else
echo "🔴 $line"
fi
echo ""
done < detekt-report.txt
echo "══════════════════════════════════════════════════════════════"
echo "ℹ️ Полный отчёт показан выше в этом шаге."
echo "ℹ️ Проверка запускается автоматически при каждом push."
echo "══════════════════════════════════════════════════════════════"
- name: Detekt result
if: always()
shell: bash
run: |
if [ -f detekt-exit-code.txt ]; then
DETEKT_EXIT_CODE=$(cat detekt-exit-code.txt)
echo ""
echo "Detekt завершился с кодом: $DETEKT_EXIT_CODE"
echo "Workflow оставлен успешным специально."
echo "Чтобы блокировать workflow при нарушениях, замените exit 0 на exit \$DETEKT_EXIT_CODE."
fi