mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-16 22:17:59 +00:00
Removed false alarms & the metadata.txt diff from the build script (#1066)
This commit is contained in:
1 parent
45c3500623
commit
da0c4e6bd9
3 files changed
+81
-22
No files matched your search
@@ -259,7 +259,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
var foundIssue = false;
|
var foundIssue = false;
|
||||||
foreach (var buildOutputLine in dotnetBuildOutputLines)
|
foreach (var buildOutputLine in dotnetBuildOutputLines)
|
||||||
{
|
{
|
||||||
if(buildOutputLine.Contains(" error ") || buildOutputLine.Contains("#warning"))
|
if(IsDotnetBuildIssue(buildOutputLine))
|
||||||
{
|
{
|
||||||
if(!foundIssue)
|
if(!foundIssue)
|
||||||
{
|
{
|
||||||
@@ -348,7 +348,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
var foundRustIssue = false;
|
var foundRustIssue = false;
|
||||||
foreach (var buildOutputLine in rustBuildOutputLines)
|
foreach (var buildOutputLine in rustBuildOutputLines)
|
||||||
{
|
{
|
||||||
if(buildOutputLine.Contains("error", StringComparison.OrdinalIgnoreCase) || buildOutputLine.Contains("warning"))
|
if(IsRustBuildIssue(buildOutputLine))
|
||||||
{
|
{
|
||||||
if(!foundRustIssue)
|
if(!foundRustIssue)
|
||||||
{
|
{
|
||||||
@@ -372,6 +372,42 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a line of the .NET build output is an error or the warning of a #warning directive.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// MSBuild writes its diagnostics as "origin: error CODE: text" and keeps the keyword English in any
|
||||||
|
/// language. Looking for the word alone would also catch messages which merely mention an error.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="line">One line of the build output.</param>
|
||||||
|
/// <returns>True, when the line reports an issue.</returns>
|
||||||
|
private static bool IsDotnetBuildIssue(string line) => DotnetErrorRegex().IsMatch(line) || line.Contains("#warning", StringComparison.Ordinal);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a line of the Rust build output is an error or a warning.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Cargo and rustc start each diagnostic at the beginning of a line, with "error:", "error[", or "warning:".
|
||||||
|
/// Looking for these words anywhere would also catch the names of crates such as thiserror, which cargo
|
||||||
|
/// prints while compiling them. The note about dependencies which a future Rust version will reject also
|
||||||
|
/// starts with "warning:", yet it says nothing about this build. The Tauri CLI reports its own failures
|
||||||
|
/// with a right-aligned "Error" label.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="line">One line of the build output.</param>
|
||||||
|
/// <returns>True, when the line reports an issue.</returns>
|
||||||
|
private static bool IsRustBuildIssue(string line)
|
||||||
|
{
|
||||||
|
const string FUTURE_INCOMPATIBILITY_NOTE = "warning: the following packages contain code that will be rejected by a future version of Rust";
|
||||||
|
|
||||||
|
if (line.StartsWith(FUTURE_INCOMPATIBILITY_NOTE, StringComparison.Ordinal))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return line.StartsWith("error:", StringComparison.Ordinal)
|
||||||
|
|| line.StartsWith("error[", StringComparison.Ordinal)
|
||||||
|
|| line.StartsWith("warning:", StringComparison.Ordinal)
|
||||||
|
|| TauriErrorRegex().IsMatch(line);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task CreateNextChangelog(int currentBuildNumber, AppVersion currentAppVersion)
|
private async Task CreateNextChangelog(int currentBuildNumber, AppVersion currentAppVersion)
|
||||||
{
|
{
|
||||||
Console.Write("- Create the next changelog ...");
|
Console.Write("- Create the next changelog ...");
|
||||||
@@ -525,7 +561,6 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
|
|
||||||
return new(
|
return new(
|
||||||
metadataPath,
|
metadataPath,
|
||||||
metadataContent,
|
|
||||||
metadataLines,
|
metadataLines,
|
||||||
appVersion,
|
appVersion,
|
||||||
buildNumber,
|
buildNumber,
|
||||||
@@ -558,8 +593,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
releaseState.MetadataLines[BUILD_TIME_INDEX] = buildTimeString;
|
releaseState.MetadataLines[BUILD_TIME_INDEX] = buildTimeString;
|
||||||
releaseState.MetadataLines[BUILD_NUMBER_INDEX] = buildNumber.ToString(CultureInfo.InvariantCulture);
|
releaseState.MetadataLines[BUILD_NUMBER_INDEX] = buildNumber.ToString(CultureInfo.InvariantCulture);
|
||||||
releaseState.MetadataLines[COMMIT_HASH_INDEX] = $"{releaseState.HeadCommitHash}, release";
|
releaseState.MetadataLines[COMMIT_HASH_INDEX] = $"{releaseState.HeadCommitHash}, release";
|
||||||
var updatedMetadata = JoinLines(releaseState.MetadataContent, releaseState.MetadataLines);
|
await WriteMetadataLinesAsync(releaseState.MetadataPath, releaseState.MetadataLines);
|
||||||
await File.WriteAllTextAsync(releaseState.MetadataPath, updatedMetadata, Environment.UTF8_NO_BOM);
|
|
||||||
|
|
||||||
var updatedChangelogHeader = FormatChangelogHeader(releaseState.AppVersion, buildNumber, buildTime);
|
var updatedChangelogHeader = FormatChangelogHeader(releaseState.AppVersion, buildNumber, buildTime);
|
||||||
var updatedChangelog = ReplaceExactlyOnce(releaseState.ChangelogContent, releaseState.ChangelogHeader, updatedChangelogHeader);
|
var updatedChangelog = ReplaceExactlyOnce(releaseState.ChangelogContent, releaseState.ChangelogHeader, updatedChangelogHeader);
|
||||||
@@ -767,10 +801,20 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
return content.Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n');
|
return content.Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string JoinLines(string originalContent, string[] lines)
|
/// <summary>
|
||||||
|
/// Writes the metadata file with a line feed after each line, the last one included.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is the form in which the file is committed, and the build script of the Rust runtime writes it
|
||||||
|
/// the same way. File.WriteAllLinesAsync would end the lines with the line break of the current OS, so
|
||||||
|
/// that the file would change with the OS it was last built on.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="pathMetadata">The path of the metadata file.</param>
|
||||||
|
/// <param name="lines">The lines to write. An empty element after the final line break, as SplitLines leaves it, adds no empty line.</param>
|
||||||
|
private static async Task WriteMetadataLinesAsync(string pathMetadata, IEnumerable<string> lines)
|
||||||
{
|
{
|
||||||
var lineEnding = originalContent.Contains("\r\n", StringComparison.Ordinal) ? "\r\n" : "\n";
|
var metadata = string.Join('\n', lines).TrimEnd('\n') + '\n';
|
||||||
return string.Join(lineEnding, lines);
|
await File.WriteAllTextAsync(pathMetadata, metadata, Environment.UTF8_NO_BOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ReadPdfiumVersion()
|
private async Task<string> ReadPdfiumVersion()
|
||||||
@@ -794,7 +838,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.Write($"- Updating architecture to {rid.ToUserFriendlyName()} ...");
|
Console.Write($"- Updating architecture to {rid.ToUserFriendlyName()} ...");
|
||||||
lines[ARCHITECTURE_INDEX] = rid.AsMicrosoftRid();
|
lines[ARCHITECTURE_INDEX] = rid.AsMicrosoftRid();
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
Console.WriteLine(" done.");
|
Console.WriteLine(" done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +857,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updating commit hash from '{currentCommitHash}' to '{updatedCommitHash}'.");
|
Console.WriteLine($"- Updating commit hash from '{currentCommitHash}' to '{updatedCommitHash}'.");
|
||||||
lines[COMMIT_HASH_INDEX] = updatedCommitHash;
|
lines[COMMIT_HASH_INDEX] = updatedCommitHash;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<AppVersion> UpdateAppVersion(PrepareAction action, string? version = null)
|
private async Task<AppVersion> UpdateAppVersion(PrepareAction action, string? version = null)
|
||||||
@@ -876,7 +920,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updating app version from '{currentAppVersionLine}' to '{updatedAppVersion}'.");
|
Console.WriteLine($"- Updating app version from '{currentAppVersionLine}' to '{updatedAppVersion}'.");
|
||||||
|
|
||||||
lines[APP_VERSION_INDEX] = updatedAppVersion;
|
lines[APP_VERSION_INDEX] = updatedAppVersion;
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
|
|
||||||
return new(updatedAppVersion, newMajor, newMinor, newPatch);
|
return new(updatedAppVersion, newMajor, newMinor, newPatch);
|
||||||
}
|
}
|
||||||
@@ -935,7 +979,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updated Tauri version from {currentTauriVersion} to {updatedTauriVersion}.");
|
Console.WriteLine($"- Updated Tauri version from {currentTauriVersion} to {updatedTauriVersion}.");
|
||||||
lines[TAURI_VERSION_INDEX] = updatedTauriVersion;
|
lines[TAURI_VERSION_INDEX] = updatedTauriVersion;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateVectorStoreVersion()
|
private async Task UpdateVectorStoreVersion()
|
||||||
@@ -960,7 +1004,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updated vector store version from {currentVectorStoreVersion} to {updatedVectorStoreVersion}.");
|
Console.WriteLine($"- Updated vector store version from {currentVectorStoreVersion} to {updatedVectorStoreVersion}.");
|
||||||
lines[VECTOR_STORE_VERSION_INDEX] = updatedVectorStoreVersion;
|
lines[VECTOR_STORE_VERSION_INDEX] = updatedVectorStoreVersion;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateMudBlazorVersion()
|
private async Task UpdateMudBlazorVersion()
|
||||||
@@ -985,7 +1029,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updated MudBlazor version from {currentMudBlazorVersion} to {updatedMudBlazorVersion}.");
|
Console.WriteLine($"- Updated MudBlazor version from {currentMudBlazorVersion} to {updatedMudBlazorVersion}.");
|
||||||
lines[MUD_BLAZOR_VERSION_INDEX] = updatedMudBlazorVersion;
|
lines[MUD_BLAZOR_VERSION_INDEX] = updatedMudBlazorVersion;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateRustVersion()
|
private async Task UpdateRustVersion()
|
||||||
@@ -1009,7 +1053,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updated Rust version from {currentRustVersion} to {updatedRustVersion}.");
|
Console.WriteLine($"- Updated Rust version from {currentRustVersion} to {updatedRustVersion}.");
|
||||||
lines[RUST_VERSION_INDEX] = updatedRustVersion;
|
lines[RUST_VERSION_INDEX] = updatedRustVersion;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateDotnetVersion()
|
private async Task UpdateDotnetVersion()
|
||||||
@@ -1040,7 +1084,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
lines[DOTNET_VERSION_INDEX] = updatedDotnetVersion;
|
lines[DOTNET_VERSION_INDEX] = updatedDotnetVersion;
|
||||||
lines[DOTNET_SDK_VERSION_INDEX] = updatedDotnetSdkVersion;
|
lines[DOTNET_SDK_VERSION_INDEX] = updatedDotnetSdkVersion;
|
||||||
|
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IList<Match>> DetermineVersion(string name, string workingDirectory, Regex regex, string program, string command)
|
private async Task<IList<Match>> DetermineVersion(string name, string workingDirectory, Regex regex, string program, string command)
|
||||||
@@ -1126,7 +1170,7 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updating build number from '{lines[BUILD_NUMBER_INDEX]}' to '{buildNumber}'.");
|
Console.WriteLine($"- Updating build number from '{lines[BUILD_NUMBER_INDEX]}' to '{buildNumber}'.");
|
||||||
|
|
||||||
lines[BUILD_NUMBER_INDEX] = buildNumber.ToString();
|
lines[BUILD_NUMBER_INDEX] = buildNumber.ToString();
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
return buildNumber;
|
return buildNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,13 +1184,12 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
Console.WriteLine($"- Updating build time from '{lines[BUILD_TIME_INDEX]}' to '{buildTime}'.");
|
Console.WriteLine($"- Updating build time from '{lines[BUILD_TIME_INDEX]}' to '{buildTime}'.");
|
||||||
|
|
||||||
lines[BUILD_TIME_INDEX] = buildTime;
|
lines[BUILD_TIME_INDEX] = buildTime;
|
||||||
await File.WriteAllLinesAsync(pathMetadata, lines, Environment.UTF8_NO_BOM);
|
await WriteMetadataLinesAsync(pathMetadata, lines);
|
||||||
return buildTime;
|
return buildTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed record RebuildReleaseState(
|
private sealed record RebuildReleaseState(
|
||||||
string MetadataPath,
|
string MetadataPath,
|
||||||
string MetadataContent,
|
|
||||||
string[] MetadataLines,
|
string[] MetadataLines,
|
||||||
string AppVersion,
|
string AppVersion,
|
||||||
int BuildNumber,
|
int BuildNumber,
|
||||||
@@ -1200,6 +1243,14 @@ public sealed partial class UpdateMetadataCommands
|
|||||||
[GeneratedRegex("^[0-9a-fA-F]{40,64}$")]
|
[GeneratedRegex("^[0-9a-fA-F]{40,64}$")]
|
||||||
private static partial Regex GitCommitHashRegex();
|
private static partial Regex GitCommitHashRegex();
|
||||||
|
|
||||||
|
// Matches the category of an MSBuild error, e.g., "): error CS0103:", "MSBUILD : error MSB1009:", or "): error :":
|
||||||
|
[GeneratedRegex(""":\s*error(?:\s+[A-Z]+[0-9]+)?\s*:""")]
|
||||||
|
private static partial Regex DotnetErrorRegex();
|
||||||
|
|
||||||
|
// Matches the label of a Tauri CLI error, which is right-aligned to twelve characters:
|
||||||
|
[GeneratedRegex("""^\s+Error\s""")]
|
||||||
|
private static partial Regex TauriErrorRegex();
|
||||||
|
|
||||||
// Matches one Markdown link. The address may hold one level of parentheses, as Wikipedia addresses do:
|
// Matches one Markdown link. The address may hold one level of parentheses, as Wikipedia addresses do:
|
||||||
[GeneratedRegex("""\[(?<text>[^\[\]]+)\]\((?<address>(?:[^()\s]|\([^()\s]*\))+)\)""")]
|
[GeneratedRegex("""\[(?<text>[^\[\]]+)\]\((?<address>(?:[^()\s]|\([^()\s]*\))+)\)""")]
|
||||||
private static partial Regex MarkdownLinkRegex();
|
private static partial Regex MarkdownLinkRegex();
|
||||||
|
|||||||
+1
-1
@@ -9,4 +9,4 @@
|
|||||||
9f102728b59, release
|
9f102728b59, release
|
||||||
osx-arm64
|
osx-arm64
|
||||||
148.0.7763.0
|
148.0.7763.0
|
||||||
0.8.0
|
0.8.0
|
||||||
+10
-2
@@ -36,8 +36,16 @@ fn main() {
|
|||||||
let metadata = include_str!("../metadata.txt");
|
let metadata = include_str!("../metadata.txt");
|
||||||
let mut metadata_lines = metadata.lines().collect::<Vec<_>>();
|
let mut metadata_lines = metadata.lines().collect::<Vec<_>>();
|
||||||
metadata_lines[9] = rid;
|
metadata_lines[9] = rid;
|
||||||
let new_metadata = metadata_lines.join("\n");
|
|
||||||
std::fs::write("../metadata.txt", new_metadata).unwrap();
|
// Every line ends with a line break, the last one included. The build
|
||||||
|
// script of the .NET side writes the file the same way:
|
||||||
|
let mut new_metadata = metadata_lines.join("\n");
|
||||||
|
new_metadata.push('\n');
|
||||||
|
|
||||||
|
// Write only on a change to avoid unnecessary rewrites:
|
||||||
|
if new_metadata != metadata {
|
||||||
|
std::fs::write("../metadata.txt", new_metadata).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read the current version and update the
|
// Read the current version and update the
|
||||||
|
|||||||
Reference in new issue
Block a user