From ad3453e4f99e5845ba2c67e5c4919152f8875737 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 16 Oct 2023 22:10:46 +0100 Subject: [PATCH] refactor: improve game icon validation script The commit refactors the game icon validation script to improve its functionality. It adds a check for unexpected game icons and ensures that the number of game icons matches the number of servers in serverlist.csv. The commit also updates error messages for better clarity and readability. --- .../workflows/serverlist-validate-game-icons.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/serverlist-validate-game-icons.sh b/.github/workflows/serverlist-validate-game-icons.sh index ebb7360f3..4701aabd6 100755 --- a/.github/workflows/serverlist-validate-game-icons.sh +++ b/.github/workflows/serverlist-validate-game-icons.sh @@ -14,13 +14,25 @@ for shortname in $(tail -n +2 serverlist.csv | cut -d ',' -f1); do fi done +echo "" +echo "Checking if an unexpected gameicon exists" +for gameicon in $(ls -1 gameicons); do + # check if $gameicon is in serverlist.csv + if ! grep -q "${gameicon%-icon.png}" serverlist.csv; then + echo "ERROR: gameicon ${gameicon} is not in serverlist.csv" + exitcode=1 + else + echo "OK: gameicon ${gameicon} is in serverlist.csv" + fi +done + # check that the number of gameicons matches the number of servers in serverlist.csv echo "" echo "Checking that the number of gameicons matches the number of servers in serverlist.csv" gameiconcount="$(ls -1 gameicons | wc -l)" serverlistcount="$(tail -n +2 serverlist.csv | wc -l)" if [ "${gameiconcount}" -ne "${serverlistcount}" ]; then - echo "ERROR: game icons (${gameiconcount}) does not match serverlistcount ($serverlistcount)" + echo "ERROR: game icons (${gameiconcount}) does not match serverlist.csv ($serverlistcount)" exitcode=1 else echo "OK: gameiconcount ($gameiconcount) matches serverlistcount ($serverlistcount)"