diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..8ce09daf6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,57 @@ +name: Tests + +on: + pull_request: + paths-ignore: + - '*.md' + push: + branches: + - master + - release/* + paths-ignore: + - '*.md' + + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + container: + image: openresty/openresty:${{ matrix.openresty }}-jammy + + strategy: + fail-fast: false + matrix: + openresty: ["1.19.9.1-14", "1.21.4.1-0"] + + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install valgrind + run: | + apt-get update + apt-get install -y valgrind + + # ensure the library works even without dev packages installed (libz.so.1 instead of libz.so) + - name: Remove dev packages + run: | + apt-get purge -y libc-dev-bin + + - name: Run test with LuaJIT + run: | + luajit test.lua /usr/local/openresty/nginx/sbin/nginx 65536000 + + - name: Run test with resty-cli + run: | + resty --no-stream test.lua /usr/local/openresty/nginx/sbin/nginx 65536000 + + - name: Run test with resty-cli (valgrind) + if: contains(matrix.extras, 'valgrind') + run: | + resty --no-stream --valgrind test.lua /usr/local/openresty/nginx/sbin/nginx 65536000 diff --git a/lib/ffi-zlib.lua b/lib/ffi-zlib.lua index 2dcfa0b29..8c8e4638f 100644 --- a/lib/ffi-zlib.lua +++ b/lib/ffi-zlib.lua @@ -6,7 +6,7 @@ local ffi_copy = ffi.copy local tonumber = tonumber local _M = { - _VERSION = '0.5.0', + _VERSION = '0.6.0', } local mt = { __index = _M } @@ -95,7 +95,17 @@ unsigned long crc32_combine(unsigned long, unsigned long, long); ]]) -local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z") +local zlib +if ffi.os == "Windows" then + zlib = ffi.load("zlib1") +elseif ffi.os == "OSX" then + zlib = ffi.load("z") +elseif ffi.os == "Linux" then + zlib = ffi.load("libz.so.1") +else + error("lua-ffi-zlib doesn't support platform: " .. ffi.os) +end + _M.zlib = zlib -- Default to 16k output buffer diff --git a/lua-ffi-zlib-0.6-0.rockspec b/lua-ffi-zlib-0.6-0.rockspec new file mode 100644 index 000000000..0b2a70c9f --- /dev/null +++ b/lua-ffi-zlib-0.6-0.rockspec @@ -0,0 +1,20 @@ +package = "lua-ffi-zlib" +version = "0.6-0" +source = { + url = "git://github.com/hamishforbes/lua-ffi-zlib", + tag = "v0.6" +} +description = { + summary = "A Lua module using LuaJIT's FFI feature to access zlib.", + homepage = "https://github.com/hamishforbes/lua-ffi-zlib", + maintainer = "Hamish Forbes" +} +dependencies = { + "lua >= 5.1", +} +build = { + type = "builtin", + modules = { + ["ffi-zlib"] = "lib/ffi-zlib.lua", + } +}