Skip to content

Commit

Permalink
[wasm] Fix chrome update script to use 'chromium dash', instead of 'o…
Browse files Browse the repository at this point in the history
…mahaproxy' (#92436)

* [wasm] Use chromium dash to get the versions, instead of the obsoleted

.. omahaproxy.

The older way to get versions hasn't been removed yet, to wait to see
how stable this method is.

* [wasm] update sln

* fix windows build
  • Loading branch information
radical committed Sep 22, 2023
1 parent 9ca60f5 commit a54ccf3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion eng/testing/bump-chrome-version.proj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</GetChromeVersions>

<GetChromeVersions
OSIdentifier="win"
OSIdentifier="Windows"
OSPrefix="Win_x64"
Channel="$(ChromeChannel)"
MaxMajorVersionsToCheck="1"
Expand Down
8 changes: 4 additions & 4 deletions eng/testing/wasm-provisioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
-->
<ChromeChannel>stable</ChromeChannel>

<ChromeOSIdentifier Condition="$([MSBuild]::IsOSPlatform('windows'))">win</ChromeOSIdentifier>
<ChromeOSIdentifier Condition="$([MSBuild]::IsOSPlatform('linux'))">linux</ChromeOSIdentifier>
<ChromeOSIdentifier Condition="$([MSBuild]::IsOSPlatform('windows'))">Windows</ChromeOSIdentifier>
<ChromeOSIdentifier Condition="$([MSBuild]::IsOSPlatform('linux'))">Linux</ChromeOSIdentifier>
<ChromeOSIdentifier Condition="'$(ChromeOSIdentifier)' == ''">unsupported-platform</ChromeOSIdentifier>

<!-- disable by default on unsupported platforms -->
Expand All @@ -25,7 +25,7 @@
<FirefoxBinaryName>firefox</FirefoxBinaryName>
</PropertyGroup>

<PropertyGroup Condition="'$(ChromeOSIdentifier)' == 'linux'">
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('linux'))">
<ChromeDirName>chrome-linux</ChromeDirName>
<ChromeDriverDirName>chromedriver_linux64</ChromeDriverDirName>
<ChromeBinaryName>chrome</ChromeBinaryName>
Expand All @@ -40,7 +40,7 @@
<ChromeDriverUrl>$(linux_ChromeBaseSnapshotUrl)/chromedriver_linux64.zip</ChromeDriverUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(ChromeOSIdentifier)' == 'win'">
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows'))">
<ChromeDirName>chrome-win</ChromeDirName>
<ChromeDriverDirName>chromedriver_win32</ChromeDriverDirName>
<ChromeBinaryName>chrome.exe</ChromeBinaryName>
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/wasm.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
{
"path": "../../tasks/WasmAppBuilder"
},
{
"path": "../../tasks/WasmBuildTasks"
}
],
"settings": {
Expand Down
34 changes: 33 additions & 1 deletion src/tasks/WasmBuildTasks/GetChromeVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.WebAssembly.Build.Tasks;

public class GetChromeVersions : MBU.Task
{
private const string s_fetchReleasesUrl = "https://chromiumdash.appspot.com/fetch_releases?channel={0}&num=1";
private const string s_allJsonUrl = "http://omahaproxy.appspot.com/all.json";
private const string s_snapshotBaseUrl = $"https://storage.googleapis.com/chromium-browser-snapshots";
private const string s_historyUrl = $"https://omahaproxy.appspot.com/history";
Expand Down Expand Up @@ -66,9 +67,10 @@ private async Task<bool> ExecuteInternalAsync()

try
{
(ChromeVersionSpec version, string baseUrl) = await FindVersionFromHistoryAsync().ConfigureAwait(false);
//(ChromeVersionSpec version, string baseUrl) = await FindVersionFromHistoryAsync().ConfigureAwait(false);
// For using all.json, use this instead:
// (ChromeVersionSpec version, string baseUrl) = await FindVersionFromAllJsonAsync().ConfigureAwait(false);
(ChromeVersionSpec version, string baseUrl) = await FindVersionFromChromiumDash().ConfigureAwait(false);

BaseSnapshotUrl = baseUrl;
ChromeVersion = version.version;
Expand Down Expand Up @@ -167,6 +169,34 @@ async IAsyncEnumerable<string> GetVersionsAsync()
}
}

private async Task<(ChromeVersionSpec version, string baseSnapshotUrl)> FindVersionFromChromiumDash()
{
using Stream stream = await GetDownloadFileStreamAsync("fetch_releases.json", string.Format(s_fetchReleasesUrl, Channel)).ConfigureAwait(false);

ChromiumDashRelease[]? releases = await JsonSerializer
.DeserializeAsync<ChromiumDashRelease[]>(stream)
.ConfigureAwait(false);
if (releases is null)
throw new LogAsErrorException($"Failed to read chrome versions from {s_fetchReleasesUrl}");

ChromiumDashRelease? foundRelease = releases.Where(rel => string.Equals(rel.platform, OSIdentifier, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();
if (foundRelease is null)
{
string availablePlatformIds = string.Join(", ", releases.Select(rel => rel.platform).Distinct().Order());
throw new LogAsErrorException($"Unknown Platform '{OSIdentifier}'. Platforms found " +
$"in fetch_releases.json: {availablePlatformIds}");
}

ChromeVersionSpec versionSpec = new(foundRelease.platform,
Channel,
foundRelease.version,
foundRelease.chromium_main_branch_position.ToString(),
foundRelease.version);
string? baseSnapshotUrl = await FindSnapshotUrlFromBasePositionAsync(versionSpec, throwIfNotFound: true)
.ConfigureAwait(false);
return (versionSpec, baseSnapshotUrl!);
}

private async Task<(ChromeVersionSpec versionSpec, string baseSnapshotUrl)> FindVersionFromAllJsonAsync()
{
using Stream stream = await GetDownloadFileStreamAsync("all.json", s_allJsonUrl).ConfigureAwait(false);
Expand Down Expand Up @@ -271,6 +301,8 @@ private async Task<Stream> GetDownloadFileStreamAsync(string filename, string ur
return null;
}

private sealed record ChromiumDashRelease(string channel, int chromium_main_branch_position, string milesone, string platform, string version);

private sealed record PerOSVersions(string os, ChromeVersionSpec[] versions);
private sealed record ChromeVersionSpec(string os, string channel, string version, string branch_base_position, string v8_version);
private sealed record ChromeDepsVersionSpec(string chromium_version, string chromium_base_position, string v8_version)
Expand Down

0 comments on commit a54ccf3

Please sign in to comment.