Skip to content

Commit

Permalink
ci: update examples to latest spec
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed May 17, 2024
1 parent 35bb4f4 commit 8803248
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ jobs:
- name: Evaluate feature flag
run: |
curl --retry 5 --retry-all-errors --retry-delay 1 -s -v http://localhost:8123 | tee response.txt
grep -F "is false for this user" response.txt || (echo "Expected false evaluation!" && exit 1)
- name: Stop ${{ matrix.name }} container
run: |
docker stop ${{ matrix.name }}
- uses: launchdarkly/gh-actions/actions/verify-hello-app
name: 'Verify ${{ matrix.name}} example output'
with:
use_server_key: true
role_arn: ${{ vars.AWS_ROLE_ARN }}
command: cat response.txt


plain-lua-examples:
runs-on: ubuntu-latest
Expand All @@ -92,6 +98,9 @@ jobs:
- name: Run ${{ matrix.name }} container in foreground
run: |
docker run --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:${{ matrix.name }} > logs.txt
- name: Verify output
run: |
grep -F "is false for this user" logs.txt || (echo "Expected false evaluation!" && exit 1)
- uses: launchdarkly/gh-actions/actions/verify-hello-app
name: 'Verify ${{ matrix.name}} example output'
with:
use_server_key: true
role_arn: ${{ vars.AWS_ROLE_ARN }}
command: cat logs.txt
2 changes: 1 addition & 1 deletion examples/hello-debian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ We've built a minimal dockerized example of using the Lua SDK within a Debian Bo
`LD_FLAG_KEY`, then the default flag key `my-boolean-flag` will be used.
You should receive the message:
> Feature flag is <true/false> for this user context
> The (flag key) feature flag evaluates to (true/false).
2 changes: 1 addition & 1 deletion examples/hello-debian/hello.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ local user = ld.makeContext({

local flag_key = get_from_env_or_default("LD_FLAG_KEY", MY_FLAG_KEY)
local value = client:boolVariation(user, flag_key, false)
print("Feature flag ".. flag_key .." is "..tostring(value).." for this user context")
print("The ".. flag_key .." feature flag evaluates to "..tostring(value)..".")
2 changes: 1 addition & 1 deletion examples/hello-haproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ We've built a minimal dockerized example of using the Lua SDK with [HAProxy](htt
4. Open `localhost:8123` in your browser. Toggle the flag on to see a change in the page (refresh the page.)

You should receive the message:
> Feature flag is <true/false> for this user context
> The (flag key) feature flag evaluates to (true/false).
7 changes: 2 additions & 5 deletions examples/hello-haproxy/service.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ core.register_service("launchdarkly", "http", function(applet)
}
})

if client:boolVariation(user, flag_key, false) then
applet:send("<p>Feature flag " .. flag_key .. " is true for this user context</p>")
else
applet:send("<p>Feature flag " .. flag_key .. " is false for this user context</p>")
end
local flag_value = client:boolVariation(user, flag_key, false)
applet:send("<p>The " .. flag_key .. " feature flag evaluates to " .. tostring(flag_value) .. ".</p>")
end)
2 changes: 1 addition & 1 deletion examples/hello-lua-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ LD_SDK_KEY=my-sdk-key LD_FLAG_KEY=my-boolean-flag lua hello.lua
```

The program should output:
> Feature flag is <true/false> for this user context
> The (flag key) feature flag evaluates to (true/false).
2 changes: 1 addition & 1 deletion examples/hello-lua-server/hello.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ local user = ld.makeContext({

local flag_key = get_from_env_or_default("LD_FLAG_KEY", MY_FLAG_KEY)
local value = client:boolVariation(user, flag_key, false)
print("Feature flag ".. flag_key .." is "..tostring(value).." for this user context")
print("The ".. flag_key .." feature flag evaluates to "..tostring(value)..".")
2 changes: 1 addition & 1 deletion examples/hello-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ We've built a minimal dockerized example of using the Lua SDK with [OpenResty NG
4. Open `localhost:8123` in your browser. Toggle the flag on to see a change in the page (refresh the page.)

You should receive the message:
> Feature flag is <true/false> for this user context
> The (flag key) feature flag evaluates to (true/false).
7 changes: 2 additions & 5 deletions examples/hello-nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ http {
})

local flag_key = get_from_env_or_default("LD_FLAG_KEY", MY_FLAG_KEY)
if client:boolVariation(user, flag_key, false) then
ngx.say("<p>Feature flag " .. flag_key .. " is true for this user context</p>")
else
ngx.say("<p>Feature flag " .. flag_key .. " is false for this user context</p>")
end
local flag_value = client:boolVariation(user, flag_key, false)
ngx.say("<p>The " .. flag_key .. " feature flag evaluates to " .. tostring(flag_value) .. ".</p>")
}
}
}
Expand Down

0 comments on commit 8803248

Please sign in to comment.