-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (168 loc) · 6.22 KB
/
ci.yml
File metadata and controls
193 lines (168 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: CI
on:
push:
branches: [master, main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
rust:
name: Rust tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust (stable)
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.toml') }}
restore-keys: |
cargo-${{ runner.os }}-${{ runner.arch }}-
- name: Build (release)
run: cargo build --release
- name: Test (release)
run: cargo test --release
- name: Test scalar-only (no AVX2/NEON feature)
run: cargo test --release --no-default-features
- name: Test with test-panic feature
run: cargo test --features test-panic --release
lua:
name: Lua integration tests
runs-on: ubuntu-latest
needs: rust
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust (stable)
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Build cdylib
run: cargo build --release
- name: Install LuaJIT, LuaRocks and dependencies
run: |
sudo apt-get update
sudo apt-get install -y luajit lua5.1 liblua5.1-0-dev luarocks
# luarocks on Ubuntu targets lua5.1 by default; LuaJIT is ABI-compatible
# with 5.1 so rocks built for 5.1 load fine under luajit.
sudo luarocks install busted
sudo luarocks install lua-cjson
- name: Run busted tests (under LuaJIT)
run: |
# ffi.load("qjson") uses dlopen which respects LD_LIBRARY_PATH,
# not LuaJIT's package.cpath. Point dlopen at the release build dir.
LD_LIBRARY_PATH="$PWD/target/release" \
busted --lua=$(which luajit) tests/lua \
--lpath='./lua/?.lua'
- name: Validate LuaRocks package
run: |
rm -rf /tmp/lua-qjson-rock
ROCKSPEC="$(python3 - <<'PY'
import re
from pathlib import Path
pattern = re.compile(r"^lua-qjson-(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?-(\d+)\.rockspec$")
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)
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")
print(max(matches)[-1])
PY
)"
luarocks make "$ROCKSPEC" --tree /tmp/lua-qjson-rock
eval "$(luarocks path --tree /tmp/lua-qjson-rock)"
unset LD_LIBRARY_PATH
luajit -e 'local qjson = require("qjson"); local doc = qjson.parse("{\"a\":42}"); assert(doc:get_i64("a") == 42)'
busted --lua=$(which luajit) tests/lua
package:
name: LuaRocks package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: rust
strategy:
matrix:
os: [ubuntu-latest, macos-14]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust (stable)
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Install LuaJIT
uses: leafo/gh-actions-lua@v13
with:
luaVersion: "luajit-2.1.0-beta3"
- name: Install LuaRocks
uses: leafo/gh-actions-luarocks@v4
with:
luarocksVersion: "3.11.1"
- name: Validate LuaRocks package
run: |
rm -rf /tmp/lua-qjson-rock
ROCKSPEC="$(python3 - <<'PY'
import re
from pathlib import Path
pattern = re.compile(r"^lua-qjson-(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?-(\d+)\.rockspec$")
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)
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")
print(max(matches)[-1])
PY
)"
luarocks make "$ROCKSPEC" --tree /tmp/lua-qjson-rock
eval "$(luarocks path --tree /tmp/lua-qjson-rock)"
unset LD_LIBRARY_PATH
unset DYLD_LIBRARY_PATH
lua -e 'assert(jit, "LuaJIT required"); local qjson = require("qjson"); local doc = qjson.parse("{\"a\":42}"); assert(doc:get_i64("a") == 42)'