Skip to content

Commit 346ac91

Browse files
authored
ci: fix publication workflow (#65)
This converts the `rockspec-names` action into a resuable workflow so it can be called once and be used by multiple jobs. Specifically, the publish workflow uses this information for: - Invoking `luarocks publish` - Invoking `luarocks install` once the package is published, as a sanity check that it succeeded The underlying theory here is that it's better to call a reusable workflow in a job and use that output in multiple jobs, than for each job to call an action individually. I'm not entirely sure that's true, but I'm getting a feel for it.
1 parent ad15ba1 commit 346ac91

File tree

9 files changed

+95
-105
lines changed

9 files changed

+95
-105
lines changed

.github/actions/ci/action.yml

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ inputs:
99
description: 'Version of the C++ Server-side SDK to use for building and testing.'
1010
required: false
1111
default: 'launchdarkly-cpp-server-redis-source-v2.1.0'
12-
12+
rockspec:
13+
description: 'The rockspec file for the server-side SDK.'
14+
required: true
1315

1416
runs:
1517
using: composite
@@ -32,78 +34,31 @@ runs:
3234
version: ${{ inputs.cpp-sdk-version }}
3335
path: cpp-sdk
3436

35-
- uses: ./.github/actions/rockspec-names
36-
id: rockspecs
37-
38-
- name: Build Lua Server-side SDK
39-
shell: bash
40-
run: |
41-
luarocks make ${{ steps.rockspecs.outputs.server }} \
42-
LD_DIR=./cpp-sdk/build-dynamic/release
43-
44-
- name: Build Lua Server-side SDK with Redis
45-
shell: bash
46-
run: |
47-
luarocks make ${{ steps.rockspecs.outputs.server_redis }} \
48-
LDREDIS_DIR=./cpp-sdk/build-dynamic/release
49-
50-
- name: Run Lua Server-side SDK Tests
37+
- name: Build Package
5138
shell: bash
52-
if: ${{ ! contains(inputs.lua-version, 'jit') }}
53-
run: luarocks test ${{ steps.rockspecs.outputs.server }}
5439
env:
55-
# Needed because boost isn't installed in default system paths, which is
56-
# what the C++ Server-side SDK shared object expects.
57-
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
40+
CPP_PATH: ${{ github.workspace }}/cpp-sdk/build-dynamic/release
41+
run: |
42+
luarocks make ${{ inputs.rockspec }} \
43+
LD_DIR=$CPP_PATH \
44+
LDREDIS_DIR=$CPP_PATH
5845
59-
- name: Run Lua Server-side SDK Tests (JIT)
46+
- name: Run Tests
6047
shell: bash
61-
if: ${{ contains(inputs.lua-version, 'jit') }}
62-
run: luajit test.lua
48+
run: luarocks test ${{ inputs.rockspec }}
6349
env:
6450
# Needed because boost isn't installed in default system paths, which is
6551
# what the C++ Server-side SDK shared object expects.
66-
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
67-
68-
- name: Run Lua Server-side SDK with Redis Tests
69-
shell: bash
70-
if: ${{ ! contains(inputs.lua-version, 'jit') }}
71-
run: luarocks test ${{ steps.rockspecs.outputs.server_redis }}
72-
env:
73-
# Needed because boost isn't installed in default system paths, which is
74-
# what the C++ Server-side SDK shared object expects. Same for hiredis which is bundled
75-
# with the SDK release.
76-
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib;./cpp-sdk/build-dynamic/release/lib
77-
78-
- name: Run Lua Server-side SDK with Redis Tests (JIT)
79-
shell: bash
80-
if: ${{ contains(inputs.lua-version, 'jit') }}
81-
run: luajit test-redis.lua
82-
env:
83-
# Needed because boost isn't installed in default system paths, which is
84-
# what the C++ Server-side SDK shared object expects. Same for hiredis which is bundled
85-
# with the SDK release.
8652
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib;./cpp-sdk/build-dynamic/release/lib
53+
LUA_INTERPRETER: ${{ contains(inputs.lua-version, 'jit') && 'luajit' || 'lua' }}
8754

8855
- name: Run hello-lua-server example
8956
if: ${{ !contains(inputs.lua-version, 'jit') }}
9057
shell: bash
58+
run: ./scripts/interpreter.sh ./examples/hello-lua-server/hello.lua
9159
env:
9260
LD_SDK_KEY: "fake-sdk-key"
9361
# Needed because boost isn't installed in default system paths, which is
9462
# what the C++ Server-side SDK shared object expects.
9563
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
96-
run: |
97-
lua ./examples/hello-lua-server/hello.lua
98-
99-
100-
- name: Run hello-lua-server example (JIT)
101-
if: ${{ contains(inputs.lua-version, 'jit') }}
102-
shell: bash
103-
env:
104-
LD_SDK_KEY: "fake-sdk-key"
105-
# Needed because boost isn't installed in default system paths, which is
106-
# what the C++ Server-side SDK shared object expects.
107-
LD_LIBRARY_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
108-
run: |
109-
luajit ./examples/hello-lua-server/hello.lua
64+
LUA_INTERPRETER: ${{ contains(inputs.lua-version, 'jit') && 'luajit' || 'lua' }}

.github/actions/rockspec-names/action.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,33 @@ on:
1010
- '**.md'
1111

1212
jobs:
13+
rockspec-info:
14+
uses: ./.github/workflows/rockspec-info.yml
15+
16+
rockspecs:
17+
needs: rockspec-info
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.set-matrix.outputs.matrix }}
21+
steps:
22+
- id: set-matrix
23+
run: |
24+
data=$(echo ${{ needs.rockspec-info.outputs.info }} | jq -c 'to_entries | map(.value.rockspec)')
25+
echo "matrix=$data" >> $GITHUB_OUTPUT
26+
1327
linux-build:
28+
needs: rockspecs
1429
runs-on: ubuntu-latest
1530

1631
strategy:
32+
fail-fast: false
1733
matrix:
1834
version: ["5.1", "5.2", "5.3", "luajit-2.0.5"]
35+
package: ${{ fromJSON(needs.rockspecs.outputs.matrix) }}
1936

2037
steps:
2138
- uses: actions/checkout@v4
2239
- uses: ./.github/actions/ci
2340
with:
2441
lua-version: ${{ matrix.version }}
42+
rockspec: ${{ matrix.package }}

.github/workflows/manual-publish.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ on:
2626
default: false
2727

2828
jobs:
29+
rockspecs:
30+
uses: ./.github/workflows/rockspec-info.yml
31+
2932
build-publish:
33+
needs: rockspecs
3034
runs-on: ubuntu-latest
3135

3236
# Needed for AWS SSM access.
@@ -43,42 +47,43 @@ jobs:
4347
ssm_parameter_pairs: '/production/common/releasing/luarocks/token = LUAROCKS_API_TOKEN'
4448

4549
- uses: ./.github/actions/ci
46-
47-
- uses: ./.github/actions/rockspec-names
48-
id: rockspecs
50+
with:
51+
server-rockspec: ${{ needs.rockspecs.outputs.server }}
52+
redis-rockspec: ${{ needs.rockspecs.outputs.server_redis }}
4953

5054
- uses: ./.github/actions/publish
51-
name: ${{ format('Publish launchdarkly-server-sdk @ {0}', steps.rockspecs.outputs.server_version) }}
55+
name: ${{ format('Publish launchdarkly-server-sdk @ {0}', needs.rockspecs.outputs.server_version) }}
5256
if: ${{ inputs.rockspec == 'server' || inputs.rockspec == 'both' }}
5357
with:
5458
dry_run: ${{ inputs.dry_run }}
55-
rockspec: ${{ steps.rockspecs.outputs.server }}
59+
rockspec: ${{ needs.rockspecs.outputs.server }}
5660
skip_pack: ${{ inputs.skip_pack }}
5761
force: ${{ inputs.force }}
5862

5963
- uses: ./.github/actions/publish
60-
name: ${{ format('Publish launchdarkly-server-sdk-redis @ {0}', steps.rockspecs.outputs.server_redis_version) }}
64+
name: ${{ format('Publish launchdarkly-server-sdk-redis @ {0}', needs.rockspecs.outputs.server_redis_version) }}
6165
if: ${{ inputs.rockspec == 'redis' || inputs.rockspec == 'both'}}
6266
with:
6367
dry_run: ${{ inputs.dry_run }}
64-
rockspec: ${{ steps.rockspecs.outputs.server_redis }}
68+
rockspec: ${{ needs.rockspecs.outputs.server_redis }}
6569
skip_pack: ${{ inputs.skip_pack }}
6670
force: ${{ inputs.force }}
6771

6872
install-server-sdk:
69-
name: ${{ format('Install launchdarkly-server-sdk @ {0}', steps.rockspecs.outputs.server_version) }}
70-
needs: build-publish
73+
name: ${{ format('Install launchdarkly-server-sdk @ {0}', needs.rockspecs.outputs.server_version) }}
74+
needs: [rockspecs, build-publish]
7175
if: ${{ inputs.rockspec == 'server' || inputs.rockspec == 'both' }}
7276
uses: ./.github/workflows/install-lua-sdk.yml
7377
with:
7478
package: launchdarkly-server-sdk
75-
version: ${{ steps.rockspecs.outputs.server_version }}
79+
version: ${{ needs.rockspecs.outputs.server_version }}
80+
7681

7782
install-server-redis:
78-
name: ${{ format('Install launchdarkly-server-sdk-redis @ {0}', steps.rockspecs.outputs.server_redis_version) }}
79-
needs: build-publish
83+
name: ${{ format('Install launchdarkly-server-sdk-redis @ {0}', needs.rockspecs.outputs.server_redis_version) }}
84+
needs: [rockspecs, build-publish]
8085
if: ${{ inputs.rockspec == 'redis' || inputs.rockspec == 'both' }}
8186
uses: ./.github/workflows/install-lua-sdk.yml
8287
with:
8388
package: launchdarkly-server-sdk-redis
84-
version: ${{ steps.rockspecs.outputs.server_redis_version }}
89+
version: ${{ needs.rockspecs.outputs.server_redis_version }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Get Rockspec Info
2+
on:
3+
workflow_call:
4+
outputs:
5+
info:
6+
description: "JSON object with rockspec info"
7+
value: ${{ jobs.rockspec-info.outputs.info }}
8+
9+
env:
10+
LUA_SERVER_VERSION: "2.0.2" # {x-release-please-version}
11+
LUA_SERVER_REDIS_VERSION: "2.0.2" # {x-release-please-version}
12+
13+
14+
jobs:
15+
rockspec-info:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
info: ${{ steps.pkg-info.outputs.info }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Construct rockspec package names
22+
id: pkg-info
23+
run: |
24+
echo 'info<<EOF' >> $GITHUB_OUTPUT
25+
echo '"{' >> $GITHUB_OUTPUT
26+
echo '\"server\":{\"version\":\"${{ env.LUA_SERVER_VERSION}}\",\"rockspec\":\"launchdarkly-server-sdk-${{ env.LUA_SERVER_VERSION }}-0.rockspec\"},' >> $GITHUB_OUTPUT
27+
echo '\"redis\":{\"version\":\"${{ env.LUA_SERVER_REDIS_VERSION}}\",\"rockspec\":\"launchdarkly-server-sdk-redis-${{ env.LUA_SERVER_REDIS_VERSION }}-0.rockspec\"}' >> $GITHUB_OUTPUT
28+
echo '}"' >> $GITHUB_OUTPUT
29+
echo 'EOF' >> $GITHUB_OUTPUT

launchdarkly-server-sdk-2.0.2-0.rockspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ external_dependencies = {
3636

3737
test = {
3838
type = "command",
39-
script = "test.lua"
39+
command = "./scripts/interpreter.sh test.lua"
4040
}
4141

4242
build = {

launchdarkly-server-sdk-redis-2.0.2-0.rockspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ external_dependencies = {
3636

3737
test = {
3838
type = "command",
39-
script = "test-redis.lua"
39+
command = "./scripts/interpreter.sh test-redis.lua"
4040
}
4141

4242
build = {

release-please-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"versioning": "default",
77
"extra-files": [
88
"launchdarkly-server-sdk.c",
9-
".github/actions/rockspec-names/action.yml",
9+
".github/workflows/rockspec-info.yml",
1010
"README.md",
1111
"scripts/update-versions.sh",
1212
"scripts/compile.sh"

scripts/interpreter.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# This invokes a lua script with a lua interpreter specified in an
4+
# environment variable. This is useful for testing in CI, where we want to test with lua and luajit.
5+
6+
if [ -z "$1" ]; then
7+
echo "Usage: $0 <lua file>"
8+
exit 1
9+
fi
10+
11+
lua_interpreter=${LUA_INTERPRETER:-lua}
12+
13+
"$lua_interpreter" "$1"

0 commit comments

Comments
 (0)