Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for keywords #280

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/keywords-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Check icons keywords

on:
pull_request:
branches:
- production
paths:
- "icons/**"

jobs:
check_icons:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: List SVG files
run: |
ICONS_DIR="icons" # Reemplaza con la ubicación real de tu carpeta de iconos
echo "Listing SVG files..."

# Utiliza 'find' para encontrar todos los archivos SVG en la carpeta de iconos
find $ICONS_DIR -type f -name "*.svg" |

# Utiliza 'basename' para obtener solo el nombre de archivo sin la ruta
xargs -I {} basename {} |

# Utiliza 'sed' para quitar las partes "-filled", "-light", "-regular" y la extensión ".svg"
sed 's/\(-filled\|-light\|-regular\)\.svg//' |

# Utiliza 'sort -u' para obtener una lista única de nombres de archivo
sort -u > icons.txt

# Muestra el contenido del archivo icons.txt en la consola
cat icons.txt
continue-on-error: false

- name: Read JSON file
run: |
JSON_FILE="icons/icons-keywords.json"
echo "Reading JSON file..."
cat $JSON_FILE > data.json
continue-on-error: true

- name: Extract keywords
run: |
echo "Extracting keywords from JSON..."

# Usamos jq para extraer las claves del JSON y guardarlas en keywords.txt
cat data.json | jq -r 'keys[]' > keywords.txt

# Mostramos el contenido de keywords.txt para verificar que se han extraído correctamente
cat keywords.txt
continue-on-error: true

- name: Compare with Keywords
run: |
echo "Comparing icon names with keywords from JSON..."
for icon_name in $(cat icons.txt); do
if ! grep -q "\"$icon_name\":" data.json; then
echo "Icon name '$icon_name' is missing in the JSON keywords."
exit 1 # Terminar la ejecución con un código de error
fi
done
continue-on-error: false

- name: Cleanup
run: |
rm data.json
rm icons.txt
rm keywords.txt
continue-on-error: true
Loading