268 lines
9.7 KiB
YAML
268 lines
9.7 KiB
YAML
name: Test Module Build
|
|
|
|
"on":
|
|
push:
|
|
branches:
|
|
- "**"
|
|
tags-ignore:
|
|
- "**"
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
TEST_BUILD_IMAGE: ubuntu:22.04
|
|
NGINX_CONFIGURE_ARGS: >-
|
|
--with-compat
|
|
--with-http_ssl_module
|
|
--with-http_stub_status_module
|
|
--with-http_realip_module
|
|
--with-http_v2_module
|
|
--with-http_gzip_static_module
|
|
|
|
jobs:
|
|
build-and-configure:
|
|
name: Nginx ${{ matrix.nginx-version }} (${{ matrix.target.name }})
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 90
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
nginx-version:
|
|
- "1.22.1"
|
|
- "1.24.0"
|
|
- "1.26.3"
|
|
- "1.28.0"
|
|
- "1.30.0"
|
|
target:
|
|
- name: linux-x86_64
|
|
platform: linux/amd64
|
|
- name: linux-arm64
|
|
platform: linux/arm64
|
|
- name: linux-armv7
|
|
platform: linux/arm/v7
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU for ARM tests
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64,arm
|
|
|
|
- name: Build, configure, and test routes
|
|
shell: bash
|
|
env:
|
|
NGINX_VERSION: ${{ matrix.nginx-version }}
|
|
TARGET_ARCH: ${{ matrix.target.name }}
|
|
DOCKER_PLATFORM: ${{ matrix.target.platform }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
docker run --rm \
|
|
--platform "$DOCKER_PLATFORM" \
|
|
-e NGINX_VERSION \
|
|
-e TARGET_ARCH \
|
|
-e NGINX_CONFIGURE_ARGS \
|
|
-v "$GITHUB_WORKSPACE:/work" \
|
|
-w /work \
|
|
"$TEST_BUILD_IMAGE" \
|
|
bash -s <<'CI_SCRIPT'
|
|
set -euo pipefail
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
ca-certificates \
|
|
curl \
|
|
file \
|
|
jq \
|
|
libpcre2-dev \
|
|
libssl-dev \
|
|
zlib1g-dev
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
build_jobs="$(nproc)"
|
|
if [[ "$TARGET_ARCH" != "linux-x86_64" && "$build_jobs" -gt 2 ]]; then
|
|
build_jobs=2
|
|
fi
|
|
|
|
nginx_root="/work/.ci-nginx/${TARGET_ARCH}"
|
|
runtime_root="/work/.ci-runtime/${TARGET_ARCH}/nginx-${NGINX_VERSION}"
|
|
archive="nginx-${NGINX_VERSION}.tar.gz"
|
|
archive_path="${nginx_root}/${archive}"
|
|
nginx_src="${nginx_root}/nginx-${NGINX_VERSION}"
|
|
module_path="${nginx_src}/objs/ngx_http_monitoring_module.so"
|
|
config_path="${runtime_root}/nginx.conf"
|
|
base_url="http://127.0.0.1:18080"
|
|
|
|
mkdir -p "$nginx_root"
|
|
if [[ ! -f "$archive_path" ]]; then
|
|
curl -fsSLo "$archive_path" \
|
|
"https://nginx.org/download/${archive}"
|
|
fi
|
|
|
|
rm -rf "$nginx_src" "$runtime_root"
|
|
tar -xzf "$archive_path" -C "$nginx_root"
|
|
|
|
cd "$nginx_src"
|
|
./configure \
|
|
--prefix=/usr/local/nginx \
|
|
--sbin-path=/usr/local/sbin/nginx \
|
|
--modules-path=/usr/local/nginx/modules \
|
|
--conf-path=/etc/nginx/nginx.conf \
|
|
--error-log-path=/var/log/nginx/error.log \
|
|
--http-log-path=/var/log/nginx/access.log \
|
|
--pid-path=/var/run/nginx.pid \
|
|
--lock-path=/var/run/nginx.lock \
|
|
--http-client-body-temp-path=/var/cache/nginx/client_temp \
|
|
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
|
|
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
|
|
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
|
|
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
|
|
$NGINX_CONFIGURE_ARGS \
|
|
--add-dynamic-module=/work
|
|
|
|
make -j"$build_jobs"
|
|
make -j"$build_jobs" modules
|
|
test -x objs/nginx
|
|
test -f "$module_path"
|
|
file objs/nginx
|
|
file "$module_path"
|
|
|
|
mkdir -p \
|
|
"$runtime_root/logs" \
|
|
"$runtime_root/temp/client_body" \
|
|
"$runtime_root/temp/proxy" \
|
|
"$runtime_root/temp/fastcgi" \
|
|
"$runtime_root/temp/uwsgi" \
|
|
"$runtime_root/temp/scgi"
|
|
|
|
{
|
|
printf 'load_module %s;\n\n' "$module_path"
|
|
printf 'worker_processes 1;\n'
|
|
printf 'error_log %s/logs/error.log info;\n' "$runtime_root"
|
|
printf 'pid %s/logs/nginx.pid;\n\n' "$runtime_root"
|
|
printf 'events {\n'
|
|
printf ' worker_connections 1024;\n'
|
|
printf '}\n\n'
|
|
printf 'http {\n'
|
|
printf ' access_log off;\n'
|
|
printf ' default_type application/octet-stream;\n'
|
|
printf ' client_body_temp_path %s/temp/client_body;\n' "$runtime_root"
|
|
printf ' proxy_temp_path %s/temp/proxy;\n' "$runtime_root"
|
|
printf ' fastcgi_temp_path %s/temp/fastcgi;\n' "$runtime_root"
|
|
printf ' uwsgi_temp_path %s/temp/uwsgi;\n' "$runtime_root"
|
|
printf ' scgi_temp_path %s/temp/scgi;\n\n' "$runtime_root"
|
|
printf ' monitor_refresh_interval 1s;\n'
|
|
printf ' monitor_history 1m;\n'
|
|
printf ' monitor_resolution 1s;\n'
|
|
printf ' monitor_shm_size 8m;\n'
|
|
printf ' monitor_collect_system on;\n'
|
|
printf ' monitor_collect_nginx on;\n'
|
|
printf ' monitor_collect_network on;\n'
|
|
printf ' monitor_access_log on;\n'
|
|
printf ' monitor_max_top_urls 100;\n\n'
|
|
printf ' server {\n'
|
|
printf ' listen 127.0.0.1:18080;\n'
|
|
printf ' server_name localhost;\n\n'
|
|
printf ' location /monitor {\n'
|
|
printf ' monitor on;\n'
|
|
printf ' monitor_dashboard on;\n'
|
|
printf ' monitor_api on;\n'
|
|
printf ' monitor_sse on;\n'
|
|
printf ' monitor_allow all;\n'
|
|
printf ' monitor_basic_auth off;\n'
|
|
printf ' monitor_cors off;\n'
|
|
printf ' monitor_rate_limit 120;\n'
|
|
printf ' }\n\n'
|
|
printf ' location / {\n'
|
|
printf ' return 200 "ok\\n";\n'
|
|
printf ' }\n'
|
|
printf ' }\n'
|
|
printf '}\n'
|
|
} > "$config_path"
|
|
|
|
"$nginx_src/objs/nginx" -t -p "$runtime_root" -c "$config_path"
|
|
|
|
cleanup() {
|
|
"$nginx_src/objs/nginx" -p "$runtime_root" -c "$config_path" -s quit || true
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
"$nginx_src/objs/nginx" -p "$runtime_root" -c "$config_path"
|
|
|
|
for attempt in $(seq 1 50); do
|
|
if curl -fsS "$base_url/" >/dev/null; then
|
|
break
|
|
fi
|
|
|
|
if [[ "$attempt" -eq 50 ]]; then
|
|
echo "Nginx did not become ready" >&2
|
|
exit 1
|
|
fi
|
|
|
|
sleep 0.2
|
|
done
|
|
|
|
curl -fsS "$base_url/" | grep -q '^ok'
|
|
|
|
dashboard="$(curl -fsS "$base_url/monitor")"
|
|
printf '%s' "$dashboard" | grep -q '<title>Nginx Monitor</title>'
|
|
printf '%s' "$dashboard" | grep -q '/monitor/api'
|
|
printf '%s' "$dashboard" | grep -q '/monitor/live'
|
|
|
|
curl -fsS "$base_url/monitor/api" \
|
|
| jq -e '.version == 1 and .scope == "full" and has("system") and has("nginx") and has("requests") and has("history")'
|
|
|
|
curl -fsS "$base_url/monitor/api/system" \
|
|
| jq -e '.version == 1 and .scope == "system" and has("system") and .system.cpu.cores >= 0'
|
|
|
|
curl -fsS "$base_url/monitor/api/nginx" \
|
|
| jq -e '.version == 1 and .scope == "nginx" and has("nginx") and .nginx.requests.total >= 0'
|
|
|
|
curl -fsS "$base_url/monitor/api/network" \
|
|
| jq -e '.version == 1 and .scope == "network" and has("network") and (.network.interfaces | type == "array")'
|
|
|
|
curl -fsS "$base_url/monitor/api/disk" \
|
|
| jq -e '.version == 1 and .scope == "disk" and has("disk") and (.disk.devices | type == "array")'
|
|
|
|
curl -fsS "$base_url/monitor/api/processes" \
|
|
| jq -e '.version == 1 and .scope == "processes" and has("processes") and .processes.process_count >= 0'
|
|
|
|
curl -fsS "$base_url/monitor/api/upstreams" \
|
|
| jq -e '.version == 1 and .scope == "upstreams" and (.upstreams | type == "array")'
|
|
|
|
curl -fsS "$base_url/monitor/api/connections" \
|
|
| jq -e '.version == 1 and .scope == "connections" and has("connections") and .connections.active >= 0'
|
|
|
|
curl -fsS "$base_url/monitor/api/requests" \
|
|
| jq -e '.version == 1 and .scope == "requests" and has("requests") and .requests.total >= 0'
|
|
|
|
curl -fsS "$base_url/monitor/health" \
|
|
| jq -e '.version == 1 and .scope == "health" and .status == "ok"'
|
|
|
|
curl -fsS "$base_url/monitor/metrics" \
|
|
| grep -q '^nginx_monitor_requests_total '
|
|
|
|
sse_output="$(timeout 5s curl -fsS -N "$base_url/monitor/live" || true)"
|
|
printf '%s' "$sse_output" | grep -q '^event: metrics'
|
|
printf '%s' "$sse_output" | grep -q '^data: {'
|
|
CI_SCRIPT
|
|
|
|
- name: Upload failed nginx logs
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nginx-${{ matrix.nginx-version }}-${{ matrix.target.name }}-test-logs
|
|
path: |
|
|
.ci-runtime/${{ matrix.target.name }}/nginx-${{ matrix.nginx-version }}/logs/*.log
|
|
.ci-runtime/${{ matrix.target.name }}/nginx-${{ matrix.nginx-version }}/nginx.conf
|
|
if-no-files-found: ignore
|