Skip to content
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
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
test:
name: Lua ${{ matrix.lua }}
runs-on: ubuntu-latest
env:
LUAROCKS_TREE: ${{ github.workspace }}/.luarocks
strategy:
fail-fast: false
matrix:
Expand All @@ -19,26 +21,32 @@ jobs:
uses: actions/checkout@v4

- name: Set up Lua
uses: leafo/gh-actions-lua@v11
uses: leafo/gh-actions-lua@v13
with:
luaVersion: ${{ matrix.lua }}

- name: Set up LuaRocks
uses: leafo/gh-actions-luarocks@v5
uses: leafo/gh-actions-luarocks@v6
with:
withLuaPath: ${{ github.workspace }}/.lua

- name: Install dependencies
run: |
luarocks install luasocket
luarocks install lua-cjson
luarocks install dkjson
luarocks install luasec
luarocks --tree="$LUAROCKS_TREE" install luasocket
luarocks --tree="$LUAROCKS_TREE" install lua-cjson
luarocks --tree="$LUAROCKS_TREE" install dkjson
luarocks --tree="$LUAROCKS_TREE" install luasec

- name: Verify JSON dependencies
- name: Verify dependencies
run: |
eval "$(luarocks --tree="$LUAROCKS_TREE" path)"
luarocks --tree="$LUAROCKS_TREE" show luasocket
lua -e "assert(require('socket.http'))"
lua -e "assert(require('dkjson'))"
lua -e "assert(require('cjson.safe'))"

- name: Run tests
run: |
eval "$(luarocks --tree="$LUAROCKS_TREE" path)"
make test
make integration
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
LUA ?= lua
LUA_PATH := ./lua/?.lua;./lua/?/init.lua;;
# Keep the project sources first, then expose pure-Lua dependencies from the
# active LuaRocks tree. This is evaluated by make because its exported
# LUA_PATH overrides any value set by a calling shell.
LUAROCKS_PATH_ARGS := $(if $(strip $(LUAROCKS_TREE)),--tree="$(LUAROCKS_TREE)")
LUAROCKS_LUA_PATH := $(shell luarocks $(LUAROCKS_PATH_ARGS) path --lr-path 2>/dev/null)
LUA_PATH := ./lua/?.lua;./lua/?/init.lua;$(LUAROCKS_LUA_PATH);;
export LUA_PATH

.PHONY: test examples examples-local integration check zip servers server-http server-sse server-streamable server-tcp server-udp server-graphql server-mcp \
Expand Down
5 changes: 4 additions & 1 deletion lua/utcp/transports/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ local function socket_http()
if cached_http then return cached_http, cached_ltn12 end
if socket_error then return nil, socket_error end
local ok, http = pcall(require, 'socket.http')
if not ok then socket_error = 'lua-socket is required'; return nil, socket_error end
if not ok then
socket_error = 'lua-socket is required: ' .. tostring(http)
return nil, socket_error
end
local ok2, ltn12 = pcall(require, 'ltn12')
if not ok2 then socket_error = 'ltn12 is required'; return nil, socket_error end
cached_http, cached_ltn12 = http, ltn12
Expand Down
Loading