Skip to content

Commit a2d3946

Browse files
authored
ci: update install-lua-sdk workflow with unified default values (#63)
The problem being solved here is that `workflow_dispatch`, `workflow_call`, and `schedule` events are often all useful for a single workflow. That is - you might want a workflow to run based on: 1. A UI interaction 2. Another workflow calling it 3. On a regular schedule The first two, and perhaps the last, are all relevant for `install-lua-sdk`. We might have a one-off test for a particular Lua version, triggered in Github UI (1). We might run this after `release-please` publishes a package (2). And finally, we might want to ensure the package is installable every day (3). To make this actually work, you need to ensure default values are assigned for each input. The cleanest way to do that seems to be some duplication and a "ternary" technique with environment variables.
1 parent 3dfaa0d commit a2d3946

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

.github/workflows/install-lua-sdk.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,43 @@ on:
2323
- '5.1'
2424
- '5.2'
2525
- '5.3'
26-
- '5.4'
2726
- 'luajit-2.0.5'
28-
default: '5.4'
27+
default: '5.3'
2928
cpp-sdk-version:
30-
description: "Version of the C++ Server-side SDK to use for building and testing."
29+
description: "Version of the C++ Server-side SDK."
3130
required: false
3231
type: string
3332
default: 'launchdarkly-cpp-server-redis-source-v2.1.0'
33+
workflow_call:
34+
inputs:
35+
package:
36+
required: false
37+
type: string
38+
version:
39+
required: false
40+
type: string
41+
lua-version:
42+
required: false
43+
type: string
44+
cpp-sdk-version:
45+
required: false
46+
type: string
3447

48+
env:
49+
PACKAGE: ${{ inputs.package == null && 'launchdarkly-server-sdk' || inputs.package }}
50+
VERSION: ${{ inputs.version == null && '' || inputs.version }}
51+
LUA_VERSION: ${{ inputs.lua-version == null && '5.3' || inputs.lua-version }}
52+
CPP_SDK_VERSION: ${{ inputs.cpp-sdk-version == null && 'launchdarkly-cpp-server-redis-source-v2.1.0' || inputs.cpp-sdk-version }}
3553
jobs:
3654
install:
3755
runs-on: ubuntu-latest
3856
steps:
3957
- uses: actions/checkout@v4
58+
4059
- name: Install Lua
4160
uses: leafo/gh-actions-lua@35bcb06abec04ec87df82e08caa84d545348536e
4261
with:
43-
luaVersion: ${{ inputs.lua-version }}
62+
luaVersion: ${{ env.LUA_VERSION }}
4463

4564
- name: Install LuaRocks
4665
uses: leafo/gh-actions-luarocks@e65774a6386cb4f24e293dca7fc4ff89165b64c5
@@ -55,18 +74,18 @@ jobs:
5574
- name: Install CPP SDK
5675
uses: ./.github/actions/install-cpp-sdk-redis
5776
with:
58-
version: ${{ inputs.cpp-sdk-version }}
77+
version: ${{ env.CPP_SDK_VERSION }}
5978
path: cpp-sdk
6079

6180
- name: Install Package
6281
shell: bash
6382
env:
64-
CPP_PATH: $GITHUB_WORKSPACE/cpp-sdk/build-dynamic/release
83+
CPP_PATH: ${{ github.workspace }}/cpp-sdk/build-dynamic/release
6584
run: |
66-
luarocks install ${{ inputs.package }} ${{ inputs.version }} \
85+
luarocks install ${{ env.PACKAGE }} ${{ env.VERSION }} \
6786
LD_DIR=$CPP_PATH \
6887
LDREDIS_DIR=$CPP_PATH
6988
7089
- name: Remove Package
7190
shell: bash
72-
run: luarocks remove ${{ inputs.package }}
91+
run: luarocks remove ${{ env.PACKAGE }}

0 commit comments

Comments
 (0)