-
Notifications
You must be signed in to change notification settings - Fork 287
165 lines (148 loc) · 6.63 KB
/
test.yml
File metadata and controls
165 lines (148 loc) · 6.63 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
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
name: "nginx ${{ matrix.nginx }}"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# OPENSSL_VER/OPENSSL_PATCH_VER were only used by the (commented out)
# OpenSSL-from-source build; the active CI uses the openresty-openssl3
# package, so only the nginx version varies here.
nginx:
- 1.31.0
services:
# Replaces Travis' `services: memcache`.
memcached:
image: memcached:1.6-alpine
ports:
- 11211:11211
env:
JOBS: 2
NGX_BUILD_JOBS: 2
CC: gcc
NGX_BUILD_CC: gcc
LUAJIT_PREFIX: /opt/luajit21
LUAJIT_LIB: /opt/luajit21/lib
LUAJIT_INC: /opt/luajit21/include/luajit-2.1
LUA_INCLUDE_DIR: /opt/luajit21/include/luajit-2.1
LUA_CMODULE_DIR: /lib
PCRE2_PREFIX: /usr/local/openresty/pcre2
PCRE2_LIB: /usr/local/openresty/pcre2/lib
PCRE2_INC: /usr/local/openresty/pcre2/include
OPENSSL_PREFIX: /usr/local/openresty/openssl3
OPENSSL_LIB: /usr/local/openresty/openssl3/lib
OPENSSL_INC: /usr/local/openresty/openssl3/include
LD_LIBRARY_PATH: /opt/luajit21/lib
TEST_NGINX_SLEEP: 0.005
TEST_NGINX_RANDOMIZE: 1
TEST_NGINX_RESOLVER: 8.8.4.4
LUACHECK_VER: 0.21.1
NGINX_VERSION: ${{ matrix.nginx }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Cache downloads
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: download-cache
key: download-cache-${{ runner.os }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
axel luarocks daemonize lsb-release wget gnupg ca-certificates \
cpanminus
# --- before_install --------------------------------------------------
- name: Lint Lua sources
run: |
sudo luarocks install luacheck $LUACHECK_VER
luacheck --globals coroutine -q .
! grep -n -P '(?<=.{80}).+' --color `find . -name '*.lua'` \
|| (echo "ERROR: Found Lua source lines exceeding 80 columns." > /dev/stderr; exit 1)
! grep -n -P '\t+' --color `find . -name '*.lua'` \
|| (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)
- name: Install Test::Nginx
run: |
sudo cpanm --notest Test::Nginx IPC::Run > build.log 2>&1 \
|| (cat build.log && exit 1)
- name: Install openresty PCRE2 and OpenSSL
run: |
wget -O - https://openresty.org/package/pubkey.gpg \
| sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg
echo "deb [signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" \
| sudo tee /etc/apt/sources.list.d/openresty.list
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
openresty-pcre2 openresty-openssl3 openresty-pcre2-dev openresty-openssl3-dev
# --- install ---------------------------------------------------------
- name: Clone dependencies
run: |
if [ ! -d download-cache ]; then mkdir download-cache; fi
git clone https://github.com/openresty/openresty.git ../openresty
git clone https://github.com/openresty/openresty-devel-utils.git
git clone https://github.com/simpl/ngx_devel_kit.git ../ndk-nginx-module
git clone https://github.com/openresty/lua-nginx-module.git ../lua-nginx-module
git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
git clone https://github.com/openresty/echo-nginx-module.git ../echo-nginx-module
git clone https://github.com/openresty/lua-resty-lrucache.git
git clone https://github.com/openresty/headers-more-nginx-module.git ../headers-more-nginx-module
git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git luajit2
git clone https://github.com/openresty/set-misc-nginx-module.git ../set-misc-nginx-module
git clone https://github.com/openresty/mockeagain.git
git clone https://github.com/openresty/test-nginx.git
git clone https://github.com/openresty/stream-lua-nginx-module.git ../stream-lua-nginx-module
# --- script ----------------------------------------------------------
- name: Build LuaJIT
run: |
cd luajit2
make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC \
XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2 -O1 -DLUAJIT_SECURITY_STRID=0 -DLUAJIT_SECURITY_STRHASH=0 -DLUAJIT_SECURITY_PRNG=0 -DLUAJIT_SECURITY_MCODE=0 -DLUAJIT_TEST_FIXED_ORDER' \
> build.log 2>&1 || (cat build.log && exit 1)
sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)
- name: Install lua-resty-lrucache
run: |
cd lua-resty-lrucache
sudo make DESTDIR=$LUAJIT_PREFIX LUA_LIB_DIR=/share/lua/5.1 install
- name: Build mockeagain
run: |
cd mockeagain
make CC=$CC -j$JOBS
- name: Build nginx
run: |
export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
ngx-build $NGINX_VERSION \
--with-http_v3_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-pcre-jit \
--with-cc-opt="-I$OPENSSL_INC -I$PCRE2_INC" \
--with-ld-opt="-L$OPENSSL_LIB -Wl,-rpath,$OPENSSL_LIB -L$PCRE2_LIB -Wl,-rpath,$PCRE2_LIB" \
--add-module=../ndk-nginx-module \
--add-module=../echo-nginx-module \
--add-module=../set-misc-nginx-module \
--add-module=../headers-more-nginx-module \
--add-module=../lua-nginx-module \
--with-debug \
--with-stream_ssl_module \
--with-stream \
--with-ipv6 \
--add-module=../stream-lua-nginx-module \
> build.log 2>&1 || (cat build.log && exit 1)
nginx -V
ldd `which nginx` | grep -E 'luajit|ssl|pcre'
- name: Run tests
env:
LD_PRELOAD: ${{ github.workspace }}/mockeagain/mockeagain.so
run: |
export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
export LD_LIBRARY_PATH=$PWD/mockeagain:$LD_LIBRARY_PATH
prove -I. -Itest-nginx/lib -j$JOBS -r t