forked from Kong/lua-resty-simdjson
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (95 loc) · 4 KB
/
tests.yml
File metadata and controls
111 lines (95 loc) · 4 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
name: Tests
on: [push, pull_request]
# cancel previous runs if new commits are pushed to the PR,
# but run for each commit on master
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
include:
# TODO: arm64
- openresty: "1.21.4.3"
- openresty: "1.25.3.2"
env:
JOBS: 1
OPENRESTY: ${{ matrix.openresty }}
CODE_PATH: ${{ github.workspace }}
BASE_PATH: /home/runner/work/cache
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup cache
uses: actions/cache@v4
id: cache-deps
with:
path: |
/home/runner/work/cache
key: ${{ runner.os }}-${{ hashFiles('**/tests.yml') }}-${{ hashFiles('**/*.cpp', '**/*.h') }}-openresty-${{ matrix.openresty }}
- name: Install packages
run: |
sudo apt update
sudo apt-get install -qq -y wget cpanminus net-tools libpcre3-dev build-essential valgrind lua5.1 liblua5.1-0-dev luarocks
if [ ! -e perl ]; then sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1); cp -r /usr/local/share/perl/ .; else sudo cp -r perl /usr/local/share; fi
- name: Download OpenResty
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
wget https://openresty.org/download/openresty-${OPENRESTY}.tar.gz
mkdir -p ${BASE_PATH}
tar xfz openresty-${OPENRESTY}.tar.gz -C ${BASE_PATH}
- name: Setup tools
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
cd ${BASE_PATH}/openresty-${OPENRESTY}
./configure --prefix=${BASE_PATH}/openresty --with-debug
make && make install
- name: Run Test
run: |
export PATH=${BASE_PATH}/openresty/bin:$PATH
openresty -V
make test OPENRESTY_PREFIX=${BASE_PATH}/openresty DEBUG=true
- name: Validate LuaRocks package
run: |
export PATH=${BASE_PATH}/openresty/bin:$PATH
rm -rf /tmp/lua-resty-simdjson-rock
ROCKSPEC="$(python3 - <<'PY'
import re
from pathlib import Path
pattern = re.compile(r"^api7-lua-resty-simdjson-(\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("api7-lua-resty-simdjson-*.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 api7-lua-resty-simdjson rockspec found")
print(max(matches)[-1])
PY
)"
luarocks --lua-version=5.1 make "$ROCKSPEC" --tree /tmp/lua-resty-simdjson-rock
eval "$(luarocks --lua-version=5.1 path --tree /tmp/lua-resty-simdjson-rock)"
resty -e 'local simdjson = require("resty.simdjson"); local parser = assert(simdjson.new()); local obj = parser:decode("{\"a\":42}"); assert(obj.a == 42); assert(parser:encode(obj) == "{\"a\":42}")'
- name: Run Valgrind
run: |
export PATH=${BASE_PATH}/openresty/bin:$PATH
export TEST_NGINX_VALGRIND='--num-callers=100 -q --tool=memcheck --leak-check=full --show-possibly-lost=no --gen-suppressions=all --suppressions=valgrind.suppress --track-origins=yes' TEST_NGINX_TIMEOUT=60 TEST_NGINX_SLEEP=1
export TEST_NGINX_USE_VALGRIND=1
openresty -V
make valgrind OPENRESTY_PREFIX=${BASE_PATH}/openresty DEBUG=true