Skip to content

Commit e5b05c6

Browse files
feat: Add GitHub Actions for automated translation compilation, variable renaming, glossary updates, and TSV validation.
1 parent d990b2d commit e5b05c6

File tree

4 files changed

+136
-14
lines changed

4 files changed

+136
-14
lines changed

.github/workflows/compile-on-merge.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ on:
2020
paths:
2121
- 'pt-br.tsv'
2222

23+
# ========== FILA AUTOMÁTICA ==========
24+
# Evita conflitos quando múltiplos merges são feitos em sequência
25+
concurrency:
26+
group: compile-translations-queue
27+
cancel-in-progress: false
28+
2329
jobs:
2430
compile:
2531
runs-on: ubuntu-latest
@@ -135,6 +141,21 @@ jobs:
135141
Glossário usado: rodrigomiquilino/wwm_brasileiro/docs/glossary.json
136142
Compilado automaticamente via GitHub Actions"
137143
138-
# Pull com rebase para evitar conflitos de race condition
139-
git pull --rebase origin main || true
140-
git push origin main
144+
# ========== PUSH COM RETRY ==========
145+
for attempt in 1 2 3; do
146+
echo "📤 Tentativa $attempt de push..."
147+
git pull --rebase origin main 2>/dev/null || true
148+
if git push origin main; then
149+
echo "✅ Push realizado com sucesso!"
150+
break
151+
else
152+
if [ $attempt -lt 3 ]; then
153+
echo "⚠️ Falha no push, aguardando $((attempt * 2))s..."
154+
sleep $((attempt * 2))
155+
else
156+
echo "❌ Falha após 3 tentativas"
157+
exit 1
158+
fi
159+
fi
160+
done
161+

.github/workflows/rename-variable-receiver.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
repository_dispatch:
1111
types: [rename-variable]
1212

13+
# ========== FILA AUTOMÁTICA ==========
14+
# Evita conflitos quando várias renomeações são feitas em sequência
15+
concurrency:
16+
group: rename-variable-queue
17+
cancel-in-progress: false
18+
1319
jobs:
1420
rename:
1521
runs-on: ubuntu-latest
@@ -59,9 +65,27 @@ jobs:
5965
git commit -m "🔄 Renomear variável: ${{ github.event.client_payload.old_var }} → ${{ github.event.client_payload.new_var }}
6066
6167
Disparado via glossary-admin por @${{ github.event.client_payload.triggered_by }}"
62-
git push origin dev
68+
69+
# ========== PUSH COM RETRY ==========
70+
for attempt in 1 2 3; do
71+
echo "📤 Tentativa $attempt de push..."
72+
git pull --rebase origin dev 2>/dev/null || true
73+
if git push origin dev; then
74+
echo "✅ Push realizado com sucesso!"
75+
break
76+
else
77+
if [ $attempt -lt 3 ]; then
78+
echo "⚠️ Falha no push, aguardando $((attempt * 2))s..."
79+
sleep $((attempt * 2))
80+
else
81+
echo "❌ Falha após 3 tentativas"
82+
exit 1
83+
fi
84+
fi
85+
done
6386
6487
- name: No changes needed
6588
if: steps.git-check.outputs.changed == 'false'
6689
run: |
6790
echo "ℹ️ Nenhuma ocorrência de ${{ github.event.client_payload.old_var }} encontrada no arquivo."
91+

.github/workflows/update-glossary.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
repository_dispatch:
1111
types: [update-glossary]
1212

13+
# ========== FILA AUTOMÁTICA ==========
14+
# Evita conflitos quando várias edições são feitas rapidamente
15+
concurrency:
16+
group: update-glossary-queue
17+
cancel-in-progress: false
18+
1319
jobs:
1420
update:
1521
runs-on: ubuntu-latest
@@ -82,11 +88,27 @@ jobs:
8288
git commit -m "$MSG
8389
8490
Disparado via glossary-admin por @${{ github.event.client_payload.triggered_by }}"
85-
git push origin main
8691
87-
echo "✅ Commit realizado!"
92+
# ========== PUSH COM RETRY ==========
93+
for attempt in 1 2 3; do
94+
echo "📤 Tentativa $attempt de push..."
95+
git pull --rebase origin main 2>/dev/null || true
96+
if git push origin main; then
97+
echo "✅ Push realizado com sucesso!"
98+
break
99+
else
100+
if [ $attempt -lt 3 ]; then
101+
echo "⚠️ Falha no push, aguardando $((attempt * 2))s..."
102+
sleep $((attempt * 2))
103+
else
104+
echo "❌ Falha após 3 tentativas"
105+
exit 1
106+
fi
107+
fi
108+
done
88109
89110
- name: No changes needed
90111
if: steps.git-check.outputs.changed == 'false'
91112
run: |
92113
echo "ℹ️ Nenhuma alteração detectada no glossário."
114+

.github/workflows/validate_tsv.yml

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
name: Validate translation_ru.tsv
1+
# Valida o arquivo pt-br.tsv quando modificado
2+
# Verifica estrutura TSV, encoding UTF-8 e consistência
3+
4+
name: Validate pt-br.tsv
25

36
on:
47
push:
58
paths:
6-
- 'translation_ru.tsv'
9+
- 'pt-br.tsv'
710
- '.github/workflows/validate_tsv.yml'
11+
- '.github/scripts/validate_tsv.py'
812
pull_request:
913
paths:
10-
- 'translation_ru.tsv'
14+
- 'pt-br.tsv'
1115
- '.github/workflows/validate_tsv.yml'
16+
- '.github/scripts/validate_tsv.py'
1217

1318
jobs:
1419
validate:
@@ -22,11 +27,61 @@ jobs:
2227
with:
2328
python-version: '3.11'
2429

25-
- name: Validate TSV file
30+
- name: Validate TSV structure
2631
run: |
27-
python .github/scripts/validate_tsv.py translation_ru.tsv
32+
echo "📋 Validando estrutura do pt-br.tsv..."
33+
34+
# Verifica se arquivo existe
35+
if [ ! -f pt-br.tsv ]; then
36+
echo "❌ Arquivo pt-br.tsv não encontrado!"
37+
exit 1
38+
fi
39+
40+
# Conta linhas
41+
LINES=$(wc -l < pt-br.tsv)
42+
echo " 📄 Total de linhas: $LINES"
43+
44+
# Verifica encoding UTF-8
45+
if file pt-br.tsv | grep -q "UTF-8"; then
46+
echo " ✅ Encoding: UTF-8"
47+
else
48+
echo " ⚠️ Encoding pode não ser UTF-8"
49+
fi
50+
51+
# Verifica se todas as linhas têm TAB
52+
LINES_WITHOUT_TAB=$(grep -cv $'\t' pt-br.tsv || true)
53+
if [ "$LINES_WITHOUT_TAB" -gt 0 ]; then
54+
echo " ⚠️ $LINES_WITHOUT_TAB linhas sem TAB (pode ser header ou linhas vazias)"
55+
else
56+
echo " ✅ Todas as linhas têm estrutura TSV"
57+
fi
58+
59+
# Verifica linhas com número incorreto de colunas
60+
EXPECTED_COLS=2
61+
WRONG_COLS=$(awk -F'\t' -v exp="$EXPECTED_COLS" 'NF != exp {count++} END {print count+0}' pt-br.tsv)
62+
if [ "$WRONG_COLS" -gt 0 ]; then
63+
echo " ⚠️ $WRONG_COLS linhas com número de colunas diferente de $EXPECTED_COLS"
64+
else
65+
echo " ✅ Todas as linhas têm $EXPECTED_COLS colunas"
66+
fi
67+
68+
echo ""
69+
echo "✅ Validação concluída!"
2870
29-
- name: Validate tags
71+
- name: Check for duplicate IDs
3072
run: |
31-
python .github/scripts/validate_tags.py translation_ru.tsv
32-
73+
echo "🔍 Verificando IDs duplicados..."
74+
75+
# Extrai primeira coluna (IDs) e encontra duplicados
76+
DUPLICATES=$(cut -f1 pt-br.tsv | sort | uniq -d)
77+
78+
if [ -n "$DUPLICATES" ]; then
79+
echo "⚠️ IDs duplicados encontrados:"
80+
echo "$DUPLICATES" | head -20
81+
DUPE_COUNT=$(echo "$DUPLICATES" | wc -l)
82+
if [ "$DUPE_COUNT" -gt 20 ]; then
83+
echo "... e mais $((DUPE_COUNT - 20)) duplicados"
84+
fi
85+
else
86+
echo "✅ Nenhum ID duplicado encontrado"
87+
fi

0 commit comments

Comments
 (0)