-
Notifications
You must be signed in to change notification settings - Fork 10
216 lines (211 loc) · 7.33 KB
/
job-unit-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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Unit tests
on:
workflow_call:
inputs:
os:
required: true
type: string
cc:
required: true
type: string
ngx:
required: true
type: string
openresty:
required: true
type: string
runtime:
required: true
type: string
wasmtime:
required: true
type: string
wasmer:
required: true
type: string
v8:
required: true
type: string
ipc:
required: true
type: string
ssl:
required: true
type: string
debug:
required: true
type: string
hup:
required: true
type: string
wasm_target:
required: false
type: string
module_type:
required: true
type: string
coverage:
required: false
type: boolean
default: false
defaults:
run:
shell: bash
env:
CC: ${{ inputs.cc }}
NGX: ${{ inputs.ngx }}
NGX_IPC: ${{ inputs.ipc == 'ipc' && 1 || 0 }}
NGX_BUILD_OPENRESTY: ${{ inputs.openresty }}
NGX_BUILD_GCOV: ${{ inputs.coverage && 1 || 0 }}
NGX_BUILD_DEBUG: ${{ inputs.debug == 'debug' && 1 || 0 }}
NGX_BUILD_SSL: ${{ inputs.ssl == 'ssl' && 1 || 0 }}
NGX_BUILD_DYNAMIC_MODULE: ${{ inputs.module_type == 'dynamic' && 1 || 0 }}
TEST_NGINX_USE_HUP: ${{ inputs.hup == 'hup' && 1 || 0 }}
TEST_NGINX_TIMEOUT: 60
TEST_NGINX_EXTERNAL_TIMEOUT: 60s
TEST_NGINX_EXTERNAL_RESOLVER: 127.0.0.1:8053
TEST_NGINX_CARGO_RUSTTARGET: ${{ inputs.wasm_target }}
jobs:
tests:
name: 'Unit tests'
runs-on: ${{ inputs.os }}
timeout-minutes: 90
outputs:
coveralls_name: ${{ steps.lcov.outputs.name }}
steps:
- name: 'Setup deps - apt-get'
if: ${{ contains(inputs.os, 'ubuntu') }}
run: sudo apt-get update && sudo apt-get install -y ${CC} libstdc++-${CC#*-}-dev lcov
- name: 'Setup deps - macOS'
if: ${{ contains(inputs.os, 'macos') }}
run: brew install lcov
- uses: actions/checkout@v4
- name: 'Setup cache - rustup toolchain'
if: ${{ !env.ACT }}
uses: actions/cache@v4
with:
path: |
~/.rustup/settings.toml
~/.rustup/toolchains/*
~/.rustup/update-hashes/*
key: rust-toolchain-${{ inputs.os }}-${{ hashFiles('.github/**/*.yml', '.github/**/*.sh', 'rust-toolchain') }}
- name: 'Setup cache - work/ dir'
if: ${{ !env.ACT }}
uses: actions/cache@v4
with:
path: |
work/downloads
work/runtimes
work/openssl
key: work-${{ inputs.os }}-${{ inputs.cc }}-${{ inputs.ngx }}-${{ inputs.openresty }}-${{ inputs.runtime }}-${{ hashFiles('util/**/*.sh', 'util/**/*.pl', 'util/**/*.awk', '.github/**/*.yml', '.github/**/*.sh', '.github/**/*.js', 'rust-toolchain', 'Makefile') }}
- name: Setup Rust
if: ${{ !env.ACT }}
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-wasip1
- name: Add wasm32-unknown-unknown target
if: ${{ inputs.wasm_target == 'wasm32-unknown-unknown' }}
run: |
rustup target add wasm32-unknown-unknown
- name: Setup Go
if: ${{ !env.ACT }}
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Setup TinyGo
if: ${{ !env.ACT }}
uses: acifani/setup-tinygo@v2
with:
tinygo-version: 0.31.1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.9.0
- name: Setup Wasm runtime
run: ./util/runtime.sh -R ${{ inputs.runtime }} -V ${{ inputs[inputs.runtime] }}
- name: Setup local httpbin server
#if: ${{ !env.ACT }}
uses: ./.github/actions/setup-httpbin-server
with:
os: ${{ inputs.os }}
ghcr_username: ${{ github.repository_owner }}
ghcr_password: ${{ secrets.TOKEN_GITHUB }}
- name: Setup coredumps location
if: ${{ contains(inputs.os, 'ubuntu') }}
run: |
mkdir ${{ github.workspace }}/coredumps
sudo bash -c 'echo "${{ github.workspace }}/coredumps/%e.%p.%t" > /proc/sys/kernel/core_pattern'
- run: make setup
- run: make
- name: Run tests
run: |
ulimit -c unlimited
make test
- name: Run lcov
id: lcov
if: ${{ !env.ACT && inputs.coverage }}
run: |
case "$CC" in
clang*)
lcov --gcov-tool gcov --capture --directory work/buildroot --base-directory work/nginx-patched --output-file lcov.info
lcov --gcov-tool gcov --remove lcov.info "*/ngx_wasm_module/src/common/debug/*" --output-file lcov.info
lcov --gcov-tool gcov --extract lcov.info "*/ngx_wasm_module/src/*" --output-file lcov.info
;;
*)
lcov --gcov-tool gcov-${CC#*-} --capture --directory work/buildroot --output-file lcov.info
lcov --gcov-tool gcov-${CC#*-} --remove lcov.info "*/ngx_wasm_module/src/common/debug/*" --output-file lcov.info
lcov --gcov-tool gcov-${CC#*-} --extract lcov.info "*/ngx_wasm_module/src/*" --output-file lcov.info
;;
esac
name="unit"
if [ -n "${{ inputs.openresty }}" ]; then
name="$name-openresty_${{ inputs.openresty }}"
else
name="$name-ngx_${{ inputs.ngx }}"
fi
name="$name-${{ inputs.runtime }}"
name="$name-${{ inputs.ipc }}"
name="$name-${{ inputs.ssl }}"
name="$name-${{ inputs.debug }}"
name="$name-${{ inputs.hup }}"
if [ "${{ inputs.module_type }}" = dynamic ]; then
name="$name-dynamic"
else
name="$name-static"
fi
if [ -n "${{ inputs.wasm_target }}" ]; then
name="$name-${{ inputs.wasm_target }}"
fi
echo "name=$name" >> $GITHUB_OUTPUT
- name: Coveralls Upload
if: ${{ !env.ACT && inputs.coverage }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ steps.lcov.outputs.name }}
path-to-lcov: './lcov.info'
parallel: true
- name: Codecov Upload
if: ${{ !env.ACT && inputs.coverage }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: './lcov.info'
flags: unit
- run: rm -f t/servroot/html/nginx.sock
if: ${{ failure() && !env.ACT }}
- name: Artifacts Upload
uses: actions/upload-artifact@v4
if: ${{ failure() && !env.ACT }}
with:
name: ${{ github.job }}-sha-${{ github.sha }}-run-${{ github.run_number }}-${{ inputs.os }}-${{ inputs.ngx != '' && format('nginx-{0}', inputs.ngx) || format('openresty-{0}', inputs.openresty) }}-${{ inputs.runtime }}-${{ inputs.module_type == 'dynamic' && 'dynamic' || 'static'}}-${{ inputs.ipc }}-${{ inputs.ssl }}-${{ inputs.debug }}-${{ inputs.hup }}
path: |
work/buildroot/
t/servroot*
${{ github.workspace }}/coredumps
#- name: Setup tmate session
# if: ${{ failure() && !env.ACT }}
# uses: mxschmitt/action-tmate@v3
- name: Cleanup
if: ${{ always() }}
uses: ./.github/actions/cleanup