-
Notifications
You must be signed in to change notification settings - Fork 25
enh(stream-connectors-lib): package lsqlite3 #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sdepassio
merged 5 commits into
develop
from
CTOR-2315-stream-connectors-package-lua-sql-sqlite
Jun 4, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| name: lua-lsqlite3 | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - '.github/workflows/lua-lsqlite3.yml' | ||
| - 'dependencies/lua-lsqlite3/**' | ||
| push: | ||
| branches: | ||
| - develop | ||
| - master | ||
| paths: | ||
| - '.github/workflows/lua-lsqlite3.yml' | ||
| - 'dependencies/lua-lsqlite3/**' | ||
|
|
||
| jobs: | ||
| dependency-scan: | ||
| uses: centreon/security-tools/.github/workflows/dependency-analysis.yml@main | ||
|
|
||
| get-environment: | ||
| needs: [dependency-scan] | ||
| uses: ./.github/workflows/get-environment.yml | ||
|
|
||
| package: | ||
| needs: [get-environment] | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| distrib: [el8, el9, el10, bullseye, bookworm, trixie, jammy, noble] | ||
| include: | ||
| - distrib: el8 | ||
| package_extension: rpm | ||
| image: packaging-stream-connectors-nfpm-alma8 | ||
| lua_version: 5.3 | ||
| - distrib: el9 | ||
| package_extension: rpm | ||
| image: packaging-stream-connectors-nfpm-alma9 | ||
| lua_version: 5.4 | ||
| - distrib: el10 | ||
| package_extension: rpm | ||
| image: packaging-stream-connectors-nfpm-alma10 | ||
| lua_version: 5.4 | ||
| - distrib: bullseye | ||
| package_extension: deb | ||
| image: packaging-stream-connectors-nfpm-bullseye | ||
| lua_version: 5.3 | ||
| - distrib: bookworm | ||
| package_extension: deb | ||
| image: packaging-stream-connectors-nfpm-bookworm | ||
| lua_version: 5.3 | ||
| - distrib: trixie | ||
| package_extension: deb | ||
| image: packaging-stream-connectors-nfpm-trixie | ||
| lua_version: 5.4 | ||
| - distrib: jammy | ||
| package_extension: deb | ||
| image: packaging-stream-connectors-nfpm-jammy | ||
| lua_version: 5.3 | ||
| - distrib: noble | ||
| package_extension: deb | ||
| image: packaging-stream-connectors-nfpm-noble | ||
| lua_version: 5.3 | ||
|
|
||
| runs-on: ubuntu-24.04 | ||
|
|
||
| container: | ||
| image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest | ||
| credentials: | ||
| username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }} | ||
| password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }} | ||
|
|
||
| name: package ${{ matrix.distrib }} | ||
|
|
||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Prepare packaging of lua-lsqlite3 | ||
| env: | ||
| PACKAGE_EXTENSION: ${{ matrix.package_extension }} | ||
| LUA_VERSION: ${{ matrix.lua_version }} | ||
| LSQLITE3_VERSION: 0.9.7 | ||
| run: | | ||
| if [ "$PACKAGE_EXTENSION" = "rpm" ]; then | ||
| dnf install -y make gcc lua-devel unzip wget sqlite sqlite-devel | ||
| else | ||
| apt-get update | ||
| apt-get install -y make gcc liblua${LUA_VERSION}-dev unzip wget sqlite3 libsqlite3-dev | ||
| fi | ||
|
|
||
| wget -O lsqlite3.zip "https://lua.sqlite.org/home/zip/lsqlite3_v097.zip?uuid=v${LSQLITE3_VERSION}" | ||
| unzip lsqlite3.zip | ||
| mv lsqlite3_v097 lsqlite3_v${LSQLITE3_VERSION} | ||
|
|
||
| if [ "$PACKAGE_EXTENSION" = "rpm" ]; then | ||
| LUA_INCDIR="/usr/include" | ||
| else | ||
| LUA_INCDIR="/usr/include/lua${LUA_VERSION}" | ||
| fi | ||
| cd lsqlite3_v${LSQLITE3_VERSION} | ||
| gcc -O2 -fPIC -shared -o lsqlite3.so lsqlite3.c -DLSQLITE_VERSION='"${LSQLITE3_VERSION}"' $(pkg-config --cflags lua${LUA_VERSION}) $(pkg-config --cflags --libs sqlite3) | ||
| shell: bash | ||
|
|
||
| - name: Package | ||
| uses: ./.github/actions/package-nfpm | ||
| with: | ||
| nfpm_file_pattern: "dependencies/lua-lsqlite3/packaging/*.yaml" | ||
| distrib: ${{ matrix.distrib }} | ||
| package_extension: ${{ matrix.package_extension }} | ||
| arch: amd64 | ||
| version: "0.9.7" | ||
| release: "1" | ||
| commit_hash: ${{ github.sha }} | ||
| cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-lua-lsqlite3-${{ matrix.distrib }} | ||
| rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }} | ||
| rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }} | ||
| rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }} | ||
| stability: ${{ needs.get-environment.outputs.stability }} | ||
| artifact_name: "package-lua-lsqlite3-${{ matrix.distrib }}" | ||
|
|
||
| test-packages: | ||
| needs: [get-environment, package] | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - package_extension: rpm | ||
| image: almalinux:8 | ||
| distrib: el8 | ||
| - package_extension: rpm | ||
| image: almalinux:9 | ||
| distrib: el9 | ||
| - package_extension: rpm | ||
| image: almalinux:10 | ||
| distrib: el10 | ||
| - package_extension: deb | ||
| image: debian:bullseye | ||
| distrib: bullseye | ||
| - package_extension: deb | ||
| image: debian:bookworm | ||
| distrib: bookworm | ||
| - package_extension: deb | ||
| image: debian:trixie | ||
| distrib: trixie | ||
| - package_extension: deb | ||
| image: ubuntu:jammy | ||
| distrib: jammy | ||
| - package_extension: deb | ||
| image: ubuntu:noble | ||
| distrib: noble | ||
|
|
||
| runs-on: ubuntu-24.04 | ||
| container: | ||
| image: ${{ matrix.image }} | ||
|
|
||
| name: Test lua packages on ${{ matrix.package_extension }} ${{ matrix.distrib }} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Test packaged libs | ||
| uses: ./.github/actions/test-packages | ||
| with: | ||
| package_extension: ${{ matrix.package_extension }} | ||
| distrib: ${{ matrix.distrib }} | ||
| cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-lua-lsqlite3-${{ matrix.distrib }} | ||
|
|
||
| - name: Upload error log | ||
| if: failure() | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: install_error_log_${{ matrix.distrib }} | ||
| path: install_error_${{ matrix.distrib }}.log | ||
|
|
||
| deliver-rpm: | ||
| if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-environment.outputs.stability) }} | ||
| needs: [get-environment, package, test-packages] | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| matrix: | ||
| distrib: [el8, el9, el10] | ||
| name: deliver ${{ matrix.distrib }} | ||
|
|
||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Publish RPM packages | ||
| uses: ./.github/actions/rpm-delivery | ||
| with: | ||
| module_name: lua-lsqlite3 | ||
| distrib: ${{ matrix.distrib }} | ||
| artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} | ||
| cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-lua-lsqlite3-${{ matrix.distrib }} | ||
| stability: ${{ needs.get-environment.outputs.stability }} | ||
|
|
||
| deliver-deb: | ||
| if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-environment.outputs.stability) }} | ||
| needs: [get-environment, package, test-packages] | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| matrix: | ||
| distrib: [bullseye, bookworm, trixie, jammy, noble] | ||
| name: deliver ${{ matrix.distrib }} | ||
|
|
||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Publish DEB packages | ||
| uses: ./.github/actions/deb-delivery | ||
| with: | ||
| module_name: lua-lsqlite3 | ||
| distrib: ${{ matrix.distrib }} | ||
| artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} | ||
| cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-lua-lsqlite3-${{ matrix.distrib }} | ||
| stability: ${{ needs.get-environment.outputs.stability }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: "lua-lsqlite3" | ||
| arch: "${ARCH}" | ||
| platform: "linux" | ||
| version_schema: "none" | ||
| version: "${VERSION}" | ||
| release: "${RELEASE}${DIST}" | ||
| section: "default" | ||
| priority: "optional" | ||
| maintainer: "Centreon <contact@centreon.com>" | ||
| 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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!") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.