diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5332430..5431e44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] smlnj-version: [110.87, 110.97, 110.98] exclude: # SML/NJ versions before 110.94 do not support 64-bit @@ -22,5 +22,12 @@ jobs: - uses: ./ with: smlnj-version: ${{ matrix.smlnj-version }} - - run: | + - name: Test version output (Unix) + if: matrix.os != 'windows-latest' + run: | [[ $(sml @SMLversion) == "sml ${{ matrix.smlnj-version }}" ]] + - name: Test version output (Windows) + if: matrix.os == 'windows-latest' + run: | + # "$(sml @SMLversion)" -eq "sml ${{ matrix.smlnj-version }}" + Get-Command sml diff --git a/lib/installer.js b/lib/installer.js index 5b4f725..0afa7e5 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -38,19 +38,50 @@ function getNJ(version) { exports.getNJ = getNJ; function acquireNJ(version) { return __awaiter(this, void 0, void 0, function* () { - if (process.platform === "linux") { - // install required 32-bit support libraries - yield exec.exec("sudo", ["apt-get", "update"]); - yield exec.exec("sudo", [ - "apt-get", - "install", - "-y", - "--no-install-recommends", - "gcc-multilib", - "lib32ncurses5", - "lib32z1" - ]); + switch (process.platform) { + case "win32": + return acquireNJWindows(version); + case "linux": + return acquireNJLinux(version); + default: + return acquireNJUnix(version); } + }); +} +function acquireNJWindows(version) { + return __awaiter(this, void 0, void 0, function* () { + let downloadUrl = util.format("https://smlnj.org/dist/working/%s/smlnj-%s.msi", version, version); + core.debug("Downloading SML/NJ from: " + downloadUrl); + let downloadPath = null; + try { + downloadPath = yield tc.downloadTool(downloadUrl); + } + catch (error) { + core.debug(error); + throw `Failed to download version ${version}: ${error}`; + } + yield exec.exec("msiexec", ["/qn", "/i", downloadPath]); + return new Promise((resolve, _) => resolve(path.join("C:", "Program Files (x86)", "SMLNJ"))); + }); +} +function acquireNJLinux(version) { + return __awaiter(this, void 0, void 0, function* () { + // install required 32-bit support libraries + yield exec.exec("sudo", ["apt-get", "update"]); + yield exec.exec("sudo", [ + "apt-get", + "install", + "-y", + "--no-install-recommends", + "gcc-multilib", + "lib32ncurses5", + "lib32z1" + ]); + return acquireNJUnix(version); + }); +} +function acquireNJUnix(version) { + return __awaiter(this, void 0, void 0, function* () { let downloadUrl = util.format("http://smlnj.cs.uchicago.edu/dist/working/%s/config.tgz", version); core.debug("Downloading SML/NJ from: " + downloadUrl); let downloadPath = null; diff --git a/src/installer.ts b/src/installer.ts index 054ac70..3e080c1 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -20,20 +20,57 @@ export async function getNJ(version: string) { } async function acquireNJ(version: string): Promise { - if (process.platform === "linux") { - // install required 32-bit support libraries - await exec.exec("sudo", ["apt-get", "update"]); - await exec.exec("sudo", [ - "apt-get", - "install", - "-y", - "--no-install-recommends", - "gcc-multilib", - "lib32ncurses5", - "lib32z1" - ]); + switch (process.platform) { + case "win32": + return acquireNJWindows(version); + case "linux": + return acquireNJLinux(version); + default: + return acquireNJUnix(version); } +} + +async function acquireNJWindows(version: string): Promise { + let downloadUrl: string = util.format( + "https://smlnj.org/dist/working/%s/smlnj-%s.msi", + version, + version + ); + + core.debug("Downloading SML/NJ from: " + downloadUrl); + + let downloadPath: string | null = null; + try { + downloadPath = await tc.downloadTool(downloadUrl); + } catch (error) { + core.debug(error); + + throw `Failed to download version ${version}: ${error}`; + } + + await exec.exec("msiexec", ["/qn", "/i", downloadPath]); + return new Promise((resolve, _) => + resolve(path.join("C:", "Program Files (x86)", "SMLNJ")) + ); +} + +async function acquireNJLinux(version: string): Promise { + // install required 32-bit support libraries + await exec.exec("sudo", ["apt-get", "update"]); + await exec.exec("sudo", [ + "apt-get", + "install", + "-y", + "--no-install-recommends", + "gcc-multilib", + "lib32ncurses5", + "lib32z1" + ]); + + return acquireNJUnix(version); +} +async function acquireNJUnix(version: string): Promise { let downloadUrl: string = util.format( "http://smlnj.cs.uchicago.edu/dist/working/%s/config.tgz", version