From e46099184158b0b3cba9a19b60147e806e15aca6 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 16 Oct 2023 22:05:55 +0100 Subject: [PATCH] feat: add serverlist game icon validation This commit adds a new script `serverlist-validate-game-icons.sh` that checks if all the game servers listed in `serverlist.csv` have a corresponding `shortname-icon.png` file. It also verifies that the number of game icons matches the number of servers in `serverlist.csv`. The script is executed as part of the workflow defined in `serverlist-validate.yml`. Co-authored-by: [co-author-name] --- .../serverlist-validate-game-icons.sh | 29 +++++++++++++++++++ .github/workflows/serverlist-validate.yml | 3 ++ 2 files changed, 32 insertions(+) create mode 100755 .github/workflows/serverlist-validate-game-icons.sh diff --git a/.github/workflows/serverlist-validate-game-icons.sh b/.github/workflows/serverlist-validate-game-icons.sh new file mode 100755 index 000000000..ebb7360f3 --- /dev/null +++ b/.github/workflows/serverlist-validate-game-icons.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +cd "lgsm/data" || exit + +echo "" +echo "Checking that all the game servers listed in serverlist.csv have a shortname-icon.png file" +for shortname in $(tail -n +2 serverlist.csv | cut -d ',' -f1); do + # check if $shortname-icon.png exists + if [ ! -f "gameicons/${shortname}-icon.png" ]; then + echo "ERROR: gameicons/${shortname}-icon.png does not exist" + exitcode=1 + else + echo "OK: gameicons/${shortname}-icon.png exists" + 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)" + exitcode=1 +else + echo "OK: gameiconcount ($gameiconcount) matches serverlistcount ($serverlistcount)" +fi + +exit ${exitcode} diff --git a/.github/workflows/serverlist-validate.yml b/.github/workflows/serverlist-validate.yml index 13f7376a1..931329571 100644 --- a/.github/workflows/serverlist-validate.yml +++ b/.github/workflows/serverlist-validate.yml @@ -12,3 +12,6 @@ jobs: - name: Compare Versions run: chmod +x .github/workflows/serverlist-validate.sh; .github/workflows/serverlist-validate.sh + + - name: Validate Game Icons + run: chmod +x .github/workflows/serverlist-validate-game-icons.sh; .github/workflows/serverlist-validate-game-icons.sh