|
| 1 | +name: Build and test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: ${{ matrix.name }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - name: "nginx 1.29.4 + OpenSSL" |
| 19 | + NGINX_VERSION: "1.29.4" |
| 20 | + |
| 21 | + services: |
| 22 | + redis: |
| 23 | + image: redis:7-alpine |
| 24 | + ports: |
| 25 | + - 6379:6379 |
| 26 | + |
| 27 | + env: |
| 28 | + JOBS: 3 |
| 29 | + NGX_BUILD_JOBS: 3 |
| 30 | + CC: gcc |
| 31 | + LUAJIT_PREFIX: /opt/luajit21 |
| 32 | + LUAJIT_LIB: /opt/luajit21/lib |
| 33 | + LUAJIT_INC: /opt/luajit21/include/luajit-2.1 |
| 34 | + LUA_INCLUDE_DIR: /opt/luajit21/include/luajit-2.1 |
| 35 | + PCRE2_PREFIX: /usr/local/openresty/pcre2 |
| 36 | + PCRE2_LIB: /usr/local/openresty/pcre2/lib |
| 37 | + PCRE2_INC: /usr/local/openresty/pcre2/include |
| 38 | + OPENSSL_PREFIX: /usr/local/openresty/openssl3 |
| 39 | + OPENSSL_LIB: /usr/local/openresty/openssl3/lib |
| 40 | + OPENSSL_INC: /usr/local/openresty/openssl3/include |
| 41 | + LIBDRIZZLE_LIB: /opt/drizzle/lib |
| 42 | + TEST_NGINX_SLEEP: "0.006" |
| 43 | + TEST_NGINX_SKIP_COSOCKET_LOG_TEST: "1" |
| 44 | + MALLOC_PERTURB_: "9" |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Install system packages |
| 50 | + run: | |
| 51 | + sudo apt-get update -q |
| 52 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 53 | + axel cpanminus \ |
| 54 | + libtest-base-perl libtext-diff-perl liburi-perl libwww-perl \ |
| 55 | + libtest-longstring-perl liblist-moreutils-perl \ |
| 56 | + libgd-dev wget \ |
| 57 | + lsb-release gnupg ca-certificates dnsutils |
| 58 | +
|
| 59 | + - name: Install Perl test modules |
| 60 | + run: | |
| 61 | + /usr/bin/env perl $(command -v cpanm) --sudo --notest \ |
| 62 | + Test::Nginx IPC::Run Test2::Util > build.log 2>&1 || (cat build.log && exit 1) |
| 63 | +
|
| 64 | + - name: Add OpenResty apt repository |
| 65 | + run: | |
| 66 | + wget -qO- https://openresty.org/package/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/openresty.gpg > /dev/null |
| 67 | + echo "deb [signed-by=/usr/share/keyrings/openresty.gpg] https://openresty.org/package/ubuntu $(lsb_release -sc) main" \ |
| 68 | + | sudo tee /etc/apt/sources.list.d/openresty.list |
| 69 | + sudo apt-get update -q |
| 70 | + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 71 | + openresty-pcre2 openresty-openssl3 openresty-pcre2-dev openresty-openssl3-dev |
| 72 | +
|
| 73 | + - name: Source code style check |
| 74 | + run: | |
| 75 | + ! grep -n -P '(?<=.{80}).+' --color $(find src -name '*.c') $(find . -name '*.h') \ |
| 76 | + || (echo "ERROR: Found C source lines exceeding 80 columns." >&2; exit 1) |
| 77 | + ! grep -n -P '\t+' --color $(find src -name '*.c') $(find . -name '*.h') \ |
| 78 | + || (echo "ERROR: Cannot use tabs." >&2; exit 1) |
| 79 | +
|
| 80 | + - name: Clone dependency repositories |
| 81 | + run: | |
| 82 | + # Sibling repos — build scripts reference them via $root/../<name> |
| 83 | + git clone --depth=1 https://github.com/openresty/openresty.git ../openresty |
| 84 | + git clone --depth=1 https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx |
| 85 | + git clone --depth=1 https://github.com/simpl/ngx_devel_kit.git ../ndk-nginx-module |
| 86 | + git clone --depth=1 https://github.com/openresty/lua-nginx-module.git ../lua-nginx-module |
| 87 | + git clone --depth=1 https://github.com/openresty/echo-nginx-module.git ../echo-nginx-module |
| 88 | + git clone --depth=1 https://github.com/openresty/memc-nginx-module.git ../memc-nginx-module |
| 89 | + git clone --depth=1 https://github.com/openresty/headers-more-nginx-module.git ../headers-more-nginx-module |
| 90 | + git clone --depth=1 https://github.com/openresty/lua-resty-core.git ../lua-resty-core |
| 91 | + git clone --depth=1 https://github.com/openresty/lua-resty-lrucache.git ../lua-resty-lrucache |
| 92 | +
|
| 93 | + # Local repos — used directly from the working directory |
| 94 | + git clone --depth=1 https://github.com/openresty/test-nginx.git |
| 95 | + git clone --depth=1 https://github.com/openresty/openresty-devel-utils.git |
| 96 | + git clone --depth=1 https://github.com/openresty/mockeagain.git |
| 97 | + git clone --depth=1 https://github.com/openresty/lua-cjson.git lua-cjson |
| 98 | + git clone -b v2.1-agentzh --depth=1 https://github.com/openresty/luajit2.git luajit2 |
| 99 | +
|
| 100 | + - name: Start memcached (native, UDP enabled) |
| 101 | + run: | |
| 102 | + sudo apt-get install -y --no-install-recommends memcached |
| 103 | + sudo systemctl stop memcached |
| 104 | + # Ubuntu's default /etc/memcached.conf has "-U 0" which disables UDP. |
| 105 | + # Start manually with UDP on port 11211 so udp-socket tests pass. |
| 106 | + memcached -d -l 127.0.0.1 -p 11211 -U 11211 -m 64 |
| 107 | + sudo ss -lntup | grep 11211 |
| 108 | +
|
| 109 | + - name: Set up network rules |
| 110 | + run: | |
| 111 | + sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT |
| 112 | + sudo iptables -I OUTPUT -p tcp --dst 127.0.0.2 --dport 12345 -j DROP |
| 113 | + sudo iptables -I OUTPUT -p udp --dst 127.0.0.2 --dport 12345 -j DROP |
| 114 | + sudo ip addr add 10.254.254.1/24 dev lo |
| 115 | + sudo ip addr add 10.254.254.2/24 dev lo |
| 116 | + sudo ip route add prohibit 0.0.0.1/32 |
| 117 | + sudo sysctl -w kernel.pid_max=10000 |
| 118 | +
|
| 119 | + - name: Build LuaJIT |
| 120 | + run: | |
| 121 | + cd luajit2 |
| 122 | + make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC \ |
| 123 | + XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2' \ |
| 124 | + > build.log 2>&1 || (cat build.log && exit 1) |
| 125 | + sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1) |
| 126 | +
|
| 127 | + - name: Build mockeagain |
| 128 | + run: cd mockeagain && make CC=$CC -j$JOBS |
| 129 | + |
| 130 | + - name: Build lua-cjson |
| 131 | + run: cd lua-cjson && make -j$JOBS && sudo make install |
| 132 | + |
| 133 | + - name: Build nginx |
| 134 | + run: | |
| 135 | + export LD_LIBRARY_PATH=$LUAJIT_LIB:$LD_LIBRARY_PATH |
| 136 | + export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH |
| 137 | + export NGX_BUILD_CC=$CC |
| 138 | + sh util/build.sh ${{ matrix.NGINX_VERSION }} > build.log 2>&1 || (cat build.log && exit 1) |
| 139 | + nginx -V |
| 140 | + ldd $(which nginx) | grep -E 'luajit|ssl|pcre' |
| 141 | +
|
| 142 | + - name: Run tests |
| 143 | + run: | |
| 144 | + export LD_LIBRARY_PATH=$LUAJIT_LIB:$PWD/mockeagain:$LD_LIBRARY_PATH |
| 145 | + export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH |
| 146 | + export LD_PRELOAD=$PWD/mockeagain/mockeagain.so |
| 147 | + export TEST_NGINX_RESOLVER=8.8.4.4 |
| 148 | + dig +short @$TEST_NGINX_RESOLVER openresty.org || exit 0 |
| 149 | + dig +short @$TEST_NGINX_RESOLVER agentzh.org || exit 0 |
| 150 | + /usr/bin/env perl $(command -v prove) -I. -Itest-nginx/lib -r t/ |
0 commit comments