Skip to content

Commit

Permalink
ci(binding/lua): add luarocks package manager support (#2558)
Browse files Browse the repository at this point in the history
* chore(binding/lua): add luarocks package manager support

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): change readme

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): fix code

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): fix code

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): change lua module name to lopendal

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): fix code

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): fix code

Signed-off-by: owl <ouyangjun1999@gmail.com>

* chore(binding/lua): fix code

Signed-off-by: owl <ouyangjun1999@gmail.com>

---------

Signed-off-by: owl <ouyangjun1999@gmail.com>
  • Loading branch information
oowl committed Jun 30, 2023
1 parent 1deb087 commit 6d8aa3a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/bindings_lua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ jobs:
- name: Setup lua toolchain
run: |
sudo apt-get update
sudo apt-get install -y lua-busted
sudo apt-get install -y lua-busted luarocks liblua5.2-dev
- name: Setup Rust toolchain
uses: ./.github/actions/setup
- name: Build & Test
working-directory: "bindings/lua"
run: |
cargo build
mv ../../target/debug/libopendal_lua.so opendal.so
sudo "PATH=$PATH" luarocks make
busted test/opendal_test.lua
28 changes: 4 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion bindings/lua/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[features]
default = ["mlua/lua52"]
lua52 = ["mlua", "mlua/lua52"]

[lib]
crate-type = ["cdylib"]

[dependencies]
mlua = { version = "0.8", features = ["lua52", "vendored", "module"] }
mlua = { version = "0.8", features = ["module"], default-features = false, optional = true }
opendal.workspace = true

7 changes: 6 additions & 1 deletion bindings/lua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ print("read: ", op:read("test.txt"))
## Lua version
You have to enable one of the features: lua54, lua53, lua52, lua51, luajit(52) or luau in `Cargo.toml`, according to the chosen Lua version. Default Lua version is 5.2.

## Build
## Build from source

1. Build OpenDAL LUA Interface

Expand All @@ -35,6 +35,11 @@ $ cargo build --package opendal-lua --release
$ cp ../../target/release/libopendal_lua.so /usr/lib/lua/5.2/opendal.so
```

## Install from luarocks
```bash
$ luarocks make
```

## Usage
```bash
$ lua5.2 example/fs.lua
Expand Down
28 changes: 28 additions & 0 deletions bindings/lua/opendal-0.1.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package = "opendal"
version = "0.1.0-1"

source = {
url = "git+https://github.com/apache/incubator-opendal/",
}

description = {
summary = "Apache OpenDAL LUA binding: access data freely. ",
detailed = [[
OpenDAL is a data access layer that allows users to easily and efficiently retrieve data from various storage services in a unified way.
]],
homepage = "https://opendal.apache.org/",
license = " Apache-2.0"
}

dependencies = {
"lua >= 5.1",
"luarocks-build-rust-mlua",
}

build = {
type = "rust-mlua",
modules = {
["opendal"] = "opendal_lua",
},
target_path = "../../target",
}
6 changes: 2 additions & 4 deletions bindings/lua/test/opendal_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
]]

local opendal = require("opendal")

describe("opendal unit test", function()
describe("opendal fs schema", function()
it("operator function in fs schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("fs",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
Expand All @@ -41,7 +42,6 @@ describe("opendal unit test", function()
assert.equal(op:is_exist("test_1.txt"), false)
end)
it("meta function in fs schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("fs",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
Expand All @@ -60,7 +60,6 @@ describe("opendal unit test", function()
end)
describe("opendal memory schema", function()
it("operator function in memory schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("memory",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
Expand All @@ -75,7 +74,6 @@ describe("opendal unit test", function()
assert.equal(op:is_exist("test_1.txt"), false)
end)
it("meta function in memory schema", function()
local opendal = require("opendal")
local op, err = opendal.operator.new("memory",{root="/tmp"})
assert.is_nil(err)
assert.is_nil(op:write("test.txt","hello world"))
Expand Down

0 comments on commit 6d8aa3a

Please sign in to comment.