refactor: consolidate compatibility JSON generation into Python script
Some checks failed
Test Module Build / Nginx 1.22.1 (linux-armv7) (push) Failing after 12m0s
Test Module Build / Nginx 1.22.1 (linux-x86_64) (push) Failing after 9m49s
Test Module Build / Nginx 1.22.1 (linux-arm64) (push) Failing after 13m7s
Test Module Build / Nginx 1.24.0 (linux-arm64) (push) Failing after 12m1s
Test Module Build / Nginx 1.24.0 (linux-armv7) (push) Failing after 11m56s
Test Module Build / Nginx 1.24.0 (linux-x86_64) (push) Failing after 9m46s
Test Module Build / Nginx 1.26.3 (linux-arm64) (push) Failing after 12m1s
Test Module Build / Nginx 1.26.3 (linux-armv7) (push) Failing after 12m1s
Test Module Build / Nginx 1.26.3 (linux-x86_64) (push) Failing after 9m46s
Test Module Build / Nginx 1.28.0 (linux-arm64) (push) Failing after 12m1s
Test Module Build / Nginx 1.28.0 (linux-armv7) (push) Failing after 12m0s
Test Module Build / Nginx 1.28.0 (linux-x86_64) (push) Failing after 9m45s
Test Module Build / Nginx 1.30.0 (linux-arm64) (push) Failing after 12m0s
Test Module Build / Nginx 1.30.0 (linux-armv7) (push) Failing after 12m1s
Test Module Build / Nginx 1.30.0 (linux-x86_64) (push) Failing after 9m45s
Test Module Build / Distro package compatibility (debian:12) (push) Failing after 6s
Test Module Build / Distro package compatibility (debian:13) (push) Failing after 8s
Test Module Build / Distro package compatibility (ubuntu:24.04) (push) Failing after 6s

This commit is contained in:
2026-06-10 02:26:50 +03:30
parent 256b21e25b
commit 05a62dfeb9

View File

@@ -345,95 +345,118 @@ dsc_sha256="$(sha256sum "$dsc_path" | awk '{ print $1 }')"
nginx_v_text="$metadata_dir/nginx-V.txt"
nginx -V > "$nginx_v_text" 2>&1
compatibility_json="$metadata_dir/compatibility.json"
jq -n \
--slurpfile nginxBuild "$nginx_build_info" \
--arg schema "1" \
--arg module "$MODULE_NAME" \
--arg debPackage "$DEB_PACKAGE_NAME" \
--arg debVersion "$deb_version" \
--arg releaseTag "$NEXT_TAG" \
--arg releaseVersion "$NEXT_VERSION" \
--arg previousTag "$LATEST_TAG" \
--arg gitRef "$GITHUB_REF" \
--arg gitSha "$GITHUB_SHA" \
--arg distroImage "$DISTRO_IMAGE" \
--arg dockerPlatform "$DOCKER_PLATFORM" \
--arg targetArch "$TARGET_ARCH" \
--arg osId "$distro_id" \
--arg osVersion "$distro_version" \
--arg osCodename "$distro_codename" \
--arg debArch "$deb_arch" \
--arg nginxBinaryPackage "$nginx_binary_package" \
--arg nginxBinaryVersion "$nginx_binary_version" \
--arg nginxSourcePackage "$source_package" \
--arg nginxSourceVersion "$source_version" \
--arg nginxAbi "$nginx_abi" \
--arg modulesPath "$modules_path" \
--arg dscPath "$(basename "$dsc_path")" \
--arg dscSha256 "$dsc_sha256" \
--arg moduleSha256 "$module_sha256" \
--arg builtAt "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg artifactBase "$artifact_base" \
--arg debFile "$deb_file" \
--arg tarballFile "$tarball_file" \
'{
schema: ($schema | tonumber),
module: $module,
release: {
tag: $releaseTag,
version: $releaseVersion,
previous_tag: $previousTag,
git_ref: $gitRef,
git_sha: $gitSha
},
target: {
os_id: $osId,
os_version: $osVersion,
os_codename: $osCodename,
architecture: $debArch,
requested_target: $targetArch,
docker_image: $distroImage,
docker_platform: $dockerPlatform
},
nginx: {
binary_package: $nginxBinaryPackage,
binary_version: $nginxBinaryVersion,
source_package: $nginxSourcePackage,
source_version: $nginxSourceVersion,
abi: $nginxAbi,
modules_path: $modulesPath,
build: $nginxBuild[0]
},
build: {
method: "distro-source-package",
dsc_file: $dscPath,
dsc_sha256: $dscSha256,
module_sha256: $moduleSha256,
built_at: $builtAt
},
artifacts: {
base_name: $artifactBase,
deb_package: $debPackage,
deb_version: $debVersion,
deb_file: $debFile,
tarball_file: $tarballFile,
compatibility_file: ($artifactBase + ".compatibility.json")
},
packaging: {
deb_depends: (
if $nginxAbi == "" then
[($nginxBinaryPackage + " (= " + $nginxBinaryVersion + ")"), "libc6"]
if [[ -n "$nginx_abi" ]]; then
deb_depends_json="$(
python3 -c 'import json, sys; print(json.dumps(sys.argv[1:]))' \
"$nginx_abi" \
"$nginx_binary_package (= $nginx_binary_version)" \
"libc6"
)"
else
[$nginxAbi, ($nginxBinaryPackage + " (= " + $nginxBinaryVersion + ")"), "libc6"]
end
)
deb_depends_json="$(
python3 -c 'import json, sys; print(json.dumps(sys.argv[1:]))' \
"$nginx_binary_package (= $nginx_binary_version)" \
"libc6"
)"
fi
compatibility_json="$metadata_dir/compatibility.json"
COMPATIBILITY_JSON="$compatibility_json" \
NGINX_BUILD_INFO="$nginx_build_info" \
SCHEMA=1 \
MODULE_NAME="$MODULE_NAME" \
DEB_PACKAGE_NAME="$DEB_PACKAGE_NAME" \
DEB_VERSION="$deb_version" \
NEXT_TAG="$NEXT_TAG" \
NEXT_VERSION="$NEXT_VERSION" \
LATEST_TAG="$LATEST_TAG" \
GITHUB_REF="$GITHUB_REF" \
GITHUB_SHA="$GITHUB_SHA" \
DISTRO_IMAGE="$DISTRO_IMAGE" \
DOCKER_PLATFORM="$DOCKER_PLATFORM" \
TARGET_ARCH="$TARGET_ARCH" \
OS_ID="$distro_id" \
OS_VERSION="$distro_version" \
OS_CODENAME="$distro_codename" \
DEB_ARCH="$deb_arch" \
NGINX_BINARY_PACKAGE="$nginx_binary_package" \
NGINX_BINARY_VERSION="$nginx_binary_version" \
NGINX_SOURCE_PACKAGE="$source_package" \
NGINX_SOURCE_VERSION="$source_version" \
NGINX_ABI="$nginx_abi" \
MODULES_PATH="$modules_path" \
DSC_PATH="$(basename "$dsc_path")" \
DSC_SHA256="$dsc_sha256" \
MODULE_SHA256="$module_sha256" \
BUILT_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
ARTIFACT_BASE="$artifact_base" \
DEB_FILE="$deb_file" \
TARBALL_FILE="$tarball_file" \
DEB_DEPENDS_JSON="$deb_depends_json" \
python3 - <<'PY'
import json
import os
with open(os.environ["NGINX_BUILD_INFO"], "r", encoding="utf-8") as f:
nginx_build = json.load(f)
artifact_base = os.environ["ARTIFACT_BASE"]
data = {
"schema": int(os.environ["SCHEMA"]),
"module": os.environ["MODULE_NAME"],
"release": {
"tag": os.environ["NEXT_TAG"],
"version": os.environ["NEXT_VERSION"],
"previous_tag": os.environ["LATEST_TAG"],
"git_ref": os.environ["GITHUB_REF"],
"git_sha": os.environ["GITHUB_SHA"],
},
"target": {
"os_id": os.environ["OS_ID"],
"os_version": os.environ["OS_VERSION"],
"os_codename": os.environ["OS_CODENAME"],
"architecture": os.environ["DEB_ARCH"],
"requested_target": os.environ["TARGET_ARCH"],
"docker_image": os.environ["DISTRO_IMAGE"],
"docker_platform": os.environ["DOCKER_PLATFORM"],
},
"nginx": {
"binary_package": os.environ["NGINX_BINARY_PACKAGE"],
"binary_version": os.environ["NGINX_BINARY_VERSION"],
"source_package": os.environ["NGINX_SOURCE_PACKAGE"],
"source_version": os.environ["NGINX_SOURCE_VERSION"],
"abi": os.environ["NGINX_ABI"],
"modules_path": os.environ["MODULES_PATH"],
"build": nginx_build,
},
"build": {
"method": "distro-source-package",
"dsc_file": os.environ["DSC_PATH"],
"dsc_sha256": os.environ["DSC_SHA256"],
"module_sha256": os.environ["MODULE_SHA256"],
"built_at": os.environ["BUILT_AT"],
},
"artifacts": {
"base_name": artifact_base,
"deb_package": os.environ["DEB_PACKAGE_NAME"],
"deb_version": os.environ["DEB_VERSION"],
"deb_file": os.environ["DEB_FILE"],
"tarball_file": os.environ["TARBALL_FILE"],
"compatibility_file": artifact_base + ".compatibility.json",
},
"packaging": {
"deb_depends": json.loads(os.environ["DEB_DEPENDS_JSON"]),
},
"validation": {
"packaged_nginx_config_test": False,
"packaged_nginx_endpoint_smoke": False,
},
validation: {
packaged_nginx_config_test: false,
packaged_nginx_endpoint_smoke: false
}
}' > "$compatibility_json"
with open(os.environ["COMPATIBILITY_JSON"], "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, sort_keys=True)
f.write("\n")
PY
cat > "$doc_dir/INSTALL.md" <<EOF
# ${MODULE_NAME} for ${distro_id} ${distro_version} ${deb_arch}
@@ -501,15 +524,28 @@ dpkg-deb --build --root-owner-group "$package_root" "$deb_path"
apt-get install -y --no-install-recommends "$deb_path"
validate_module "${modules_path}/${MODULE_NAME}.so" "$build_root/runtime"
jq \
--arg debFile "$deb_file" \
--arg validationTime "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
'.artifacts.deb_file = $debFile
| .validation.packaged_nginx_config_test = true
| .validation.packaged_nginx_endpoint_smoke = true
| .validation.validated_at = $validationTime' \
"$compatibility_json" > "$compatibility_json.tmp"
mv "$compatibility_json.tmp" "$compatibility_json"
COMPATIBILITY_JSON="$compatibility_json" \
DEB_FILE="$deb_file" \
VALIDATION_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
python3 - <<'PY'
import json
import os
path = os.environ["COMPATIBILITY_JSON"]
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
data["artifacts"]["deb_file"] = os.environ["DEB_FILE"]
data["validation"]["packaged_nginx_config_test"] = True
data["validation"]["packaged_nginx_endpoint_smoke"] = True
data["validation"]["validated_at"] = os.environ["VALIDATION_TIME"]
tmp = path + ".tmp"
with open(tmp, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, sort_keys=True)
f.write("\n")
os.replace(tmp, path)
PY
dpkg-deb --build --root-owner-group "$package_root" "$deb_path"
tar_root="$build_root/tar"