Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -33,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
Expand All @@ -43,4 +61,9 @@ jobs:
run: |
lua examples/dice_simulation.lua
lua examples/normal_quality_control.lua
lua examples/gamma_distribution.lua
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
53 changes: 47 additions & 6 deletions .github/workflows/publish-luarocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 }}"
run: luarocks upload "${{ inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}"
Loading