Support “nightly-latest” version#13
Conversation
|
While you are at it, put in latest release as well |
| async function latestNightlyVersion() { | ||
| // Shamelessly copied and modified from dafny-lang/ide-vscode | ||
| // I'd prefer to use the GitHub API to list the assets under the "nightly" release, | ||
| // but @actions/github requires authentication. |
There was a problem hiding this comment.
Oh I suppose I can use GITHUB_TOKEN, true. Not sure how to refactor the tests to still work though.
Actually, I'm going to leave that out for now. It goes against repeatable builds, and especially in Dafny's case automatically picking up the latest version just means being forced to immediately deal with verification variability. |
|
Temporarily closing to conserve dafny-lang CI resources |
| const entries = stdout | ||
| .split("----------------") | ||
| .map((entry) => entry.split(/\r?\n/).filter((e) => e !== "")); | ||
| const dafnyEntry = entries.filter((entry) => entry[0] === "dafny")[0]; | ||
| const versionsIndex = dafnyEntry.findIndex((v) => v.startsWith("Versions:")); | ||
| const versions = dafnyEntry | ||
| .slice(versionsIndex + 1) | ||
| .map((versionLine) => versionLine.trimStart().split(" ")[0]); | ||
|
|
||
| const nightlies = versions.filter((l) => l.includes("nightly")); | ||
| const dates = nightlies.map((n, index) => { | ||
| const split = n.split("-"); | ||
| return { index, date: split[2] + split[3] + split[4] }; | ||
| }); | ||
| dates.sort((a, b) => (a.date < b.date ? 1 : -1)); | ||
| const toolVersion = nightlies[dates[0].index]; | ||
|
|
||
| // Slice off the "3.11.0.50201-" from 3.11.0.50201-nightly-2023-02-13-14bc57f, for e.g. | ||
| const version = toolVersion.slice(toolVersion.indexOf("-") + 1); | ||
|
|
||
| core.info(`Using latest nightly version: ${version}`); | ||
| return version; |
There was a problem hiding this comment.
This would be best refactored into a function that takes the string.
Then we can have a test with a hard coded string...
| // "install the latest 3.X version including prereleases". | ||
| const { exitCode, stdout, stderr } = await exec.getExecOutput( | ||
| "dotnet", | ||
| ["tool", "search", "Dafny", "--detail", "--prerelease"], |
There was a problem hiding this comment.
This pulls both dafny and the report, I would suggest --take 1
There is some way to query,
but I don't understand how to get the specific package ID.
https://learn.microsoft.com/en-us/nuget/api/search-query-service-resource#search-for-packages
There was a problem hiding this comment.
Yup, I wouldn't want to just --take 1 though, it feels brittle to depend on the order of results.
As per my comment I'd also prefer to use the NuGet API, will timebox attempting that.
| const entries = stdout | ||
| .split("----------------") | ||
| .map((entry) => entry.split(/\r?\n/).filter((e) => e !== "")); |
There was a problem hiding this comment.
Having only taken the first or removed the report generator
| const entries = stdout | |
| .split("----------------") | |
| .map((entry) => entry.split(/\r?\n/).filter((e) => e !== "")); | |
| const entries = stdout | |
| .split('\n') | |
| .filter(s => s.includes('-nightly-) | |
| .map(s => s.split('Downloads:')[0].trim()) |
|
|
||
| const nightlies = versions.filter((l) => l.includes("nightly")); | ||
| const dates = nightlies.map((n, index) => { | ||
| const split = n.split("-"); |
There was a problem hiding this comment.
You mean to compare a date,
so I would do that.
| const split = n.split("-"); | |
| const date = new Date(n.split('-').slice(2, 5).join('-')) |
| const split = n.split("-"); | ||
| return { index, date: split[2] + split[3] + split[4] }; | ||
| }); | ||
| dates.sort((a, b) => (a.date < b.date ? 1 : -1)); |
There was a problem hiding this comment.
I agree I don't think you care about equal
| const nightlies = versions.filter((l) => l.includes("nightly")); | ||
| const dates = nightlies.map((n, index) => { | ||
| const split = n.split("-"); | ||
| return { index, date: split[2] + split[3] + split[4] }; |
There was a problem hiding this comment.
I would just take the value n rather than the index...
Then you can just take the value right off the sorted dates
There was a problem hiding this comment.
Had that thought too when making this work initially :)
seebees
left a comment
There was a problem hiding this comment.
LGTM, I would refactor the search logic, but keeping it the same as the IDE is a good idea too.
Resolves #12