name: PR Prerequisites on: pull_request: branches: - main - develop env: LUA_VERSION: "5.1" LUA_LANGUAGE_SERVER_VERSION: "3.19.1" jobs: bundles_without_error: runs-on: ubuntu-latest name: Bundles Without Errors steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Lua uses: leafo/gh-actions-lua@v13 with: luaVersion: ${{ env.LUA_VERSION }} - name: Compile Spearhead uses: https://git.dutchie031.com/dutchie031/DcsMissionScriptingTools/github-action@action/v0 with: source-root: ./src output-file: ./output/spearhead.lua - name: Verify Compiled Lua Syntax run: lua -e "assert(loadfile('./output/spearhead.lua'))" - name: Set up Luarocks uses: leafo/gh-actions-luarocks@v4 - name: Install luacheck run: luarocks install luacheck - name: Lint Compiled Output run: luacheck ./output/spearhead.lua lua_check: runs-on: ubuntu-latest name: Lua Check steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Lua uses: leafo/gh-actions-lua@v13 with: luaVersion: ${{ env.LUA_VERSION }} - name: Install Dcs Plugins uses: https://git.dutchie031.com/dutchie031/DcsMissionScriptingTools/github-actions/install-lua-addon@install-lua-addon/v1 with: destination-path: "./.vscode/lua-addons" ##same as local so .luarc.json can be the same - name: Verify Dcs Plugins Installation run: ls -la ./.vscode/lua-addons - name: Install lua-language-server run: | mkdir -p ./luals # For Ubuntu/Debian wget https://github.com/LuaLS/lua-language-server/releases/download/${{ env.LUA_LANGUAGE_SERVER_VERSION }}/lua-language-server-${{ env.LUA_LANGUAGE_SERVER_VERSION }}-linux-x64.tar.gz tar -xzf lua-language-server-*.tar.gz -C ./luals rm lua-language-server-*.tar.gz - name: Verify Lua Language Server Installation run: ./luals/bin/lua-language-server --version - name: Resolve Addon Paths And Update Config run: | ADDONS_PATH=$(realpath ./.vscode/lua-addons) ADDON_ROOT=$(find "$ADDONS_PATH" -mindepth 1 -maxdepth 1 -type d | head -n 1) LIBRARY_PATH="$ADDON_ROOT/library" echo "addons-path: $ADDONS_PATH" echo "addon-root: $ADDON_ROOT" echo "library-path: $LIBRARY_PATH" test -d "$ADDON_ROOT" test -d "$LIBRARY_PATH" test -f "$LIBRARY_PATH/DcsTypes.lua" jq \ --arg addons_path "$ADDONS_PATH" \ --arg addon_root "$ADDON_ROOT" \ --arg library_path "$LIBRARY_PATH" \ '.Lua.workspace.library = [$library_path, $addon_root] | .Lua.workspace.userThirdParty = [$addons_path]' \ ./.luarc.json > ./.luarc.json.tmp && mv ./.luarc.json.tmp ./.luarc.json - name: Show Config run: cat ./.luarc.json - name: LuaLS Smoke Test For Addon Globals run: | cat > ./_luals_smoke_test.lua << 'EOF' local now = timer.getTime() local base = Airbase.getByName("TEST") local side = coalition.side.RED return now, base, side EOF set -o pipefail echo "=== smoke(root) ===" ./luals/bin/lua-language-server --check ./_luals_smoke_test.lua --checklevel=Warning --configpath ./.luarc.json 2>&1 | tee ./_luals_smoke_root.log if grep -q "undefined-global" ./_luals_smoke_root.log; then echo "Root smoke test reported undefined-global" exit 1 fi rm -f ./_luals_smoke_test.lua - name: Run Lua Language Server run: | set -euo pipefail echo "Checking Lua files one-by-one to keep addon globals resolution consistent" while IFS= read -r -d '' file; do echo "Checking $file" ./luals/bin/lua-language-server --check "$file" --checklevel=Warning --configpath ./.luarc.json done < <(find ./src -type f -name '*.lua' -print0)