action-details-check.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # This action will check that LinuxGSM is picking up game server config and parameter variables.
  2. name: Details Check
  3. on:
  4. workflow_dispatch:
  5. push:
  6. branches:
  7. - develop
  8. pull_request:
  9. branches:
  10. - develop
  11. permissions:
  12. contents: read
  13. concurrency:
  14. group: details-check-${{ github.ref_name }}
  15. cancel-in-progress: true
  16. env:
  17. LGSM_REF: ${{ github.event.pull_request.head.sha || github.sha }}
  18. jobs:
  19. create-matrix:
  20. if: github.repository_owner == 'GameServerManagers'
  21. runs-on: ubuntu-latest
  22. outputs:
  23. matrix: ${{ steps.set-matrix.outputs.matrix }}
  24. legacy: ${{ steps.set-matrix.outputs.legacy }}
  25. steps:
  26. - name: Checkout
  27. uses: actions/checkout@v7
  28. with:
  29. ref: ${{ env.LGSM_REF }}
  30. # Full history so the base branch ref is available for the
  31. # `git diff origin/<base>...HEAD` comparison below (a shallow
  32. # checkout has no origin/<base> and the diff fails).
  33. fetch-depth: 0
  34. - name: Detect targeted servers (PR only)
  35. id: targeted
  36. if: github.event_name == 'pull_request'
  37. run: |
  38. changed=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
  39. echo "Changed files:"
  40. echo "$changed"
  41. # Only these modules directly affect what 'details', 'parse-game-details'
  42. # and 'query-raw' output. Everything else (install, fix, update, check_*,
  43. # data CSVs, game icons, etc.) is irrelevant to this check.
  44. details_core='^(linuxgsm\.sh|lgsm/modules/(info_game|info_messages|command_details|command_dev_parse_game_details|command_dev_query_raw|core_modules)\.sh|\.github/workflows/action-details-check\.yml|\.github/scripts/details-check-.*\.sh)$'
  45. if echo "$changed" | grep -qE "${details_core}"; then
  46. echo "Details-relevant core file changed — using full matrix."
  47. echo "mode=full" >> "$GITHUB_OUTPUT"
  48. else
  49. # Extract shortnames from changed config-lgsm paths
  50. shortnames=$(echo "$changed" \
  51. | grep -oE 'lgsm/config-default/config-lgsm/[a-z0-9]+server' \
  52. | sed 's|lgsm/config-default/config-lgsm/||;s|server$||' \
  53. | sort -u)
  54. if [ -z "$shortnames" ]; then
  55. echo "No server configs or core files changed — skipping matrix."
  56. echo "mode=skip" >> "$GITHUB_OUTPUT"
  57. else
  58. echo "Targeted servers: $shortnames"
  59. echo "mode=targeted" >> "$GITHUB_OUTPUT"
  60. printf '%s\n' $shortnames > targeted_shortnames.txt
  61. fi
  62. fi
  63. - name: Generate matrix
  64. if: github.event_name != 'pull_request' || steps.targeted.outputs.mode != 'skip'
  65. run: |
  66. if [ -f targeted_shortnames.txt ]; then
  67. TARGETED_SHORTNAMES=$(cat targeted_shortnames.txt) .github/scripts/details-check-generate-matrix.sh
  68. else
  69. .github/scripts/details-check-generate-matrix.sh
  70. fi
  71. - name: Set Matrix
  72. id: set-matrix
  73. run: |
  74. if [ ! -f shards.json ]; then
  75. echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
  76. echo 'legacy=' >> "$GITHUB_OUTPUT"
  77. else
  78. cat shards.json
  79. echo "matrix=$(cat shards.json)" >> "$GITHUB_OUTPUT"
  80. echo "legacy=$(cat legacy.txt)" >> "$GITHUB_OUTPUT"
  81. fi
  82. details-check:
  83. name: details-check (${{ matrix.shard }})
  84. # Skip (rather than fail the run) when create-matrix found nothing to check.
  85. if: github.repository_owner == 'GameServerManagers' && needs.create-matrix.outputs.matrix != '{"include":[]}'
  86. needs: create-matrix
  87. continue-on-error: true
  88. runs-on: ubuntu-latest
  89. strategy:
  90. fail-fast: false
  91. matrix: ${{ fromJSON(needs.create-matrix.outputs.matrix) }}
  92. steps:
  93. - name: Checkout
  94. uses: actions/checkout@v7
  95. with:
  96. ref: ${{ env.LGSM_REF }}
  97. - name: Cache apt packages
  98. uses: actions/cache@v6
  99. with:
  100. path: /var/cache/apt/archives
  101. key: apt-${{ runner.os }}-libxml2-utils-jq
  102. - name: Install dependencies
  103. run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libxml2-utils jq
  104. - name: Details check
  105. run: .github/scripts/details-check-run.sh ${{ matrix.shortnames }}
  106. details-check-legacy:
  107. name: details-check (legacy)
  108. if: github.repository_owner == 'GameServerManagers' && needs.create-matrix.outputs.legacy != ''
  109. needs: create-matrix
  110. continue-on-error: true
  111. runs-on: ubuntu-latest
  112. container: public.ecr.aws/ubuntu/ubuntu:20.04
  113. steps:
  114. - name: Install dependencies
  115. env:
  116. DEBIAN_FRONTEND: noninteractive
  117. run: |
  118. apt-get update
  119. apt-get install -y --no-install-recommends ca-certificates curl wget git sudo iproute2 libxml2-utils jq \
  120. bc binutils bsdmainutils bzip2 cpio distro-info file gzip hostname lib32gcc-s1 lib32stdc++6 \
  121. netcat-openbsd pigz python3 tar tmux unzip util-linux uuid-runtime xz-utils
  122. - name: Checkout
  123. uses: actions/checkout@v7
  124. with:
  125. ref: ${{ env.LGSM_REF }}
  126. - name: Details check
  127. run: |
  128. useradd -m linuxgsm
  129. echo "linuxgsm ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/linuxgsm
  130. chown -R linuxgsm:linuxgsm "${GITHUB_WORKSPACE}"
  131. chmod a+w "${GITHUB_STEP_SUMMARY}"
  132. sudo -u linuxgsm -H env LGSM_REF="${LGSM_REF}" GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY}" \
  133. "${GITHUB_WORKSPACE}/.github/scripts/details-check-run.sh" ${{ needs.create-matrix.outputs.legacy }}