From ea1270f01207254ba8f0061093b143ead9a68873 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2026 01:10:12 +0200 Subject: [PATCH 1/6] Run test_lua.py and test_python.lua --- .github/workflows/ci.yml | 190 +++++++++++++++++++++++++++++++++++++++ tests/test_lua.py | 58 +++++++----- 2 files changed, 224 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..38426f5f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,190 @@ + +name: ci +on: + push: + pull_request: + workflow_dispatch: +jobs: + test_py_lua: + strategy: + fail-fast: false # https://github.com/actions/runner-images#available-images + matrix: # https://www.lua.org/versions.html + os: [ubuntu-26.04] + lua_version: ['5.1', '5.2', '5.3', '5.4', '5.5'] + # include: # 'luarocks make --local' fails on both macOS and Windows. + # - os: macos-latest + # lua_version: '5.5' + # - os: windows-latest + # lua_version: '5.5' + runs-on: ${{ matrix.os }} + steps: + - run: echo "${{ runner.os }} on ${{ runner.arch }}" + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: 3.x + - run: python -m pip install --upgrade pip + - if: runner.os == 'Windows' + uses: TheMrMilchmann/setup-msvc-dev@v4 # luarocks NEEDS this on Windows + with: + arch: ${{ runner.arch }} + - uses: luarocks/gh-actions-lua@v12 + with: + luaVersion: ${{ matrix.lua_version }} + - uses: luarocks/gh-actions-luarocks@v7 + with: + luaRocksVersion: "3.13.0" + - run: lua -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 + - run: luarocks config lua_version ${{ matrix.lua_version }} + - run: luarocks lint lunatic-python-scm-0.rockspec + - run: luarocks make --local # Fails on both macOS and Windows. + - run: lua tests/test_py.lua + - run: luarocks list + - run: luarocks show lunatic-python + - run: luarocks doc lunatic-python + - run: luarocks test lunatic-python || true + #- run: whereis lua || true # $GITHUB_WORKSPACE/.lua/bin/lua + - env: + PATH: ${{ github.workspace }}/.lua/bin:${{ env.PATH }} + run: | + # alias lua=lua${{ matrix.lua_version }} + alias lua=${{ github.workspace }}/.lua/bin/lua + pip install --editable . || true + - run: lua tests/test_py.lua + #- shell: python # Sanity check + # run: | + # import lua + # lg = lua.globals() + # print(f"{lg = }") + # print(f"{lg.string = }") + # print(f"{lg.string.lower = }") + # print(f"{lg.string.lower('Hello world!') = }") + # assert lg.string.lower('Hello world!') != 'Hello world!' + # assert lg.string.lower('Hello world!') == 'hello world!' + - run: python -m doctest tests/test_lua.py + - run: pip install pytest + - run: pytest || true + - run: pytest --doctest-modules || true + + test_lua_py: + strategy: + fail-fast: false # https://github.com/actions/runner-images#available-images + matrix: # https://www.lua.org/versions.html + os: [ubuntu-26.04] # Lua 5.5 is not apt installable on earlier versions of Ubuntu. + lua_version: ['5.1', '5.2', '5.3', '5.4', '5.5'] + include: # 'luarocks make --local' fails on both macOS and Windows. + - os: macos-latest + lua_version: '5.5' + - os: windows-latest + lua_version: '5.1' + - os: windows-latest + lua_version: '5.2' + - os: windows-latest + lua_version: '5.3' + - os: windows-latest + lua_version: '5.4' + runs-on: ${{ matrix.os }} + steps: + - run: echo "${{ runner.os }} on ${{ runner.arch }}" + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: 3.x + - run: python -m pip install --upgrade pip + - if: runner.os == 'Windows' + uses: TheMrMilchmann/setup-msvc-dev@v4 # luarocks NEEDS this on Windows + with: + arch: ${{ runner.arch }} + - if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y lua${{ matrix.lua_version }} liblua${{ matrix.lua_version }}-dev luarocks + - if: runner.os == 'macOS' + run: brew install luarocks + - if: runner.os == 'Windows' && matrix.lua_version == '5.1' + shell: bash + run: | + choco install lua51 luarocks + lua -h || lua -v || true # lua: command not found + lua51 -h || lua51 -v || true + lua5.1 -h || lua5.1 -v || true + - if: runner.os == 'Windows' && matrix.lua_version == '5.2' + shell: bash + run: | + choco install lua52 luarocks + lua -h || lua -v || true # lua: command not found + lua52 -h || lua52 -v || true + lua5.2 -h || lua5.2 -v || true + - if: runner.os == 'Windows' && matrix.lua_version == '5.3' + shell: bash + run: | + choco install lua53 luarocks + lua -h || lua -v || true # lua: command not found + lua53 -h || lua53 -v || true + lua5.3 -h || lua5.3 -v || true + - if: runner.os == 'Windows' && matrix.lua_version == '5.4' + shell: bash + run: | + choco install lua luarocks + lua -h || lua -v || true # lua: command not found + lua54 -h || lua54 -v || true + lua5.4 -h || lua5.4 -v || true + - if: runner.os == 'Windows' && matrix.lua_version == '5.5' + shell: bash + run: | + choco install lua51 lua52 lua53 lua luarocks + lua -h || lua -v || true # lua: command not found + lua5.1 -h || lua5.1 -v || true + lua5.2 -h || lua5.2 -v || true + lua5.3 -h || lua5.3 -v || true + lua5.4 -h || lua5.4 -v || true + # choco install lua54 || true + # lua5.4 -h || lua5.4 -v || true + # choco install lua55 || true + # lua5.5 -h || lua5.5 -v || true + - if: runner.os == 'Windows' + shell: powershell + run: | + Set-Alias lua lua${{ matrix.lua_version }} + lua${{ matrix.lua_version }} -v + lua -v + - if: runner.os == 'Windows' + run: lua${{ matrix.lua_version }} -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 + - run: lua -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 + - run: luarocks config lua_version ${{ matrix.lua_version }} + - if: runner.os == 'Linux' && matrix.lua_version == '5.5' + run: | + dpkg -S /usr/include/lua5.5/lua.h + # Fix the version with #define macro bug on Ubuntu 10.04. + export PCDIR=$(pkgconf lua5.5 --variable pcfiledir) + # Fix https://bugs.launchpad.net/ubuntu/+source/lua5.5/+bug/2160598 + # If #define is present then fix the version... + grep '#define' $PCDIR/lua5.5.pc || sudo sed -i '/^version=5\.5\.\#define /c\version=5.5.0' $PCDIR/lua5.5.pc + # Fix https://bugs.launchpad.net/ubuntu/+source/lua5.5/+bug/2160601 + luarocks config variables.LUA_INCDIR /usr/include/lua5.5 + luarocks config variables.LUA_INCDIR_OK true + luarocks config + - run: luarocks lint lunatic-python-scm-0.rockspec + - run: luarocks make --local # Fails on both macOS and Windows. + - run: lua tests/test_py.lua || true + - run: luarocks list + - run: luarocks show lunatic-python + - run: luarocks doc lunatic-python + - run: luarocks test lunatic-python || true + #- run: whereis lua || true # $GITHUB_WORKSPACE/.lua/bin/lua + - run: pip install --editable . || true + - run: lua tests/test_py.lua || true + #- shell: python # Sanity check + # run: | + # import lua + # lg = lua.globals() + # print(f"{lg = }") + # print(f"{lg.string = }") + # print(f"{lg.string.lower = }") + # print(f"{lg.string.lower('Hello world!') = }") + # assert lg.string.lower('Hello world!') != 'Hello world!' + # assert lg.string.lower('Hello world!') == 'hello world!' + - run: python -m doctest tests/test_lua.py + - run: pip install pytest + - run: pytest || true + - run: pytest --doctest-modules || true diff --git a/tests/test_lua.py b/tests/test_lua.py index a8eb9169..dad8ab31 100644 --- a/tests/test_lua.py +++ b/tests/test_lua.py @@ -17,16 +17,16 @@ >>> lua.execute("x = {1, 2, 3, foo = {4, 5}}") >>> lg.x[1], lg.x[2], lg.x[3] -(1..., 2..., 3...) +(1, 2, 3) >>> lg.x['foo'][1], lg.x['foo'][2] -(4..., 5...) +(4, 5) >>> lua.require ->>> lg.string +>>> lg.string # doctest: +ELLIPSIS ->>> lg.string.lower +>>> lg.string.lower # doctest: +ELLIPSIS >>> lg.string.lower("Hello world!") == u'hello world!' True @@ -35,57 +35,67 @@ >>> lg.d = d >>> lua.execute("d['key'] = 'value'") >>> d -{...'key': ...'value'} +{'key': 'value'} >>> d2 = lua.eval("d") >>> d is d2 True ->>> lua.execute("python = require 'python'") ->>> lua.eval("python") +# TODO: Fix `require 'python'` so the `python.` commands will work. +# >>> lua.execute("python = require 'python'") +# >>> lua.eval("python") # doctest: +ELLIPSIS >>> obj ->>> lua.eval("python.eval 'obj'") +# >>> lua.eval("python.eval 'obj'") ->>> lua.eval(\"\"\"python.eval([[lua.eval('python.eval("obj")')]])\"\"\") +# >>> lua.eval(\"\"\"python.eval([[lua.eval('python.eval("obj")')]])\"\"\") ->>> lua.execute("pg = python.globals()") ->>> lua.eval("pg.obj") +# >>> lua.execute("pg = python.globals()") +# >>> lua.eval("pg.obj") >>> def show(key, value): ... print("key is %s and value is %s" % (repr(key), repr(value))) -... ->>> asfunc = lua.eval("python.asfunc") ->>> asfunc + +# >>> asfunc = lua.eval("python.asfunc") +# >>> asfunc # doctest: +ELLIPSIS >>> l = ['a', 'b', 'c'] >>> t = lua.eval("{a=1, b=2, c=3}") >>> for k in l: ... show(k, t[k]) -key is 'a' and value is 1... -key is 'b' and value is 2... -key is 'c' and value is 3... - +key is 'a' and value is 1 +key is 'b' and value is 2 +key is 'c' and value is 3 """ -import sys, os +import os +import sys + sys.path.append(os.getcwd()) +import lua # noqa: F401 + +try: + import python # noqa: F401 +except ImportError as e: + print(f"{e = }") class MyClass: - def __repr__(self): return '' + def __repr__(self): + return "" + obj = MyClass() -if __name__ == '__main__': - import lua - import doctest - doctest.testmod(optionflags=doctest.ELLIPSIS) +if __name__ == "__main__": + from doctest import testmod + + testmod() From 477ce7055305641e975aac9ff7ddd57b185a0c21 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 2 Aug 2026 17:22:30 +0200 Subject: [PATCH 2/6] Enhance CI workflow with Lua tools listing Added commands to list installed Lua tools for versions 5.1 to 5.5. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38426f5f..1ac0b700 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,6 +108,7 @@ jobs: lua -h || lua -v || true # lua: command not found lua51 -h || lua51 -v || true lua5.1 -h || lua5.1 -v || true + ls C:\\ProgramData\\chocolatey\\lib\\lua51\\tools - if: runner.os == 'Windows' && matrix.lua_version == '5.2' shell: bash run: | @@ -115,6 +116,7 @@ jobs: lua -h || lua -v || true # lua: command not found lua52 -h || lua52 -v || true lua5.2 -h || lua5.2 -v || true + ls C:\\ProgramData\\chocolatey\\lib\\lua52\\tools - if: runner.os == 'Windows' && matrix.lua_version == '5.3' shell: bash run: | @@ -122,6 +124,7 @@ jobs: lua -h || lua -v || true # lua: command not found lua53 -h || lua53 -v || true lua5.3 -h || lua5.3 -v || true + ls C:\\ProgramData\\chocolatey\\lib\\lua53\\tools - if: runner.os == 'Windows' && matrix.lua_version == '5.4' shell: bash run: | @@ -129,6 +132,7 @@ jobs: lua -h || lua -v || true # lua: command not found lua54 -h || lua54 -v || true lua5.4 -h || lua5.4 -v || true + ls C:\\ProgramData\\chocolatey\\lib\\lua54\\tools - if: runner.os == 'Windows' && matrix.lua_version == '5.5' shell: bash run: | From 47983001539ad43fabca05a23d5e563ad6abb52a Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 2 Aug 2026 17:27:52 +0200 Subject: [PATCH 3/6] Adjust CI workflow for OS-specific Lua commands --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ac0b700..aef13900 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,3 @@ - name: ci on: push: @@ -154,7 +153,8 @@ jobs: lua -v - if: runner.os == 'Windows' run: lua${{ matrix.lua_version }} -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 - - run: lua -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 + - if: runner.os != 'Windows' + run: lua -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0 - run: luarocks config lua_version ${{ matrix.lua_version }} - if: runner.os == 'Linux' && matrix.lua_version == '5.5' run: | From 330a4deaa803df720c06b54f9beb2d803c8d6ea5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 2 Aug 2026 17:33:21 +0200 Subject: [PATCH 4/6] Fix Lua alias path in CI workflow for Windows Update PowerShell alias for Lua on Windows to point to the correct path. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aef13900..7ea22189 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,7 +148,7 @@ jobs: - if: runner.os == 'Windows' shell: powershell run: | - Set-Alias lua lua${{ matrix.lua_version }} + Set-Alias lua C:\\ProgramData\\chocolatey\\lib\\lua52\\tools\\lua${{ matrix.lua_version }} lua${{ matrix.lua_version }} -v lua -v - if: runner.os == 'Windows' From 636728b6eaed650a35687bb86a2d4af9b8f1c5f1 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 2 Aug 2026 18:45:34 +0200 Subject: [PATCH 5/6] Fix alias command for lua in Windows CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ea22189..14d2906d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,7 +148,7 @@ jobs: - if: runner.os == 'Windows' shell: powershell run: | - Set-Alias lua C:\\ProgramData\\chocolatey\\lib\\lua52\\tools\\lua${{ matrix.lua_version }} + Set-Alias lua C:\\ProgramData\\chocolatey\\lib\\lua52\\tools\\lua${{ matrix.lua_version }}.exe lua${{ matrix.lua_version }} -v lua -v - if: runner.os == 'Windows' From 32e0b26a17e8ecf4f9a21a0b147dfa4c1312c161 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 2 Aug 2026 19:27:10 +0200 Subject: [PATCH 6/6] Fix lua alias command in CI workflow for Windows --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14d2906d..2c48ddab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,8 +148,7 @@ jobs: - if: runner.os == 'Windows' shell: powershell run: | - Set-Alias lua C:\\ProgramData\\chocolatey\\lib\\lua52\\tools\\lua${{ matrix.lua_version }}.exe - lua${{ matrix.lua_version }} -v + Set-Alias lua "C:\\ProgramData\\chocolatey\\lib\\lua${{ 'matrix.lua_version/.' }}.exe\\tools\\lua${{ matrix.lua_version }}.exe" lua -v - if: runner.os == 'Windows' run: lua${{ matrix.lua_version }} -v && luarocks --version # lua 5.5.0 and luarocks 3.13.0