Files
factorio-scenario-ExpCluster/.github/workflows/fmtk.yml
T
817069fbad Bump LuaLS to 3.18.2 in lint workflow (#422)
LuaLS 3.15.0 stack overflows in the cast-type-mismatch diagnostic while
resolving the recursive Commands.Status and Async.Status function type
aliases (functions whose return type is themselves). 3.18.2, the latest
release, resolves these correctly and runs the repository clean.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 23:12:04 +01:00

75 lines
3.1 KiB
YAML

name: FMTK Lint
on:
push:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install FMTK
run: |
pnpm install factoriomod-debug
pnpm exec fmtk luals-addon
jq '.["workspace.library"] += ["${{ github.workspace }}/factorio/library"] | .["runtime.plugin"] = "${{ github.workspace }}/factorio/plugin.lua"' .luarc.json > temp.luarc.json
jq -s '.[0] * .[1].settings' temp.luarc.json ${{ github.workspace }}/factorio/config.json > check.luarc.json
- name: Install LuaLS
run: |
wget https://github.com/LuaLS/lua-language-server/releases/download/3.18.2/lua-language-server-3.18.2-linux-x64.tar.gz -q -O lusls.tar.gz
mkdir luals && tar -xf lusls.tar.gz -C luals && rm lusls.tar.gz
- name: Run Lint Report
shell: bash
run: |
./luals/bin/lua-language-server --check=. --logpath=. --configpath=check.luarc.json --checklevel=Information --check_out_path=check.json
# Credit to https://github.com/Krealle/luals-check-action/blob/main/action.yml
# Although some minor fixes were needed
# Format and print the messages (would be nice to format as a table, but that's too complex for jq)
cat check.json | \
jq -r \
'to_entries | map(.key as $file | .value[] |
{
file: $file | sub("file://${{ github.workspace }}/./"; ""),
code: .code,
line: .range.start.line,
message: (.message | split("\n")
| map(if startswith("- ") then .[2:] else . end)
| join("\n")),
severity: (if .severity <= 1 then "ERR" else "WARN" end)
}) |
map("**[\(.severity)] \(.code):** \(.file)#L\(.line)<br><code>\(.message)</code>") | .[]' \
> $GITHUB_STEP_SUMMARY
echo ""
# Github Annotations (limited to 10)
cat check.json | \
jq -r \
'to_entries | map(.key as $file | .value[] |
{
file: $file | sub("file://${{ github.workspace }}/./"; ""),
title: .code,
line: .range.start.line,
endLine: .range.end.line,
col: .range.start.character,
endColumn: .range.end.character,
message: .message | gsub("\n"; "%0A"; "m"),
level: (if .severity <= 1 then "error" else "warning" end)
}) |
map("::\(.level) file=\(.file),line=\(.line+1),endLine=\(.line+1),col=\(.col+1),endColumn=\(.endColumn+1),title=\(.title)::\(.message) (\(.title))") | .[]'
if [[ $(wc -l < check.json) > 1 ]] ; then
exit 1
else
echo "✅ All checks succeeded!" | tee $GITHUB_STEP_SUMMARY
fi