From 7b7de3903817c814daea599e502b9cc6e5e2c4b3 Mon Sep 17 00:00:00 2001 From: HubertRonald Date: Thu, 4 Jun 2026 19:32:45 -0500 Subject: [PATCH 1/2] Improve CI and LuaRocks manual workflows --- .github/workflows/ci.yml | 24 +++++++++++- .github/workflows/publish-luarocks.yml | 53 +++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cd5103..4429466 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,21 @@ name: CI on: workflow_dispatch: + pull_request: + branches: + - master + paths: + - "src/**" + - "spec/**" + - "examples/**" + - "LuaSF.lua" + - "LuaStat.lua" + - "*.rockspec" + - ".github/workflows/ci.yml" + +permissions: + contents: read + jobs: test: name: Lua ${{ matrix.lua-version }} @@ -20,7 +35,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Lua uses: leafo/gh-actions-lua@v13 @@ -43,4 +58,9 @@ jobs: run: | lua examples/dice_simulation.lua lua examples/normal_quality_control.lua - lua examples/gamma_distribution.lua \ No newline at end of file + lua examples/gamma_distribution.lua + lua examples/weighted_loot_drop.lua + lua examples/monte_carlo_pi.lua + lua examples/poisson_arrivals.lua + lua examples/binomial_coin_flips.lua + lua examples/bootstrap_mean.lua diff --git a/.github/workflows/publish-luarocks.yml b/.github/workflows/publish-luarocks.yml index ed51866..4ba520b 100644 --- a/.github/workflows/publish-luarocks.yml +++ b/.github/workflows/publish-luarocks.yml @@ -4,9 +4,22 @@ on: workflow_dispatch: inputs: rockspec: - description: "Rockspec file to validate" + description: "Rockspec file to validate or publish" required: true - default: "luasf-0.3.0-1.rockspec" + default: "luasf-0.4.0-1.rockspec" + type: string + publish: + description: "Publish to LuaRocks after validation" + required: true + default: false + type: boolean + +permissions: + contents: read + +concurrency: + group: luarocks-publish + cancel-in-progress: false jobs: validate: @@ -15,7 +28,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Lua uses: leafo/gh-actions-lua@v13 @@ -26,10 +39,38 @@ jobs: uses: leafo/gh-actions-luarocks@v6 - name: Validate rockspec - run: luarocks lint "${{ github.event.inputs.rockspec }}" + run: luarocks lint "${{ inputs.rockspec }}" - name: Build rock locally - run: luarocks make "${{ github.event.inputs.rockspec }}" + run: luarocks make "${{ inputs.rockspec }}" + + - name: Test LuaRocks package entry point + run: lua -e 'local stats = require("luasf"); print(stats.sum({1,2,3}))' + + - name: Test LuaSF compatibility entry point + run: lua -e 'local stats = require("LuaSF"); print(stats.sumF({1,2,3}))' + + - name: Test LuaStat compatibility entry point + run: lua -e 'local stats = require("LuaStat"); print(stats.avF({2,4,6}))' + + publish: + name: Publish to LuaRocks + needs: validate + runs-on: ubuntu-latest + if: ${{ inputs.publish == true }} + environment: luarocks-production + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Set up Lua + uses: leafo/gh-actions-lua@v13 + with: + luaVersion: "5.4.8" + + - name: Set up LuaRocks + uses: leafo/gh-actions-luarocks@v6 - name: Upload to LuaRocks - run: luarocks upload "${{ github.event.inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}" \ No newline at end of file + run: luarocks upload "${{ inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}" From ef049ce6bb7fd15bd00842e736e08d1e1a7854bd Mon Sep 17 00:00:00 2001 From: HubertRonald Date: Thu, 4 Jun 2026 19:37:34 -0500 Subject: [PATCH 2/2] Configure Lua module path in CI --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4429466..114a7a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,9 @@ jobs: - name: Install test dependencies run: luarocks install luaunit + - name: Configure local Lua module path + run: echo "LUA_PATH=./src/?.lua;./?.lua;${LUA_PATH}" >> "$GITHUB_ENV" + - name: Run tests run: | lua spec/test_stats.lua