diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..738cff3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,76 @@ +name: Test + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + lua-version: + - 5.1 + - 5.2 + - 5.3 + - 5.4 + - 5.5 + - luajit + - openresty + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Lua and LuaRocks + uses: luau-project/setup-lua@8f6d85e7d2cb9cdc47188dce050f05143ab7a8e6 # v1.1.1 + with: + lua-version: ${{ matrix.lua-version }} + + - name: Print Lua version + run: lua -v + + - name: Print LuaRocks version + run: luarocks --version + + - name: Print LuaRocks config + run: luarocks config + + - name: Install ljsyscall (Unix) + if: ${{ runner.os != 'Windows' && (matrix.lua-version == 'luajit' || matrix.lua-version == 'openresty') }} + run: luarocks install ljsyscall + + - name: Install LuaFileSystem + run: luarocks install luafilesystem + + - name: Install lunitx + run: luarocks install lunitx + + - name: Install LuaCov + run: luarocks install luacov + + - name: Install lua-path using the development rockspec + run: luarocks make "rockspecs/lua-path-scm-0.rockspec" + + - name: Run tests (Windows) + if: ${{ runner.os == 'Windows' }} + working-directory: test + run: | + lua run.lua + lua -lluacov test_lfs.lua + + - name: Run tests (Unix) + if: ${{ runner.os != 'Windows' }} + working-directory: test + run: | + lunit.sh run.lua + lua -lluacov test_lfs.lua + + - name: Install LuaCov-coveralls + run: luarocks install luacov-coveralls + + - name: Upload coverage report + working-directory: test + run: luacov-coveralls -t "${{ secrets.GITHUB_TOKEN }}" diff --git a/README.md b/README.md index c8ff54d..9f727b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # lua-path [![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENCE.txt) +[![Test](https://github.com/moteus/lua-path/actions/workflows/test.yml/badge.svg)](https://github.com/moteus/lua-path/actions/workflows/test.yml) [![Build Status](https://travis-ci.org/moteus/lua-path.png?branch=master)](https://travis-ci.org/moteus/lua-path) [![Build Status](https://ci.appveyor.com/api/projects/status/okrhcb519rldjhn4?svg=true)](https://ci.appveyor.com/project/moteus/lua-path) [![Coverage Status](https://coveralls.io/repos/moteus/lua-path/badge.png)](https://coveralls.io/r/moteus/lua-path) diff --git a/rockspecs/lua-path-0.3.1-3.rockspec b/rockspecs/lua-path-0.3.1-3.rockspec new file mode 100644 index 0000000..b761fc6 --- /dev/null +++ b/rockspecs/lua-path-0.3.1-3.rockspec @@ -0,0 +1,47 @@ +package = "lua-path" +version = "0.3.1-3" +source = { + url = "https://github.com/moteus/lua-path/archive/v0.3.1.zip", + dir = "lua-path-0.3.1", +} + +description = { + summary = "File system path manipulation library", + detailed = [[ + ]], + homepage = "https://github.com/moteus/lua-path", + license = "MIT/X11", +} + +dependencies = { + "lua >= 5.1, < 5.6", + -- "luafilesystem >= 1.4", + -- "alien >= 0.7.0", -- instead lfs on windows +} + +build = { + type = "builtin", + copy_directories = { + "doc", + "examples", + "test", + }, + modules = { + ["path" ] = "lua/path.lua", + ["path.fs" ] = "lua/path/fs.lua", + ["path.findfile" ] = "lua/path/findfile.lua", + ["path.lfs.fs" ] = "lua/path/lfs/fs.lua", + ["path.syscall.fs" ] = "lua/path/syscall/fs.lua", + ["path.lfs.impl.fs" ] = "lua/path/lfs/impl/fs.lua", + ["path.module" ] = "lua/path/module.lua", + ["path.win32.alien.fs" ] = "lua/path/win32/alien/fs.lua", + ["path.win32.alien.types" ] = "lua/path/win32/alien/types.lua", + ["path.win32.alien.utils" ] = "lua/path/win32/alien/utils.lua", + ["path.win32.alien.wcs" ] = "lua/path/win32/alien/wcs.lua", + ["path.win32.ffi.fs" ] = "lua/path/win32/ffi/fs.lua", + ["path.win32.ffi.types" ] = "lua/path/win32/ffi/types.lua", + ["path.win32.ffi.wcs" ] = "lua/path/win32/ffi/wcs.lua", + ["path.win32.fs" ] = "lua/path/win32/fs.lua", + ["path.win32.wcs" ] = "lua/path/win32/wcs.lua", + } +} diff --git a/rockspecs/lua-path-scm-0.rockspec b/rockspecs/lua-path-scm-0.rockspec index 6d67610..88c4ccf 100644 --- a/rockspecs/lua-path-scm-0.rockspec +++ b/rockspecs/lua-path-scm-0.rockspec @@ -14,7 +14,7 @@ description = { } dependencies = { - "lua >= 5.1, < 5.5", + "lua >= 5.1, < 5.6", -- "luafilesystem >= 1.4", -- "alien >= 0.7.0", -- instead lfs on windows } diff --git a/test/test.lua b/test/test.lua index e3ac3a8..5a00de2 100644 --- a/test/test.lua +++ b/test/test.lua @@ -350,7 +350,8 @@ function test_findfile() assert_nil(next(params)) params = clone(files) - for f in path.each("./1/2/3/*.*") do + for file in path.each("./1/2/3/*.*") do + local f = file f = up(f) assert_not_nil(params[f], "unexpected: " .. f) params[f] = nil @@ -377,7 +378,8 @@ function test_findfile() assert_nil(next(params)) params = clone(files) - for f, sz in path.each("./1/2/3/*.*", "fz") do + for file, sz in path.each("./1/2/3/*.*", "fz") do + local f = file f = up(f) assert_not_nil(params[f], "unexpected: " .. f) assert_equal(5, sz) @@ -926,4 +928,4 @@ end end -if not LUNIT_RUN then lunit.run() end \ No newline at end of file +if not LUNIT_RUN then lunit.run() end diff --git a/test/test_each.lua b/test/test_each.lua index d97ff58..be6b804 100644 --- a/test/test_each.lua +++ b/test/test_each.lua @@ -115,7 +115,8 @@ function test_findfile() assert_nil(next(params)) params = clone(files) - for f in path_each("./1/2/3/*.*") do + for file in path_each("./1/2/3/*.*") do + local f = file f = up(f) assert_not_nil(params[f], "unexpected: " .. f) params[f] = nil @@ -142,7 +143,8 @@ function test_findfile() assert_nil(next(params)) params = clone(files) - for f, sz in path_each("./1/2/3/*.*", "fz") do + for file, sz in path_each("./1/2/3/*.*", "fz") do + local f = file f = up(f) assert_not_nil(params[f], "unexpected: " .. f) assert_equal(5, sz) @@ -219,4 +221,4 @@ elseif not prequire"path.syscall.fs" then test = SKIP_CASE"syscall module not fo }) end -if not LUNIT_RUN then lunit.run() end \ No newline at end of file +if not LUNIT_RUN then lunit.run() end