Skip to content

Commit 1f566ee

Browse files
committed
tests: Replace travis ci with github actions
1 parent fb7710e commit 1f566ee

3 files changed

Lines changed: 166 additions & 106 deletions

File tree

.github/workflows/semantic-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Validate PR title
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: amannn/action-semantic-pull-request@v4
15+
- uses: amannn/action-semantic-pull-request@505e44b4f33b4c801f063838b3f053990ee46ea7 # v4.6.0
1616
env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
with:

.github/workflows/test.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
name: "nginx ${{ matrix.nginx }}"
14+
runs-on: ubuntu-22.04
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
# OPENSSL_VER/OPENSSL_PATCH_VER were only used by the (commented out)
20+
# OpenSSL-from-source build; the active CI uses the openresty-openssl3
21+
# package, so only the nginx version varies here.
22+
nginx:
23+
- 1.31.0
24+
25+
services:
26+
# Replaces Travis' `services: memcache`.
27+
memcached:
28+
image: memcached:1.6-alpine
29+
ports:
30+
- 11211:11211
31+
32+
env:
33+
JOBS: 2
34+
NGX_BUILD_JOBS: 2
35+
CC: gcc
36+
NGX_BUILD_CC: gcc
37+
LUAJIT_PREFIX: /opt/luajit21
38+
LUAJIT_LIB: /opt/luajit21/lib
39+
LUAJIT_INC: /opt/luajit21/include/luajit-2.1
40+
LUA_INCLUDE_DIR: /opt/luajit21/include/luajit-2.1
41+
LUA_CMODULE_DIR: /lib
42+
PCRE2_PREFIX: /usr/local/openresty/pcre2
43+
PCRE2_LIB: /usr/local/openresty/pcre2/lib
44+
PCRE2_INC: /usr/local/openresty/pcre2/include
45+
OPENSSL_PREFIX: /usr/local/openresty/openssl3
46+
OPENSSL_LIB: /usr/local/openresty/openssl3/lib
47+
OPENSSL_INC: /usr/local/openresty/openssl3/include
48+
LD_LIBRARY_PATH: /opt/luajit21/lib
49+
TEST_NGINX_SLEEP: 0.005
50+
TEST_NGINX_RANDOMIZE: 1
51+
TEST_NGINX_RESOLVER: 8.8.4.4
52+
LUACHECK_VER: 0.21.1
53+
NGINX_VERSION: ${{ matrix.nginx }}
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
58+
59+
- name: Cache downloads
60+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
61+
with:
62+
path: download-cache
63+
key: download-cache-${{ runner.os }}
64+
65+
- name: Install system dependencies
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y --no-install-recommends \
69+
axel luarocks daemonize lsb-release wget gnupg ca-certificates \
70+
cpanminus
71+
72+
# --- before_install --------------------------------------------------
73+
- name: Lint Lua sources
74+
run: |
75+
sudo luarocks install luacheck $LUACHECK_VER
76+
luacheck --globals coroutine -q .
77+
! grep -n -P '(?<=.{80}).+' --color `find . -name '*.lua'` \
78+
|| (echo "ERROR: Found Lua source lines exceeding 80 columns." > /dev/stderr; exit 1)
79+
! grep -n -P '\t+' --color `find . -name '*.lua'` \
80+
|| (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)
81+
82+
- name: Install Test::Nginx
83+
run: |
84+
sudo cpanm --notest Test::Nginx IPC::Run > build.log 2>&1 \
85+
|| (cat build.log && exit 1)
86+
87+
- name: Install openresty PCRE2 and OpenSSL
88+
run: |
89+
wget -O - https://openresty.org/package/pubkey.gpg \
90+
| sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg
91+
echo "deb [signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" \
92+
| sudo tee /etc/apt/sources.list.d/openresty.list
93+
sudo apt-get update
94+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
95+
openresty-pcre2 openresty-openssl3 openresty-pcre2-dev openresty-openssl3-dev
96+
97+
# --- install ---------------------------------------------------------
98+
- name: Clone dependencies
99+
run: |
100+
if [ ! -d download-cache ]; then mkdir download-cache; fi
101+
git clone https://github.com/openresty/openresty.git ../openresty
102+
git clone https://github.com/openresty/openresty-devel-utils.git
103+
git clone https://github.com/simpl/ngx_devel_kit.git ../ndk-nginx-module
104+
git clone https://github.com/openresty/lua-nginx-module.git ../lua-nginx-module
105+
git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
106+
git clone https://github.com/openresty/echo-nginx-module.git ../echo-nginx-module
107+
git clone https://github.com/openresty/lua-resty-lrucache.git
108+
git clone https://github.com/openresty/headers-more-nginx-module.git ../headers-more-nginx-module
109+
git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git luajit2
110+
git clone https://github.com/openresty/set-misc-nginx-module.git ../set-misc-nginx-module
111+
git clone https://github.com/openresty/mockeagain.git
112+
git clone https://github.com/openresty/test-nginx.git
113+
git clone https://github.com/openresty/stream-lua-nginx-module.git ../stream-lua-nginx-module
114+
115+
# --- script ----------------------------------------------------------
116+
- name: Build LuaJIT
117+
run: |
118+
cd luajit2
119+
make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC \
120+
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' \
121+
> build.log 2>&1 || (cat build.log && exit 1)
122+
sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)
123+
124+
- name: Install lua-resty-lrucache
125+
run: |
126+
cd lua-resty-lrucache
127+
sudo make DESTDIR=$LUAJIT_PREFIX LUA_LIB_DIR=/share/lua/5.1 install
128+
129+
- name: Build mockeagain
130+
run: |
131+
cd mockeagain
132+
make CC=$CC -j$JOBS
133+
134+
- name: Build nginx
135+
run: |
136+
export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
137+
ngx-build $NGINX_VERSION \
138+
--with-http_v3_module \
139+
--with-http_v2_module \
140+
--with-http_realip_module \
141+
--with-http_ssl_module \
142+
--with-pcre-jit \
143+
--with-cc-opt="-I$OPENSSL_INC -I$PCRE2_INC" \
144+
--with-ld-opt="-L$OPENSSL_LIB -Wl,-rpath,$OPENSSL_LIB -L$PCRE2_LIB -Wl,-rpath,$PCRE2_LIB" \
145+
--add-module=../ndk-nginx-module \
146+
--add-module=../echo-nginx-module \
147+
--add-module=../set-misc-nginx-module \
148+
--add-module=../headers-more-nginx-module \
149+
--add-module=../lua-nginx-module \
150+
--with-debug \
151+
--with-stream_ssl_module \
152+
--with-stream \
153+
--with-ipv6 \
154+
--add-module=../stream-lua-nginx-module \
155+
> build.log 2>&1 || (cat build.log && exit 1)
156+
nginx -V
157+
ldd `which nginx` | grep -E 'luajit|ssl|pcre'
158+
159+
- name: Run tests
160+
env:
161+
LD_PRELOAD: ${{ github.workspace }}/mockeagain/mockeagain.so
162+
run: |
163+
export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
164+
export LD_LIBRARY_PATH=$PWD/mockeagain:$LD_LIBRARY_PATH
165+
prove -I. -Itest-nginx/lib -j$JOBS -r t

.travis.yml

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)