Skip to content

Fixup lua language server CI #29889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/problem-matchers/Lua.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
},
{
"owner": "Lua-language-server-problem-matcher",
"fileLocation": [ "relative", "${GITHUB_WORKSPACE}" ],
"pattern": [
{
"regexp": "^(.+.lua):(\\d+):(\\d+)",
"regexp": "^(.+\\.lua):(\\d+):(\\d+)(.*)$",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "^(.*)",
"message": 1
"column": 3,
"message": 4
}
]
}
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/test_scripting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ jobs:
with:
submodules: 'recursive'

- name: Register lua problem matcher
run: echo "::add-matcher::.github/problem-matchers/Lua.json"
- name: Register lua check problem matcher
run: |
echo "::add-matcher::.github/problem-matchers/Lua.json"
echo "::remove-matcher owner=Lua-language-server-problem-matcher::"

- name: Lua Linter
shell: bash
Expand All @@ -39,12 +41,22 @@ jobs:
sudo apt-get -y install lua-check
./Tools/scripts/run_luacheck.sh

- name: Register lua language server problem matcher
run: |
echo "::add-matcher::.github/problem-matchers/Lua.json"
echo "::remove-matcher owner=Luacheck-problem-matcher::"

- name: Language server check
shell: bash
run: |
python3 -m pip install github-release-downloader
python3 ./Tools/scripts/run_lua_language_check.py

- name: Remove problem matchers
run: |
echo "::remove-matcher owner=Luacheck-problem-matcher::"
echo "::remove-matcher owner=Lua-language-server-problem-matcher::"

- name: Generate docs md
shell: bash
run: |
Expand Down
58 changes: 16 additions & 42 deletions Tools/scripts/run_lua_language_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,11 @@
import sys
import os
import pathlib
import json
import shutil
import platform
from urllib.parse import unquote
import subprocess
import re


def print_failures(file_name, fails, original_name):
file_name = unquote(file_name)
file_path = pathlib.Path(file_name[5:])

if (original_name is not None) and (original_name.name == file_path.name):
file_path = original_name

for fail in fails:
start = fail['range']['start']

# These seem to be off by one, not sure why
line = start['line'] + 1
character = start['character'] + 1

print("%s:%i:%i" % (file_path, line, character))

print("\tCode: %s" % fail['code'])
message = fail['message'].split("\n")
for line in message:
print("\t%s" % line)

print()
return len(fails)


if __name__ == '__main__':

parser = optparse.OptionParser(__file__)
Expand Down Expand Up @@ -145,6 +117,22 @@ def print_failures(file_name, fails, original_name):
elif checked_files != count:
raise Exception("Checked files error expected: %i got: %i" % (checked_files, count))

# Grab the summary line to so we can error out for errors
summary = None
summary_re = re.compile(r"^Diagnosis (?:complete|completed), (\d+|no) problems found")
for line in result:
match = summary_re.search(line)
if match is not None:
summary = match

if summary is None:
raise Exception("Could not complete Diagnosis")

# Get number of errors
errors = 0
if summary.group(1) != "no":
errors = int(summary.group(1))

if tmp_check_dir is not None:
# Remove test directory
shutil.rmtree(tmp_check_dir)
Expand All @@ -153,20 +141,6 @@ def print_failures(file_name, fails, original_name):
# remove copy of docs
os.remove(docs_copy)

# Read output
errors = 0
result = (logs / "check.json").resolve()
if os.path.exists(result):
# File only created if there are errors
f = open((logs / "check.json").resolve())
data = json.load(f)
f.close()

if len(data) > 0:
# Print output if there are any errors
for key, value in data.items():
errors += print_failures(key, value, original_name)

# Remove output
shutil.rmtree(logs)

Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Scripting/applets/RockBlock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ function HLSatcom()
--- check if GCS telemetry has been lost for RCK_TIMEOUT sec (if param enabled)
if RCK_FORCEHL:get() == 2 then
-- link lost time = boot time - GCS last seen time
---@diagnostic disable-next-line cast-local-type
link_lost_for = millis():toint() - gcs:last_seen()
-- gcs:last_seen() is set to millis() during boot (on plane). 0 on rover/copter
-- So if it's less than 10000 assume no GCS packet received since boot
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Scripting/examples/MAVLinkHL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ function HLSatcom()
-- if mode 1 and there's been no mavlink traffic for 5000 ms, enable high latency
if hl_mode == 1 then
-- link lost time = boot time - GCS last seen time
---@diagnostic disable-next-line cast-local-type
link_lost_for = millis():toint() - gcs:last_seen()
-- gcs:last_seen() is set to millis() during boot (on plane). 0 on rover/copter
-- So if it's less than 10000 assume no GCS packet received since boot
Expand Down
Loading