-
Notifications
You must be signed in to change notification settings - Fork 21
151 lines (124 loc) · 4.09 KB
/
tests.yml
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
name: Tests
on:
pull_request:
push:
env:
KONG_VERSION: feat-next-upstream
BUILD_ROOT: ${{ github.workspace }}/kong/bazel-bin/build
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
name: Build dependencies
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Checkout Kong source code
uses: actions/checkout@v3
with:
repository: kong/kong
ref: ${{ env.KONG_VERSION }}
path: kong
- name: Set the LUA_KONG_NGINX_MODULE in kong/.requirements
run: |
cd kong
branch=""
if [ ${{ github.event_name }} == 'pull_request' ]; then
branch=${GITHUB_HEAD_REF}
else
branch=${GITHUB_REF}
fi
branch=$(echo "$branch" | sed 's/\//\\\//g')
sed -i "s/LUA_KONG_NGINX_MODULE=.\+/LUA_KONG_NGINX_MODULE=${branch}/" .requirements
cat .requirements
- name: Lookup build cache
id: cache-deps
uses: actions/cache@v3
with:
path: |
${{ env.BUILD_ROOT }}
key: ${{ hashFiles('src/**', 'lualib/**', '.github/workflows/tests.yml', 'kong/.requirements') }}
- name: Install packages
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo apt update
sudo apt install libyaml-dev valgrind libprotobuf-dev cpanminus net-tools libpcre3-dev build-essential
- name: Build Kong
if: steps.cache-deps.outputs.cache-hit != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
cd kong
make build-kong
make build-venv
BUILD_PREFIX=$BUILD_ROOT/kong-dev
export PATH="$BUILD_PREFIX/bin:$BUILD_PREFIX/openresty/nginx/sbin:$BUILD_PREFIX/openresty/bin:$PATH"
chmod +rw -R $BUILD_PREFIX
nginx -V
ldd $(which nginx)
luarocks
test:
name: Test
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Checkout Kong source code
uses: actions/checkout@v3
with:
repository: kong/kong
ref: ${{ env.KONG_VERSION }}
path: kong
- name: Set the LUA_KONG_NGINX_MODULE in kong/.requirements
run: |
cd kong
branch=""
if [ ${{ github.event_name }} == 'pull_request' ]; then
branch=${GITHUB_HEAD_REF}
else
branch=${GITHUB_REF}
fi
branch=$(echo "$branch" | sed 's/\//\\\//g')
sed -i "s/LUA_KONG_NGINX_MODULE=.\+/LUA_KONG_NGINX_MODULE=${branch}/" .requirements
cat .requirements
- name: Load build cache
id: cache-deps
uses: actions/cache@v3
with:
path: |
${{ env.BUILD_ROOT }}
key: ${{ hashFiles('src/**', 'lualib/**', '.github/workflows/tests.yml', 'kong/.requirements') }}
- name: Install packages
run: |
sudo apt update
sudo apt install libyaml-dev valgrind libprotobuf-dev cpanminus net-tools libpcre3-dev build-essential
- name: Install Test::Nginx
run: |
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: Run Test
run: |
source ${{ env.BUILD_ROOT }}/kong-dev-venv.sh
nginx -V
resty -V
luarocks --version
openssl version
prove -r t
- name: Run Test with Valgrind
run: |
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
nginx -V
resty -V
luarocks --version
openssl version
# fail if definite leak found
prove -r t 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0