diff --git a/.github/actions/package-nfpm/action.yml b/.github/actions/package-nfpm/action.yml index 69240563..c5e42cf2 100644 --- a/.github/actions/package-nfpm/action.yml +++ b/.github/actions/package-nfpm/action.yml @@ -96,6 +96,7 @@ runs: BASENAME=$(basename $FILE) cd $DIRNAME sed -i "s/@luaver@/$luaver/g" $BASENAME + sed -i "s/@VERSION@/${INPUT_VERSION}/g" $BASENAME sed -i "s/@COMMIT_HASH@/${INPUT_COMMIT_HASH}/g" $BASENAME nfpm package --config "$BASENAME" --packager "$INPUT_PACKAGE_EXTENSION" cd - diff --git a/.github/docker/Dockerfile.packaging-stream-connectors-nfpm-trixie b/.github/docker/Dockerfile.packaging-stream-connectors-nfpm-trixie index b8629c20..0c4d1cf7 100644 --- a/.github/docker/Dockerfile.packaging-stream-connectors-nfpm-trixie +++ b/.github/docker/Dockerfile.packaging-stream-connectors-nfpm-trixie @@ -5,7 +5,7 @@ FROM ${REGISTRY_URL}/debian:trixie RUN bash -e <" +description: | + Lua SQLite3 library + Commit: @COMMIT_HASH@ +vendor: "Centreon" +homepage: "https://www.centreon.com" +license: "MIT" + +contents: + - src: "../../../lsqlite3_v@VERSION@/lsqlite3.so" + dst: "/usr/lib64/lua/@luaver@/lsqlite3.so" + packager: rpm + + - src: "../../../lsqlite3_v@VERSION@/lsqlite3.so" + dst: "/usr/lib/x86_64-linux-gnu/lua/@luaver@/lsqlite3.so" + packager: deb + +overrides: + rpm: + depends: + - lua + - sqlite-libs + deb: + depends: + - "lua@luaver@" + - libsqlite3-0 + +rpm: + summary: Lua SQLite3 + signature: + key_file: ${RPM_SIGNING_KEY_FILE} + key_id: ${RPM_SIGNING_KEY_ID} diff --git a/tests/packaging/lua-lsqlite3.lua b/tests/packaging/lua-lsqlite3.lua new file mode 100644 index 00000000..26ff3432 --- /dev/null +++ b/tests/packaging/lua-lsqlite3.lua @@ -0,0 +1,89 @@ +#!/usr/bin/env lua + +-- Check if the module can be loaded +local status, sqlite3 = pcall(require, 'lsqlite3') + +if not status then + print("ERROR: Unable to load lsqlite3 module") + print(sqlite3) + os.exit(1) +end + +print("✓ lsqlite3 module loaded successfully") + +-- Open an in-memory database +local db = sqlite3.open_memory() + +if not db then + print("ERROR: Unable to open in-memory database") + os.exit(1) +end + +print("✓ In-memory database opened successfully") + +-- Create a table +local rc = db:exec([[ + CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT, value REAL); +]]) + +if rc ~= sqlite3.OK then + print("ERROR: Unable to create table: " .. db:errmsg()) + db:close() + os.exit(1) +end + +print("✓ Table created successfully") + +-- Insert rows +local stmt = db:prepare("INSERT INTO test (name, value) VALUES (?, ?)") + +if not stmt then + print("ERROR: Unable to prepare insert statement: " .. db:errmsg()) + db:close() + os.exit(1) +end + +local rows = { + { "alpha", 1.1 }, + { "beta", 2.2 }, + { "gamma", 3.3 }, +} + +for _, row in ipairs(rows) do + stmt:bind_values(row[1], row[2]) + rc = stmt:step() + if rc ~= sqlite3.DONE then + print("ERROR: Unable to insert row: " .. db:errmsg()) + stmt:finalize() + db:close() + os.exit(1) + end + stmt:reset() +end + +stmt:finalize() +print("✓ Rows inserted successfully") + +-- Query and verify data +local count = 0 +for row in db:nrows("SELECT name, value FROM test ORDER BY id") do + count = count + 1 + local expected = rows[count] + if row.name ~= expected[1] or math.abs(row.value - expected[2]) > 1e-9 then + print(string.format("ERROR: Row %d mismatch: got (%s, %f), expected (%s, %f)", + count, row.name, row.value, expected[1], expected[2])) + db:close() + os.exit(1) + end +end + +if count ~= #rows then + print(string.format("ERROR: Expected %d rows, got %d", #rows, count)) + db:close() + os.exit(1) +end + +print("✓ Data queried and verified successfully") + +db:close() +print("\nAll tests passed - lua-lsqlite3 is working correctly!")