details-check-run.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. # Runs the details check for each shortname given, in one shared LinuxGSM directory.
  3. # Modules, default configs and data come from the checkout, so the code under test is used and nothing is downloaded per server.
  4. # Usage: details-check-run.sh <shortname>...
  5. src="${GITHUB_WORKSPACE:-${PWD}}"
  6. workdir="${DETAILS_CHECK_DIR:-${HOME}/details-check}"
  7. summary="${GITHUB_STEP_SUMMARY:-/dev/null}"
  8. export LGSM_GITHUBBRANCH="${LGSM_REF:?LGSM_REF must be set}"
  9. rm -rf "${workdir}"
  10. mkdir -p "${workdir}/lgsm" "${workdir}/serverfiles"
  11. cp "${src}/linuxgsm.sh" "${workdir}/"
  12. cp -r "${src}/lgsm/modules" "${src}/lgsm/config-default" "${src}/lgsm/data" "${workdir}/lgsm/"
  13. cd "${workdir}" || exit 1
  14. result() {
  15. if [ "${1}" -eq 0 ]; then echo "✅ pass"; else echo "❌ fail"; fi
  16. }
  17. failed=()
  18. {
  19. echo "| Server | Config | Details | Parse game details | Query raw |"
  20. echo "|--------|--------|---------|--------------------|-----------|"
  21. } >> "${summary}"
  22. for shortname in "$@"; do
  23. gameserver="${shortname}server"
  24. echo "::group::${gameserver}"
  25. ./linuxgsm.sh "${gameserver}"
  26. ./"${gameserver}" developer
  27. servercfg=$(sed -n "/^\<servercfgdefault\>/ { s/.*= *\"\?\([^\"']*\)\"\?/\1/p;q }" "lgsm/config-lgsm/${gameserver}/_default.cfg")
  28. if [ -n "${servercfg}" ]; then
  29. cfgpath="${servercfg}"
  30. [[ "${cfgpath}" == \$\{*\}/* ]] && cfgpath="${cfgpath#*\}/}"
  31. curl -fsS -o "config-${shortname}" "https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/main/${shortname}/${cfgpath}"
  32. config=$?
  33. [ "${config}" -eq 0 ] && cat "config-${shortname}"
  34. configresult=$(result "${config}")
  35. else
  36. echo "This game server has no config file."
  37. config=0
  38. configresult="➖ none"
  39. fi
  40. grep "startparameters" "lgsm/config-default/config-lgsm/${gameserver}/_default.cfg"
  41. ./"${gameserver}" details
  42. details=$?
  43. ./"${gameserver}" parse-game-details
  44. parse=$?
  45. ./"${gameserver}" query-raw
  46. query=$?
  47. echo "::endgroup::"
  48. if [ "${config}" -ne 0 ] || [ "${details}" -ne 0 ] || [ "${parse}" -ne 0 ] || [ "${query}" -ne 0 ]; then
  49. failed+=("${gameserver}")
  50. echo "::error title=${gameserver}::config=${config} details=${details} parse-game-details=${parse} query-raw=${query}"
  51. fi
  52. echo "| ${gameserver} | ${configresult} | $(result "${details}") | $(result "${parse}") | $(result "${query}") |" >> "${summary}"
  53. done
  54. if [ "${#failed[@]}" -gt 0 ]; then
  55. echo -e "\n**Failed:** ${failed[*]}" >> "${summary}"
  56. exit 1
  57. fi