Skip to content

Commit

Permalink
chore(build): build Kong binary for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP authored and fffonion committed Apr 27, 2023
1 parent baba594 commit 4d19e8d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 60 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Lint

on: [push, pull_request]
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
tests:
Expand Down
76 changes: 26 additions & 50 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,34 @@
name: Tests

on: [push, pull_request]
on: [pull_request]

env:
KONG_VERSION: master
BUILD_ROOT: ${{ github.workspace }}/kong/bazel-bin/build

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
tests:
name: Tests
runs-on: ubuntu-20.04

strategy:
matrix:
include:
# TODO: arm64
- openresty: "1.19.3.2"
luarocks: "3.7.0"
openssl: "1.1.1k"
- openresty: "1.19.9.1"
luarocks: "3.8.0"
openssl: "1.1.1m"
- openresty: "1.21.4.1"
luarocks: "3.9.1"
openssl: "1.1.1q"

env:
JOBS: 1 # must be 1 as socket tests interfere with each other

INSTALL_ROOT: /home/runner/work/install-root
DOWNLOAD_ROOT: /home/runner/work/download-root

OPENSSL_INSTALL: /home/runner/work/install-root/openssl
OPENSSL_DIR: /home/runner/work/install-root/openssl
OPENRESTY_INSTALL: /home/runner/work/install-root/openresty
LUAROCKS_INSTALL: /home/runner/work/install-root/luarocks

BUILD_TOOLS_DOWNLOAD: /home/runner/work/download-root/kong-build-tools
BUILD_TOOLS_BRANCH: master

OPENRESTY: ${{ matrix.openresty }}
LUAROCKS: ${{ matrix.luarocks }}
OPENSSL: ${{ matrix.openssl }}
build:
name: Build dependencies
runs-on: ubuntu-22.04

steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Checkout Kong source code
uses: actions/checkout@v3
with:
submodules: 'true'
repository: kong/kong
ref: ${{ env.KONG_VERSION }}
path: kong

- name: Setup cache
uses: actions/cache@v2
- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
with:
path: |
${{ env.BUILD_ROOT }}
Expand Down Expand Up @@ -96,7 +77,7 @@ jobs:
- name: Install packages
run: |
sudo apt update
sudo apt-get install -qq -y cpanminus net-tools libpcre3-dev build-essential valgrind
sudo apt install libyaml-dev valgrind libprotobuf-dev cpanminus net-tools libpcre3-dev build-essential
- name: Install Test::Nginx
run: |
Expand All @@ -109,21 +90,18 @@ jobs:
- name: Run Test
run: |
export PATH=$OPENSSL_INSTALL/bin:$OPENRESTY_INSTALL/nginx/sbin:$OPENRESTY_INSTALL/bin:$LUAROCKS_INSTALL/bin:$PATH
export LD_LIBRARY_PATH=$OPENSSL_INSTALL/lib:$LD_LIBRARY_PATH # for openssl's CLI invoked in the test suite
source ${{ env.BUILD_ROOT }}/kong-dev-venv.sh
nginx -V
resty -V
luarocks --version
openssl version
eval `luarocks path`
prove -j$JOBS -r t
prove -r t
- name: Run Test with Valgrind
run: |
export PATH=$OPENSSL_INSTALL/bin:$OPENRESTY_INSTALL/nginx/sbin:$OPENRESTY_INSTALL/bin:$LUAROCKS_INSTALL/bin:$PATH
export LD_LIBRARY_PATH=$OPENSSL_INSTALL/lib:$LD_LIBRARY_PATH # for openssl's CLI invoked in the test suite
source ${{ env.BUILD_ROOT }}/kong-dev-venv.sh
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
Expand All @@ -133,7 +111,5 @@ jobs:
luarocks --version
openssl version
eval `luarocks path`
# fail if definite leak found
prove -j$JOBS -r t 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0
prove -r t 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0
11 changes: 3 additions & 8 deletions t/005-indexed-var-openresty-suites.t
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,12 @@ variable not changeable
}
}
--- config
location =/balancer {
set $port '';
set_by_lua_block $port {
local args, _ = ngx.req.get_uri_args()
local port = args['port']
return port
}
location ~ /balancer/(?<target_port>\d+) {
set $port $target_port;
proxy_pass http://balancer;
}
--- pipelined_requests eval
["GET /balancer?port=8091", "GET /balancer?port=8092"]
["GET /balancer/8091", "GET /balancer/8092"]
--- response_body eval
["this is backend peer 8091", "this is backend peer 8092"]

Expand Down
1 change: 0 additions & 1 deletion t/008-log.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ ok
log.set_log_level(ngx.DEBUG, 2)
assert(log.get_log_level(ngx.WARN) == ngx.DEBUG)
ngx.update_time()
ngx.sleep(3)
assert(log.get_log_level(ngx.WARN) == ngx.WARN)
Expand Down

0 comments on commit 4d19e8d

Please sign in to comment.