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
42 changes: 42 additions & 0 deletions .github/actions/setup-lua/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Setup Lua
description: Install a Lua runtime, LuaRocks, and optional LuaRocks packages.

inputs:
lua-version:
description: Runtime version accepted by leafo/gh-actions-lua.
required: true
luarocks-version:
description: LuaRocks version to install.
required: false
default: "3.11.1"
install-luarocks:
description: Install LuaRocks with leafo/gh-actions-luarocks.
required: false
default: "true"
packages:
description: Whitespace-separated LuaRocks packages to install.
required: false
default: ""

runs:
using: composite
steps:
- name: Install Lua
uses: leafo/gh-actions-lua@v13
with:
luaVersion: ${{ inputs.lua-version }}

- name: Install LuaRocks
if: inputs.install-luarocks == 'true'
uses: leafo/gh-actions-luarocks@v4
with:
luarocksVersion: ${{ inputs.luarocks-version }}

- name: Install LuaRocks packages
if: inputs.install-luarocks == 'true' && inputs.packages != ''
shell: bash
run: |
set -euo pipefail
for package in ${{ inputs.packages }}; do
luarocks install "$package"
done
10 changes: 10 additions & 0 deletions .github/scripts/install-lua-test-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

sudo apt-get update
sudo apt-get install -y lua5.1 liblua5.1-0-dev luarocks

# Ubuntu LuaRocks targets Lua 5.1 by default; LuaJIT is ABI-compatible
# with 5.1 so rocks built for 5.1 load fine under each runtime.
sudo /usr/bin/luarocks install busted
sudo /usr/bin/luarocks install lua-cjson
69 changes: 69 additions & 0 deletions .github/scripts/latest-rockspec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
import argparse
import re
from pathlib import Path


def prerelease_key(value):
if value is None:
return ()
key = []
for part in value.split("."):
if part.isdigit():
key.append((0, int(part)))
else:
key.append((1, part))
return tuple(key)


def latest_any():
pattern = re.compile(
r"^lua-qjson-(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?-(\d+)\.rockspec$"
)
matches = []
for path in Path("rockspec").glob("lua-qjson-*.rockspec"):
match = pattern.match(path.name)
if match:
major, minor, patch, prerelease, revision = match.groups()
matches.append(
(
int(major),
int(minor),
int(patch),
prerelease is None,
prerelease_key(prerelease),
int(revision),
str(path),
)
)
if not matches:
raise SystemExit("no lua-qjson rockspec found")
return max(matches)[-1]


def latest_for_version(version):
version = version.removeprefix("v")
pattern = re.compile(r"^lua-qjson-" + re.escape(version) + r"-(\d+)\.rockspec$")
matches = []
for path in Path("rockspec").glob("lua-qjson-" + version + "-*.rockspec"):
match = pattern.match(path.name)
if match:
matches.append((int(match.group(1)), str(path)))
if not matches:
raise SystemExit("rockspec file not found for version " + version)
return max(matches)[1]


def main():
parser = argparse.ArgumentParser(description="Print the newest lua-qjson rockspec path.")
parser.add_argument("--version", help="Select the newest revision for a release version.")
args = parser.parse_args()

if args.version:
print(latest_for_version(args.version))
else:
print(latest_any())


if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions .github/scripts/resolve-luajit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -eq 0 ]; then
set -- luajit luajit-2.1.0-beta3 lua
fi

for candidate in "$@"; do
if command -v "$candidate" >/dev/null 2>&1; then
lua_bin="$(command -v "$candidate")"
if "$lua_bin" -e 'assert(jit, "LuaJIT required")' >/dev/null 2>&1; then
if [ -n "${GITHUB_OUTPUT:-}" ]; then
echo "path=$lua_bin" >> "$GITHUB_OUTPUT"
fi
"$lua_bin" -e 'print(jit.version)'
exit 0
fi
fi
done

echo "LuaJIT executable not found" >&2
exit 1
39 changes: 22 additions & 17 deletions .github/scripts/run-openresty-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail

workspace="${GITHUB_WORKSPACE:-$(pwd)}"
libqjson="$workspace/target/release/libqjson.so"
full_busted="${OPENRESTY_FULL_BUSTED:-false}"

if [[ ! -f "$libqjson" ]]; then
echo "missing release cdylib: $libqjson" >&2
Expand All @@ -13,6 +14,7 @@ fi

docker run --rm \
-e DEBIAN_FRONTEND=noninteractive \
-e OPENRESTY_FULL_BUSTED="$full_busted" \
-v "$workspace:/workspace" \
-w /workspace \
"$OPENRESTY_IMAGE" \
Expand All @@ -22,31 +24,34 @@ set -euo pipefail
OPENRESTY=/usr/local/openresty
RESTY="$OPENRESTY/bin/resty"
LUAJIT="$OPENRESTY/luajit/bin/luajit"
BUSTED="$OPENRESTY/luajit/bin/busted"

test -x "$RESTY"
test -x "$LUAJIT"

apt-get update
apt-get install -y --no-install-recommends \
ca-certificates \
liblua5.1-0-dev \
lua5.1 \
luarocks

# Use Ubuntu LuaRocks here. The OpenResty-bundled luarocks command runs under
# LuaJIT and can fail to load the current public manifest due to bytecode limits.
/usr/bin/luarocks install busted
/usr/bin/luarocks install lua-cjson

test -x "$BUSTED"
"$RESTY" -V >/dev/null 2>&1
"$RESTY" -V
"$LUAJIT" -e '\''assert(jit, "LuaJIT required"); print(jit.version)'\''

export LD_LIBRARY_PATH=/workspace/target/release
export LUA_PATH="/workspace/lua/?.lua;;"

"$RESTY" /workspace/.github/scripts/openresty-smoke.lua
"$BUSTED" --lua="$LUAJIT" /workspace/tests/lua \
--lpath="/workspace/lua/?.lua"

if [ "${OPENRESTY_FULL_BUSTED:-false}" = "true" ]; then
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates \
liblua5.1-0-dev \
lua5.1 \
luarocks

# Use Ubuntu LuaRocks here. The OpenResty-bundled luarocks command runs under
# LuaJIT and can fail to load the current public manifest due to bytecode limits.
/usr/bin/luarocks install busted
/usr/bin/luarocks install lua-cjson

BUSTED="$(command -v busted)"
test -x "$BUSTED"
"$BUSTED" --lua="$LUAJIT" /workspace/tests/lua \
--lpath="/workspace/lua/?.lua"
fi
'
4 changes: 4 additions & 0 deletions .github/workflows/changelog-policy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
- "CHANGELOG.md"
- ".github/workflows/changelog-policy.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

Expand Down
Loading
Loading