Skip to content

Commit 7ef86ce

Browse files
committed
[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.
1 parent 4ad310d commit 7ef86ce

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

eng/testing/bump-chrome-version.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</GetChromeVersions>
1818

1919
<GetChromeVersions
20-
OSIdentifier="win"
20+
OSIdentifier="Windows"
2121
OSPrefix="Win_x64"
2222
Channel="$(ChromeChannel)"
2323
MaxMajorVersionsToCheck="1"

eng/testing/wasm-provisioning.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
-->
66
<ChromeChannel>stable</ChromeChannel>
77

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

1212
<!-- disable by default on unsupported platforms -->

src/tasks/WasmBuildTasks/GetChromeVersions.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.WebAssembly.Build.Tasks;
1818

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

6768
try
6869
{
69-
(ChromeVersionSpec version, string baseUrl) = await FindVersionFromHistoryAsync().ConfigureAwait(false);
70+
//(ChromeVersionSpec version, string baseUrl) = await FindVersionFromHistoryAsync().ConfigureAwait(false);
7071
// For using all.json, use this instead:
7172
// (ChromeVersionSpec version, string baseUrl) = await FindVersionFromAllJsonAsync().ConfigureAwait(false);
73+
(ChromeVersionSpec version, string baseUrl) = await FindVersionFromChromiumDash().ConfigureAwait(false);
7274

7375
BaseSnapshotUrl = baseUrl;
7476
ChromeVersion = version.version;
@@ -167,6 +169,34 @@ async IAsyncEnumerable<string> GetVersionsAsync()
167169
}
168170
}
169171

172+
private async Task<(ChromeVersionSpec version, string baseSnapshotUrl)> FindVersionFromChromiumDash()
173+
{
174+
using Stream stream = await GetDownloadFileStreamAsync("fetch_releases.json", string.Format(s_fetchReleasesUrl, Channel)).ConfigureAwait(false);
175+
176+
ChromiumDashRelease[]? releases = await JsonSerializer
177+
.DeserializeAsync<ChromiumDashRelease[]>(stream)
178+
.ConfigureAwait(false);
179+
if (releases is null)
180+
throw new LogAsErrorException($"Failed to read chrome versions from {s_fetchReleasesUrl}");
181+
182+
ChromiumDashRelease? foundRelease = releases.Where(rel => string.Equals(rel.platform, OSIdentifier, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();
183+
if (foundRelease is null)
184+
{
185+
string availablePlatformIds = string.Join(", ", releases.Select(rel => rel.platform).Distinct().Order());
186+
throw new LogAsErrorException($"Unknown Platform '{OSIdentifier}'. Platforms found " +
187+
$"in fetch_releases.json: {availablePlatformIds}");
188+
}
189+
190+
ChromeVersionSpec versionSpec = new(foundRelease.platform,
191+
Channel,
192+
foundRelease.version,
193+
foundRelease.chromium_main_branch_position.ToString(),
194+
foundRelease.version);
195+
string? baseSnapshotUrl = await FindSnapshotUrlFromBasePositionAsync(versionSpec, throwIfNotFound: true)
196+
.ConfigureAwait(false);
197+
return (versionSpec, baseSnapshotUrl!);
198+
}
199+
170200
private async Task<(ChromeVersionSpec versionSpec, string baseSnapshotUrl)> FindVersionFromAllJsonAsync()
171201
{
172202
using Stream stream = await GetDownloadFileStreamAsync("all.json", s_allJsonUrl).ConfigureAwait(false);
@@ -271,6 +301,8 @@ private async Task<Stream> GetDownloadFileStreamAsync(string filename, string ur
271301
return null;
272302
}
273303

304+
private sealed record ChromiumDashRelease(string channel, int chromium_main_branch_position, string milesone, string platform, string version);
305+
274306
private sealed record PerOSVersions(string os, ChromeVersionSpec[] versions);
275307
private sealed record ChromeVersionSpec(string os, string channel, string version, string branch_base_position, string v8_version);
276308
private sealed record ChromeDepsVersionSpec(string chromium_version, string chromium_base_position, string v8_version)

0 commit comments

Comments
 (0)