Skip to content

Commit 737a9e1

Browse files
authored
Merge pull request #14 from HubertRonald/feature/improve-ci-luarocks-workflow
Improve CI and LuaRocks manual publishing workflows
2 parents 7d85d57 + ef049ce commit 737a9e1

2 files changed

Lines changed: 72 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ name: CI
33
on:
44
workflow_dispatch:
55

6+
pull_request:
7+
branches:
8+
- master
9+
paths:
10+
- "src/**"
11+
- "spec/**"
12+
- "examples/**"
13+
- "LuaSF.lua"
14+
- "LuaStat.lua"
15+
- "*.rockspec"
16+
- ".github/workflows/ci.yml"
17+
18+
permissions:
19+
contents: read
20+
621
jobs:
722
test:
823
name: Lua ${{ matrix.lua-version }}
@@ -20,7 +35,7 @@ jobs:
2035

2136
steps:
2237
- name: Checkout repository
23-
uses: actions/checkout@v4
38+
uses: actions/checkout@v5
2439

2540
- name: Set up Lua
2641
uses: leafo/gh-actions-lua@v13
@@ -33,6 +48,9 @@ jobs:
3348
- name: Install test dependencies
3449
run: luarocks install luaunit
3550

51+
- name: Configure local Lua module path
52+
run: echo "LUA_PATH=./src/?.lua;./?.lua;${LUA_PATH}" >> "$GITHUB_ENV"
53+
3654
- name: Run tests
3755
run: |
3856
lua spec/test_stats.lua
@@ -43,4 +61,9 @@ jobs:
4361
run: |
4462
lua examples/dice_simulation.lua
4563
lua examples/normal_quality_control.lua
46-
lua examples/gamma_distribution.lua
64+
lua examples/gamma_distribution.lua
65+
lua examples/weighted_loot_drop.lua
66+
lua examples/monte_carlo_pi.lua
67+
lua examples/poisson_arrivals.lua
68+
lua examples/binomial_coin_flips.lua
69+
lua examples/bootstrap_mean.lua

.github/workflows/publish-luarocks.yml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ on:
44
workflow_dispatch:
55
inputs:
66
rockspec:
7-
description: "Rockspec file to validate"
7+
description: "Rockspec file to validate or publish"
88
required: true
9-
default: "luasf-0.3.0-1.rockspec"
9+
default: "luasf-0.4.0-1.rockspec"
10+
type: string
11+
publish:
12+
description: "Publish to LuaRocks after validation"
13+
required: true
14+
default: false
15+
type: boolean
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: luarocks-publish
22+
cancel-in-progress: false
1023

1124
jobs:
1225
validate:
@@ -15,7 +28,7 @@ jobs:
1528

1629
steps:
1730
- name: Checkout repository
18-
uses: actions/checkout@v4
31+
uses: actions/checkout@v5
1932

2033
- name: Set up Lua
2134
uses: leafo/gh-actions-lua@v13
@@ -26,10 +39,38 @@ jobs:
2639
uses: leafo/gh-actions-luarocks@v6
2740

2841
- name: Validate rockspec
29-
run: luarocks lint "${{ github.event.inputs.rockspec }}"
42+
run: luarocks lint "${{ inputs.rockspec }}"
3043

3144
- name: Build rock locally
32-
run: luarocks make "${{ github.event.inputs.rockspec }}"
45+
run: luarocks make "${{ inputs.rockspec }}"
46+
47+
- name: Test LuaRocks package entry point
48+
run: lua -e 'local stats = require("luasf"); print(stats.sum({1,2,3}))'
49+
50+
- name: Test LuaSF compatibility entry point
51+
run: lua -e 'local stats = require("LuaSF"); print(stats.sumF({1,2,3}))'
52+
53+
- name: Test LuaStat compatibility entry point
54+
run: lua -e 'local stats = require("LuaStat"); print(stats.avF({2,4,6}))'
55+
56+
publish:
57+
name: Publish to LuaRocks
58+
needs: validate
59+
runs-on: ubuntu-latest
60+
if: ${{ inputs.publish == true }}
61+
environment: luarocks-production
62+
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v5
66+
67+
- name: Set up Lua
68+
uses: leafo/gh-actions-lua@v13
69+
with:
70+
luaVersion: "5.4.8"
71+
72+
- name: Set up LuaRocks
73+
uses: leafo/gh-actions-luarocks@v6
3374

3475
- name: Upload to LuaRocks
35-
run: luarocks upload "${{ github.event.inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}"
76+
run: luarocks upload "${{ inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}"

0 commit comments

Comments
 (0)