From d2cf328e4ed2ec9d86da9e2e073b4ec5439e2c12 Mon Sep 17 00:00:00 2001 From: Vinicius Mignot Date: Tue, 23 Jan 2024 14:53:01 -0300 Subject: [PATCH] fix(build): use NGX_WASM_MODULE_BRANCH environment variable (#12241) * fix(build): use NGX_WASM_MODULE_BRANCH env var * chore(changelog): update changelog * fix(build): force invalidation of wasm related env vars --- build/README.md | 3 --- build/kong_bindings.bzl | 4 ++++ build/openresty/wasmx/wasmx_repositories.bzl | 6 +++++- changelog/unreleased/kong/fix-wasm-module-branch.yml | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/kong/fix-wasm-module-branch.yml diff --git a/build/README.md b/build/README.md index 7f54803d68f..7e795dff777 100644 --- a/build/README.md +++ b/build/README.md @@ -195,9 +195,6 @@ time to control how the ngx_wasm_module repository is sourced: tells bazel to build from a branch rather than using the tag found in our `.requirements` file -**NOTE:** these environment variables currently do not integrate very well with -bazel's cache mechanism, so you may need to clear cache after changing their value. - ## Cross compiling Cross compiling is currently only tested on Ubuntu 22.04 x86_64 with following targeting platforms: diff --git a/build/kong_bindings.bzl b/build/kong_bindings.bzl index 006df8d9882..90353230f94 100644 --- a/build/kong_bindings.bzl +++ b/build/kong_bindings.bzl @@ -64,6 +64,9 @@ def _load_vars(ctx): ngx_wasm_module_remote = ctx.os.environ.get("NGX_WASM_MODULE_REMOTE", "https://github.com/Kong/ngx_wasm_module.git") content += '"NGX_WASM_MODULE_REMOTE": "%s",' % ngx_wasm_module_remote + ngx_wasm_module_branch = ctx.os.environ.get("NGX_WASM_MODULE_BRANCH", "") + content += '"NGX_WASM_MODULE_BRANCH": "%s",' % ngx_wasm_module_branch + ctx.file("BUILD.bazel", "") ctx.file("variables.bzl", "KONG_VAR = {\n" + content + "\n}") @@ -107,6 +110,7 @@ load_bindings = repository_rule( "INSTALL_DESTDIR", "RPM_SIGNING_KEY_FILE", "NFPM_RPM_PASSPHRASE", + "NGX_WASM_MODULE_BRANCH", "NGX_WASM_MODULE_REMOTE", ], ) diff --git a/build/openresty/wasmx/wasmx_repositories.bzl b/build/openresty/wasmx/wasmx_repositories.bzl index 26314f2ebec..fa00a087d4c 100644 --- a/build/openresty/wasmx/wasmx_repositories.bzl +++ b/build/openresty/wasmx/wasmx_repositories.bzl @@ -53,9 +53,13 @@ wasm_runtimes = { } def wasmx_repositories(): + wasm_module_branch = KONG_VAR["NGX_WASM_MODULE_BRANCH"] + if wasm_module_branch == "": + wasm_module_branch = KONG_VAR["NGX_WASM_MODULE"] + new_git_repository( name = "ngx_wasm_module", - branch = KONG_VAR["NGX_WASM_MODULE"], + branch = wasm_module_branch, remote = KONG_VAR["NGX_WASM_MODULE_REMOTE"], build_file_content = """ filegroup( diff --git a/changelog/unreleased/kong/fix-wasm-module-branch.yml b/changelog/unreleased/kong/fix-wasm-module-branch.yml new file mode 100644 index 00000000000..7e7092d5759 --- /dev/null +++ b/changelog/unreleased/kong/fix-wasm-module-branch.yml @@ -0,0 +1,3 @@ +message: use NGX_WASM_MODULE_BRANCH environment variable to set ngx_wasm_module repository branch when building Kong. +type: bugfix +scope: Core