Skip to content

Commit 956c098

Browse files
authored
ci: update codacy-variation-fallback.yml
1 parent 1358ad7 commit 956c098

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

.github/workflows/codacy-variation-fallback.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,44 @@ jobs:
3131
- name: Parse codacy.yml exclusions
3232
id: parse-codacy-exclusions
3333
run: |
34-
3534
FILE_NAME=".codacy.yml"
3635
36+
# --- 1. EXTRACCIÓN Y DEFINICIÓN DE RUTAS ---
37+
38+
# Usamos 'yq' para extraer la lista de rutas excluidas (EXCLUDES)
39+
# '2>/dev/null || true' evita que el workflow falle si la clave no existe.
40+
EXCLUDES=$(yq '.exclude_paths[]' "$FILE_NAME" 2>/dev/null || true)
41+
42+
# Definimos las rutas estáticas de control que siempre ignoramos.
43+
STATIC_IGNORES=".github/**"$'\n'"$FILE_NAME"
44+
45+
# Concatenamos todas las rutas a una sola variable.
46+
ALL_PATHS="$EXCLUDES"$'\n'"$STATIC_IGNORES"
47+
48+
# Si el fichero no existe, avisamos
3749
if [ ! -f "$FILE_NAME" ]; then
3850
echo "::warning::File $FILE_NAME not found. Basic ignored configuration file will be used."
3951
fi
4052
41-
42-
# Extract excluded paths and add the 'codacy.yml' file itself
53+
# --- 2. GENERACIÓN DEL FORMATO YAML ---
54+
55+
# Inicializamos la lista con las inclusiones obligatorias (para dotfiles/carpetas ocultas)
4356
FORMATTED_LIST="relevant_files:"$'\n'
44-
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \"**\"" # 1. Incluir todo lo visible
45-
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \".*/**\"" # 2. Incluir todo lo oculto (ej. .github, .vscode, .codacy.yml)
57+
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \"**\"" # 1. Incluir visible
58+
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \".*/**\"" # 2. Incluir oculto (SOLUCIÓN .github/)
4659
47-
# Format the list
60+
# Iteramos sobre todas las rutas para añadir las exclusiones (negaciones)
61+
# ALL_PATHS ahora sí contiene la lista de rutas dinámicas y estáticas.
4862
while IFS= read -r line; do
4963
if [[ -n "$line" ]]; then
50-
# Generamos la negación: - "!ruta"
51-
# Mantenemos las comillas dobles para evitar el error de alias
52-
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \"!${line}\""
53-
fi
64+
# Generamos la negación: - "!ruta"
65+
FORMATTED_LIST="$FORMATTED_LIST"$'\n'"- \"!${line}\""
66+
fi
5467
done <<< "$ALL_PATHS"
5568
56-
# Save the result on a variable
69+
# --- 3. GUARDAR EL OUTPUT ---
70+
71+
# Guardamos el resultado en la variable
5772
{
5873
echo 'filters<<EOF'
5974
echo "$FORMATTED_LIST"

0 commit comments

Comments
 (0)