Showed the Rust compiler actually used on the information page (#1160)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-04 15:19:16 +01:00
1 parent 54c3f0b3e0
commit 677b650a79
9 files changed
+144 -17

No files matched your search

+24 -2
View File
@@ -1,3 +1,4 @@
use crate::metadata::RUST_VERSION;
use axum::http::StatusCode;
use axum::Json;
use log::{debug, error, info, warn};
@@ -126,6 +127,9 @@ pub struct RuntimeInfo {
pub executable_path: String,
pub linux_package_type: LinuxPackageType,
pub installation_kind: InstallationKind,
/// The Rust compiler which built the runtime, see `metadata::RUST_VERSION`.
pub rust_version: String,
}
pub async fn get_runtime_info() -> Json<RuntimeInfo> {
@@ -138,6 +142,7 @@ pub async fn get_runtime_info() -> Json<RuntimeInfo> {
.unwrap_or_default(),
linux_package_type: detect_linux_package_type(),
installation_kind: installation_kind(),
rust_version: RUST_VERSION.to_string(),
})
}
@@ -1419,7 +1424,7 @@ fn digits_of_hyphenated_guid(value: &str) -> Option<String> {
mod tests {
use super::{
canonical_enterprise_config_id, directory_is_writable, enterprise_env_key_suffix_ignoring_case,
enterprise_environment_key_name, enterprise_policy_file_slot_suffix,
enterprise_environment_key_name, enterprise_policy_file_slot_suffix, get_runtime_info,
has_managed_installation_marker,
is_windows_machine_wide_installation, is_windows_per_user_installation,
load_external_http_custom_root_certificate_policy_from_directories,
@@ -1430,7 +1435,7 @@ mod tests {
EnterpriseConfig, EnterpriseSourceData, EnterpriseSourceValue, EnterpriseSourceValues,
ExternalHttpCustomRootCertificatePolicy, InstallationKind, LinuxPackageType,
ENTERPRISE_ENV_CONFIG_ID_PREFIX, ENTERPRISE_ENV_CONFIG_SERVER_URL_PREFIX,
MANAGED_INSTALLATION_MARKER_FILE_NAME,
MANAGED_INSTALLATION_MARKER_FILE_NAME, RUST_VERSION,
};
use std::collections::HashMap;
use std::fs;
@@ -1473,6 +1478,23 @@ mod tests {
}
}
/// The information page of the app shows the Rust compiler which built the runtime. The
/// app reads it as `rust_version`, in the form of metadata.txt, which the build script
/// keeps: the version as the compiler names it, and the short hash of its commit.
#[tokio::test]
async fn runtime_info_names_the_rust_compiler_which_built_the_runtime() {
let runtime_info = get_runtime_info().await.0;
assert_eq!(serde_json::to_value(&runtime_info).unwrap()["rust_version"], RUST_VERSION);
let (version, commit) = RUST_VERSION
.strip_suffix(')')
.and_then(|rest| rest.split_once(" (commit "))
.unwrap_or_else(|| panic!("'{RUST_VERSION}' does not read '<version> (commit <hash>)'"));
assert!(version.starts_with(|character: char| character.is_ascii_digit()), "'{version}' is no version of the compiler");
assert!(!commit.is_empty() && commit.chars().all(|character| character.is_ascii_hexdigit()), "'{commit}' is no commit hash");
}
fn enterprise_config(
id: &str,
server_url: &str,
+11 -2
View File
@@ -3,6 +3,13 @@ use std::sync::Mutex;
pub static META_DATA: Lazy<Mutex<Option<MetaData>>> = Lazy::new(|| Mutex::new(None));
/// The Rust compiler which built the runtime, e.g., "1.99.1 (commit 58cf8f9c3)".
///
/// The build script asks the compiler itself. Line 6 of metadata.txt names
/// only the one our pipeline is supposed to use, while other builds, such
/// as the Flatpak, bring their own compiler.
pub const RUST_VERSION: &str = env!("AI_STUDIO_RUST_VERSION");
#[derive(Clone)]
pub struct MetaData {
pub app_version: String,
@@ -34,7 +41,9 @@ impl MetaData {
let build_number = metadata_lines.next().unwrap();
let dotnet_sdk_version = metadata_lines.next().unwrap();
let dotnet_version = metadata_lines.next().unwrap();
let rust_version = metadata_lines.next().unwrap();
// Skip the Rust compiler of the pipeline, see RUST_VERSION:
metadata_lines.next().unwrap();
let mud_blazor_version = metadata_lines.next().unwrap();
let tauri_version = metadata_lines.next().unwrap();
let app_commit_hash = metadata_lines.next().unwrap();
@@ -51,7 +60,7 @@ impl MetaData {
dotnet_sdk_version: dotnet_sdk_version.to_string(),
dotnet_version: dotnet_version.to_string(),
mud_blazor_version: mud_blazor_version.to_string(),
rust_version: rust_version.to_string(),
rust_version: RUST_VERSION.to_string(),
tauri_version: tauri_version.to_string(),
pdfium_version: pdfium_version.to_string(),
vector_store_version: vector_store_version.to_string(),