Skip to content

.github: Run luacheck v1.2.0 in CI#32755

Closed
cclauss wants to merge 1 commit into
ArduPilot:masterfrom
cclauss:patch-7
Closed

.github: Run luacheck v1.2.0 in CI#32755
cclauss wants to merge 1 commit into
ArduPilot:masterfrom
cclauss:patch-7

Conversation

@cclauss

@cclauss cclauss commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Run luacheck in GitHub Actions CI.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

Total: 12812 warnings / 0 errors in 256 files

As discussed below, we already run an old version of luacheck in GitHub Actions, which finds no issues.

Ubuntu Luacheck
22.04 LTS v0.25.0
24.04 LTS v1.1.2
26.04 LTS v1.2.0

The GitHub Action from the luacheck team enables us to run the current version, which raises 12k+ warnings.

With the .luacheckrc file:

Total: 0 warnings / 0 errors in 256 files

@IamPete1

Copy link
Copy Markdown
Member

@cclauss We already run lua check in CI.

- 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
run: |
sudo apt-get update
sudo apt-get -y install lua-check
./Tools/scripts/run_luacheck.sh

Were just not getting the latest version for some reason.

@cclauss cclauss closed this Apr 13, 2026
@cclauss

cclauss commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

runs-on: ubuntu-22.04

Should probably at least be ubuntu-latest

Ubuntu Luacheck
22.04 LTS v0.25.0
24.04 LTS v1.1.2
26.04 LTS v1.2.0

Ubuntu 22.04.5 LTS
Luacheck: 0.25.0
Lua: PUC-Rio Lua 5.1
Argparse: 0.6.0
LuaFileSystem: 1.8.0
LuaLanes: Not found

Ubuntu 24.04.4 LTS
Luacheck: 1.1.2
Lua: PUC-Rio Lua 5.1
Argparse: 0.7.1
LuaFileSystem: 1.8.0
LuaLanes: Not found

Ubuntu Resolute Raccoon (development branch)
Luacheck: 1.2.0
Lua: PUC-Rio Lua 5.1
Argparse: 0.7.1
LuaFileSystem: 1.9.0
LuaLanes: Not found

The GitHub Action - uses: lunarmodules/luacheck@v1 pulls in a Docker container with the current version.

@IamPete1

Copy link
Copy Markdown
Member

All of CI is on 22.04, I'm not really qualified to say if we should change over or not.

@cclauss

cclauss commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Total: 12812 warnings / 0 errors in 256 files

We need a .luacheckrc file to ignore those warnings.

@cclauss cclauss reopened this Apr 13, 2026
@cclauss cclauss changed the title .github: Run luacheck in CI .github: Run luacheck v1.2.0 in CI Apr 13, 2026
@IamPete1

Copy link
Copy Markdown
Member

We need a .luacheckrc file to ignore those warnings.

We do have one already, https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Scripting/tests/luacheck.lua

All it needs to run the latest version of luacheck in the existing check. We don't need to re-invent the wheel.

@cclauss

cclauss commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

Excellent! We could add the Docker image inside the GitHub Action to get the current version. Closing.

@cclauss cclauss closed this Apr 13, 2026
@cclauss cclauss deleted the patch-7 branch April 13, 2026 01:19
@cclauss

cclauss commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

https://github.com/search?q=repo:ArduPilot/ardupilot+setfenv

assert(pcall(setfenv(assert(loadfile("libraries/AP_Scripting/docs/docs.lua")), env)))

But setfenv was removed in Lua >= v5.2 which is causing luacheck v1.2.0 to fail.

@IamPete1

IamPete1 commented Apr 13, 2026

Copy link
Copy Markdown
Member

But setfenv was removed in Lua >= v5.2 which is causing luacheck v1.2.0 to fail.

I knew that was going to happen eventually. I was hoping we could run latest luacheck on older lua.

I suspect its possible to do it some other way, reading the docs file directly worked quite well but it maybe that we need to generate a config directly when we generate the bindings or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants