Skip to content

Commit

Permalink
I feel pretty…
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws committed Oct 31, 2023
1 parent 97bdab9 commit ec99494
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6695,7 +6695,10 @@ const os = __nccwpck_require__(2037);
try {
const version = core.getInput("dafny-version", { required: true });
const distribution = getDistribution(os.platform(), version);
const { url, fullVersion } = await dafnyURLAndFullVersion(version, distribution);
const { url, fullVersion } = await dafnyURLAndFullVersion(
version,
distribution
);

core.info(`Dafny Version: ${fullVersion}`);
core.info(`Dafny Url: ${url}`);
Expand Down Expand Up @@ -6738,6 +6741,7 @@ exports.resolveNightlyVersionFromDotnetToolSearch =

async function dafnyURLAndFullVersion(version, distribution) {
const versionPath = version.startsWith("nightly") ? "nightly" : `v${version}`;
var fullVersion;
if (version.startsWith("nightly")) {
fullVersion = await resolveNightlyVersion(version);
// Slice off the "3.11.0.50201-" from 3.11.0.50201-nightly-2023-02-13-14bc57f, for e.g.
Expand Down Expand Up @@ -6799,7 +6803,9 @@ function resolveNightlyVersionFromDotnetToolSearch(output, nightlyVersion) {
dates.sort((a, b) => (a.date < b.date ? 1 : -1));
toolVersion = dates[0].nightly;
} else {
const matchingVersions = versions.filter((nightly) => nightly.includes(nightlyVersion));
const matchingVersions = versions.filter((nightly) =>
nightly.includes(nightlyVersion)
);
if (matchingVersions.length != 1) {
throw new Error(
`Did not find exactly one version matching ${nightlyVersion}: ${matchingVersions}"`
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const os = require("os");
try {
const version = core.getInput("dafny-version", { required: true });
const distribution = getDistribution(os.platform(), version);
const { url, fullVersion } = await dafnyURLAndFullVersion(version, distribution);
const { url, fullVersion } = await dafnyURLAndFullVersion(
version,
distribution
);

core.info(`Dafny Version: ${fullVersion}`);
core.info(`Dafny Url: ${url}`);
Expand Down Expand Up @@ -50,6 +53,7 @@ exports.resolveNightlyVersionFromDotnetToolSearch =

async function dafnyURLAndFullVersion(version, distribution) {
const versionPath = version.startsWith("nightly") ? "nightly" : `v${version}`;
var fullVersion;
if (version.startsWith("nightly")) {
fullVersion = await resolveNightlyVersion(version);
// Slice off the "3.11.0.50201-" from 3.11.0.50201-nightly-2023-02-13-14bc57f, for e.g.
Expand Down Expand Up @@ -111,7 +115,9 @@ function resolveNightlyVersionFromDotnetToolSearch(output, nightlyVersion) {
dates.sort((a, b) => (a.date < b.date ? 1 : -1));
toolVersion = dates[0].nightly;
} else {
const matchingVersions = versions.filter((nightly) => nightly.includes(nightlyVersion));
const matchingVersions = versions.filter((nightly) =>
nightly.includes(nightlyVersion)
);
if (matchingVersions.length != 1) {
throw new Error(
`Did not find exactly one version matching ${nightlyVersion}: ${matchingVersions}"`
Expand Down
13 changes: 10 additions & 3 deletions test/setup-dafny-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ describe("dafnyURLAndFullVersion", () => {
});

it("nightly usage", async () => {
const { url, fullVersion } = await dafnyURLAndFullVersion("nightly-2022-09-23-2bc0042", "ubuntu-16.04");
const { url, fullVersion } = await dafnyURLAndFullVersion(
"nightly-2022-09-23-2bc0042",
"ubuntu-16.04"
);
expect(url).to.equal(
"https://github.com/dafny-lang/dafny/releases/download/nightly/dafny-nightly-2022-09-23-2bc0042-x64-ubuntu-16.04.zip"
);
Expand All @@ -24,13 +27,17 @@ describe("dafnyURLAndFullVersion", () => {

it("latest nightly parsing logic", async () => {
const test = resolveNightlyVersionFromDotnetToolSearch(
sampleDotnetToolSearchOutput, "nightly-latest"
sampleDotnetToolSearchOutput,
"nightly-latest"
);
expect(test).to.equal("3.11.0.50201-nightly-2023-02-15-567a5ba");
});

it("latest nightly usage", async () => {
const { url, fullVersion } = await dafnyURLAndFullVersion("nightly-latest", "ubuntu-16.04");
const { url, fullVersion } = await dafnyURLAndFullVersion(
"nightly-latest",
"ubuntu-16.04"
);
expect(url).to.match(
/^https:\/\/github.com\/dafny-lang\/dafny\/releases\/download\/nightly\/dafny-nightly-/
);
Expand Down

0 comments on commit ec99494

Please sign in to comment.