From fcae33d215abc61a2b8f3fd8951eb870c331d23a Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Sat, 3 Feb 2024 23:26:04 +0000 Subject: [PATCH 1/2] fix: show the actual deno cli version in `Deno.version` (cherry picked from commit b4b5b9ee3966af437469744b86839801416f4a1e) --- crates/base/src/deno_runtime.rs | 14 +++++++++++--- crates/cli/src/main.rs | 3 +++ crates/sb_core/js/bootstrap.js | 7 ++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/base/src/deno_runtime.rs b/crates/base/src/deno_runtime.rs index 5d995c7d8..51f5057a7 100644 --- a/crates/base/src/deno_runtime.rs +++ b/crates/base/src/deno_runtime.rs @@ -18,6 +18,7 @@ use deno_tls::rustls::RootCertStore; use deno_tls::RootCertStoreProvider; use futures_util::future::poll_fn; use log::{error, trace}; +use once_cell::sync::OnceCell; use sb_core::conn_sync::ConnSync; use sb_core::util::sync::AtomicFlag; use serde::de::DeserializeOwned; @@ -78,6 +79,8 @@ fn get_error_class_name(e: &AnyError) -> &'static str { sb_core::errors_rt::get_error_class_name(e).unwrap_or("Error") } +pub static MAYBE_DENO_VERSION: OnceCell = OnceCell::new(); + pub struct DenoRuntime { pub js_runtime: JsRuntime, pub env_vars: HashMap, // TODO: does this need to be pub? @@ -303,11 +306,16 @@ impl DenoRuntime { // Bootstrapping stage let script = format!( - "globalThis.bootstrapSBEdge({}, {}, {}, '{}')", + // opts, isUserWorker, isEventsWorker, edgeRuntimeVersion, denoVersion + "globalThis.bootstrapSBEdge({}, {}, {}, '{}', '{}')", deno_core::serde_json::json!({ "target": env!("TARGET") }), conf.is_user_worker(), conf.is_events_worker(), - version.unwrap_or("0.1.0") + version.unwrap_or("0.1.0"), + MAYBE_DENO_VERSION + .get() + .map(|it| &**it) + .unwrap_or("UNKNOWN") ); js_runtime @@ -903,7 +911,7 @@ mod test { .to_vec(); assert_eq!( deno_version_array.first().unwrap().as_str().unwrap(), - "supabase-edge-runtime-0.1.0" + "supabase-edge-runtime-0.1.0 (compatible with Deno vUNKNOWN)" ); assert_eq!( deno_version_array.get(1).unwrap().as_str().unwrap(), diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index ff70f1f6d..5e2c21d89 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -2,6 +2,7 @@ mod logger; use anyhow::{anyhow, bail, Error}; use base::commands::start_server; +use base::deno_runtime::MAYBE_DENO_VERSION; use base::rt_worker::worker_pool::{SupervisorPolicy, WorkerPoolPolicy}; use base::server::WorkerEntrypoints; use clap::builder::{FalseyValueParser, TypedValueParser}; @@ -102,6 +103,8 @@ fn cli() -> Command { //} fn main() -> Result<(), anyhow::Error> { + MAYBE_DENO_VERSION.get_or_init(|| env!("DENO_VERSION").to_string()); + let runtime = tokio::runtime::Builder::new_current_thread() .enable_all() .build() diff --git a/crates/sb_core/js/bootstrap.js b/crates/sb_core/js/bootstrap.js index a8526378c..13cd7cb25 100644 --- a/crates/sb_core/js/bootstrap.js +++ b/crates/sb_core/js/bootstrap.js @@ -233,7 +233,7 @@ const deleteDenoApis = (apis) => { }); }; -globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => { +globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, edgeRuntimeVersion, denoVersion) => { // We should delete this after initialization, // Deleting it during bootstrapping can backfire delete globalThis.__bootstrap; @@ -255,7 +255,8 @@ globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => { ...opts, }); - ObjectDefineProperty(globalThis, 'SUPABASE_VERSION', readOnly(String(version))); + ObjectDefineProperty(globalThis, 'SUPABASE_VERSION', readOnly(String(edgeRuntimeVersion))); + ObjectDefineProperty(globalThis, 'DENO_VERSION', readOnly(denoVersion)) // set these overrides after runtimeStart ObjectDefineProperties(denoOverrides, { @@ -265,7 +266,7 @@ globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => { args: readOnly([]), // args are set to be empty mainModule: getterOnly(() => ops.op_main_module()), version: getterOnly(() => ({ - deno: `supabase-edge-runtime-${globalThis.SUPABASE_VERSION}`, + deno: `supabase-edge-runtime-${globalThis.SUPABASE_VERSION} (compatible with Deno v${globalThis.DENO_VERSION})`, v8: '11.6.189.12', typescript: '5.1.6', })), From 1127ff1d8db043390c0efdab84cc229f887d0bff Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Mon, 5 Feb 2024 02:18:40 +0000 Subject: [PATCH 2/2] stamp: passing `GIT_V_VERSION` correctly --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6101f2f1..45ffeee73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,7 +61,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max build-args: | - GIT_V_VERSION=${{ steps.semantic.outputs.new_release_version }} + GIT_V_VERSION=${{ needs.release.outputs.version }} publish_arm: needs: @@ -103,6 +103,8 @@ jobs: platforms: linux/${{ env.arch }} tags: ${{ steps.meta.outputs.tags }} no-cache: true + build-args: | + GIT_V_VERSION=${{ needs.release.outputs.version }} merge_manifest: needs: [release, publish_x86, publish_arm]