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