diff --git a/setup/dist/index.js b/setup/dist/index.js index 9c830802..39cc08c8 100644 --- a/setup/dist/index.js +++ b/setup/dist/index.js @@ -13309,11 +13309,9 @@ const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); const tc = __importStar(__nccwpck_require__(7784)); const fs_1 = __nccwpck_require__(7147); -const path_1 = __nccwpck_require__(1017); -const opts_1 = __nccwpck_require__(8131); const process_1 = __importDefault(__nccwpck_require__(7282)); const glob = __importStar(__nccwpck_require__(8090)); -const fs = __importStar(__nccwpck_require__(7147)); +// import * as fs from 'fs'; const compare_versions_1 = __nccwpck_require__(4773); // compareVersions can be used in the sense of > // Don't throw on non-zero. const exec = async (cmd, args) => (0, exec_1.exec)(cmd, args, { ignoreReturnCode: true }); @@ -13325,7 +13323,9 @@ async function configureOutputs(tool, path, os) { core.setOutput(`${tool}-exe`, await (0, io_1.which)(tool)); if (tool == 'stack') { const sr = process_1.default.env['STACK_ROOT'] ?? - (os === 'win32' ? 'C:\\sr' : `${process_1.default.env.HOME}/.stack`); + //(os === 'win32' ? 'C:\\sr' : + `${process_1.default.env.HOME}/.stack`; + //); core.setOutput('stack-root', sr); if (os === 'win32') core.exportVariable('STACK_ROOT', sr); @@ -13362,16 +13362,18 @@ async function isInstalled(tool, version, os) { const ghcupPath = `${process_1.default.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`; const v = aptVersion(tool, version); const aptPath = `/opt/${tool}/${v}/bin`; - const chocoPath = await getChocoPath(tool, version); + // const chocoPath = await getChocoPath(tool, version); const locations = { stack: [], cabal: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [], linux: [aptPath], darwin: [] }[os], ghc: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [ghcupPath], linux: [aptPath, ghcupPath], darwin: [ghcupPath] }[os] @@ -13389,7 +13391,8 @@ async function isInstalled(tool, version, os) { return success(tool, version, installedPath, os); } } - if (tool === 'cabal' && os !== 'win32') { + // if (tool === 'cabal' && os !== 'win32') { + if (tool === 'cabal') { const installedPath = await fs_1.promises .access(`${ghcupPath}/cabal-${version}`) .then(() => ghcupPath) @@ -13432,7 +13435,8 @@ async function installTool(tool, version, os) { await apt(tool, version); break; case 'win32': - await choco(tool, version); + await ghcup(tool, version, os); + // await choco(tool, version); break; case 'darwin': await ghcup(tool, version, os); @@ -13461,7 +13465,9 @@ async function resetTool(tool, _version, os) { await exec(bin, ['unset', tool]); return; case 'win32': - // We don't need to do anything here... yet + bin = await ghcupBin(os); + await exec(bin, ['unset', tool]); + // // We don't need to do anything here... yet return; } } @@ -13499,35 +13505,41 @@ async function apt(tool, version) { // Ignore the return code so we can fall back to ghcup await exec(`sudo -- sh -c "add-apt-repository -y ppa:hvr/ghc && apt-get update && apt-get -y install ${toolName}-${v}"`); } -async function choco(tool, version) { - core.info(`Attempting to install ${tool} ${version} using chocolatey`); - // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. - console.log('::stop-commands::SetupHaskellStopCommands'); - const args = [ - 'choco', - 'install', - tool, - '--version', - version, - '-m', - '--no-progress', - '-r' - ]; - if ((await exec('powershell', args)) !== 0) - await exec('powershell', [...args, '--pre']); - console.log('::SetupHaskellStopCommands::'); // Re-enable command execution - // Add GHC to path automatically because it does not add until the end of the step and we check the path. - const chocoPath = await getChocoPath(tool, version); - if (tool == 'ghc') - core.addPath(chocoPath); -} +// async function choco(tool: Tool, version: string): Promise { +// core.info(`Attempting to install ${tool} ${version} using chocolatey`); +// // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. +// console.log('::stop-commands::SetupHaskellStopCommands'); +// const args = [ +// 'choco', +// 'install', +// tool, +// '--version', +// version, +// '-m', +// '--no-progress', +// '-r' +// ]; +// if ((await exec('powershell', args)) !== 0) +// await exec('powershell', [...args, '--pre']); +// console.log('::SetupHaskellStopCommands::'); // Re-enable command execution +// // Add GHC to path automatically because it does not add until the end of the step and we check the path. +// const chocoPath = await getChocoPath(tool, version); +// if (tool == 'ghc') core.addPath(chocoPath); +// } async function ghcupBin(os) { - const cachedBin = tc.find('ghcup', opts_1.ghcup_version); - if (cachedBin) - return (0, path_1.join)(cachedBin, 'ghcup'); - const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/x86_64-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`); - await fs_1.promises.chmod(bin, 0o755); - return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup'); + return os ? 'ghcup' : 'ghcup'; // Always pre-installed + // const cachedBin = tc.find('ghcup', ghcup_version); + // if (cachedBin) return join(cachedBin, 'ghcup'); + // const bin = await tc.downloadTool( + // `https://downloads.haskell.org/ghcup/${ghcup_version}/x86_64-${ + // os === 'darwin' ? 'apple-darwin' : 'linux' + // }-ghcup-${ghcup_version}` + // ); + // await afs.chmod(bin, 0o755); + // return join( + // await tc.cacheFile(bin, 'ghcup', 'ghcup', ghcup_version), + // 'ghcup' + // ); } async function ghcup(tool, version, os) { core.info(`Attempting to install ${tool} ${version} using ghcup`); @@ -13549,24 +13561,29 @@ async function ghcupGHCHead() { if (returnCode === 0) await exec(bin, ['set', 'ghc', 'head']); } -async function getChocoPath(tool, version) { - // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon - // fallback to C:\\tools for now until variable is available - const chocoToolsLocation = process_1.default.env.ChocolateyToolsLocation ?? - (0, path_1.join)(`${process_1.default.env.SystemDrive}`, 'tools'); - // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) - let chocoToolPath = (0, path_1.join)(chocoToolsLocation, `${tool}-${version}`); - // choco packages GHC < 9.x - if (!fs.existsSync(chocoToolPath)) { - chocoToolPath = (0, path_1.join)(`${process_1.default.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`); - } - const pattern = `${chocoToolPath}/**/${tool}.exe`; - const globber = await glob.create(pattern); - for await (const file of globber.globGenerator()) { - return (0, path_1.dirname)(file); - } - return ''; -} +// async function getChocoPath(tool: Tool, version: string): Promise { +// // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon +// // fallback to C:\\tools for now until variable is available +// const chocoToolsLocation = +// process.env.ChocolateyToolsLocation ?? +// join(`${process.env.SystemDrive}`, 'tools'); +// // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) +// let chocoToolPath = join(chocoToolsLocation, `${tool}-${version}`); +// // choco packages GHC < 9.x +// if (!fs.existsSync(chocoToolPath)) { +// chocoToolPath = join( +// `${process.env.ChocolateyInstall}`, +// 'lib', +// `${tool}.${version}` +// ); +// } +// const pattern = `${chocoToolPath}/**/${tool}.exe`; +// const globber = await glob.create(pattern); +// for await (const file of globber.globGenerator()) { +// return dirname(file); +// } +// return ''; +// } /***/ }), @@ -13797,14 +13814,13 @@ async function run(inputs) { // Blindly appending is fine. // Cabal merges these and picks the last defined option. const configFile = await cabalConfig(); - if (process.platform === 'win32') { - fs.appendFileSync(configFile, `store-dir: C:\\sr${os_1.EOL}`); - core.setOutput('cabal-store', 'C:\\sr'); - } - else { - core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); - } - // Workaround the GHC nopie linking errors for ancient GHC verions + // if (process.platform === 'win32') { + // fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`); + // core.setOutput('cabal-store', 'C:\\sr'); + // } else { + core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); + // } + // Workaround the GHC nopie linking errors for ancient GHC versions // NB: Is this _just_ for GHC 7.10.3? if (opts.ghc.resolved === '7.10.3') { fs.appendFileSync(configFile, ['program-default-options', ' ghc-options: -optl-no-pie'].join(os_1.EOL) + os_1.EOL); @@ -14042,7 +14058,7 @@ module.exports = JSON.parse('{"win32":{"ghc":[{"from":"8.10.2","to":"8.10.2.2"}, /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"ghc":["9.4.2","9.4.1","9.2.4","9.2.3","9.2.2","9.2.1","9.0.2","9.0.1","8.10.7","8.10.6","8.10.5","8.10.4","8.10.3","8.10.2","8.10.1","8.8.4","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.8.1.0","3.6.2.0","3.6.0.0","3.4.1.0","3.4.0.0","3.2.0.0","3.0.0.0","2.4.1.0"],"stack":["2.9.3","2.9.1","2.7.5","2.7.3","2.7.1","2.5.1","2.3.3","2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"],"ghcup":["0.1.18.0"]}'); +module.exports = JSON.parse('{"ghc":["9.4.3","9.4.2","9.4.1","9.2.5","9.2.4","9.2.3","9.2.2","9.2.1","9.0.2","9.0.1","8.10.7","8.10.6","8.10.5","8.10.4","8.10.3","8.10.2","8.10.1","8.8.4","8.8.3","8.8.2","8.8.1","8.6.5","8.6.4","8.6.3","8.6.2","8.6.1","8.4.4","8.4.3","8.4.2","8.4.1","8.2.2","8.0.2","7.10.3"],"cabal":["3.8.1.0","3.6.2.0","3.6.0.0","3.4.1.0","3.4.0.0","3.2.0.0","3.0.0.0","2.4.1.0"],"stack":["2.9.3","2.9.1","2.7.5","2.7.3","2.7.1","2.5.1","2.3.3","2.3.1","2.1.3","2.1.1","1.9.3","1.9.1","1.7.1","1.6.5","1.6.3","1.6.1","1.5.1","1.5.0","1.4.0","1.3.2","1.3.0","1.2.0"],"ghcup":["0.1.18.0"]}'); /***/ }) diff --git a/setup/lib/installer.js b/setup/lib/installer.js index c39dfadc..84037763 100644 --- a/setup/lib/installer.js +++ b/setup/lib/installer.js @@ -32,11 +32,9 @@ const exec_1 = require("@actions/exec"); const io_1 = require("@actions/io"); const tc = __importStar(require("@actions/tool-cache")); const fs_1 = require("fs"); -const path_1 = require("path"); -const opts_1 = require("./opts"); const process_1 = __importDefault(require("process")); const glob = __importStar(require("@actions/glob")); -const fs = __importStar(require("fs")); +// import * as fs from 'fs'; const compare_versions_1 = require("compare-versions"); // compareVersions can be used in the sense of > // Don't throw on non-zero. const exec = async (cmd, args) => (0, exec_1.exec)(cmd, args, { ignoreReturnCode: true }); @@ -48,7 +46,9 @@ async function configureOutputs(tool, path, os) { core.setOutput(`${tool}-exe`, await (0, io_1.which)(tool)); if (tool == 'stack') { const sr = process_1.default.env['STACK_ROOT'] ?? - (os === 'win32' ? 'C:\\sr' : `${process_1.default.env.HOME}/.stack`); + //(os === 'win32' ? 'C:\\sr' : + `${process_1.default.env.HOME}/.stack`; + //); core.setOutput('stack-root', sr); if (os === 'win32') core.exportVariable('STACK_ROOT', sr); @@ -85,16 +85,18 @@ async function isInstalled(tool, version, os) { const ghcupPath = `${process_1.default.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`; const v = aptVersion(tool, version); const aptPath = `/opt/${tool}/${v}/bin`; - const chocoPath = await getChocoPath(tool, version); + // const chocoPath = await getChocoPath(tool, version); const locations = { stack: [], cabal: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [], linux: [aptPath], darwin: [] }[os], ghc: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [ghcupPath], linux: [aptPath, ghcupPath], darwin: [ghcupPath] }[os] @@ -112,7 +114,8 @@ async function isInstalled(tool, version, os) { return success(tool, version, installedPath, os); } } - if (tool === 'cabal' && os !== 'win32') { + // if (tool === 'cabal' && os !== 'win32') { + if (tool === 'cabal') { const installedPath = await fs_1.promises .access(`${ghcupPath}/cabal-${version}`) .then(() => ghcupPath) @@ -155,7 +158,8 @@ async function installTool(tool, version, os) { await apt(tool, version); break; case 'win32': - await choco(tool, version); + await ghcup(tool, version, os); + // await choco(tool, version); break; case 'darwin': await ghcup(tool, version, os); @@ -184,7 +188,9 @@ async function resetTool(tool, _version, os) { await exec(bin, ['unset', tool]); return; case 'win32': - // We don't need to do anything here... yet + bin = await ghcupBin(os); + await exec(bin, ['unset', tool]); + // // We don't need to do anything here... yet return; } } @@ -222,35 +228,41 @@ async function apt(tool, version) { // Ignore the return code so we can fall back to ghcup await exec(`sudo -- sh -c "add-apt-repository -y ppa:hvr/ghc && apt-get update && apt-get -y install ${toolName}-${v}"`); } -async function choco(tool, version) { - core.info(`Attempting to install ${tool} ${version} using chocolatey`); - // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. - console.log('::stop-commands::SetupHaskellStopCommands'); - const args = [ - 'choco', - 'install', - tool, - '--version', - version, - '-m', - '--no-progress', - '-r' - ]; - if ((await exec('powershell', args)) !== 0) - await exec('powershell', [...args, '--pre']); - console.log('::SetupHaskellStopCommands::'); // Re-enable command execution - // Add GHC to path automatically because it does not add until the end of the step and we check the path. - const chocoPath = await getChocoPath(tool, version); - if (tool == 'ghc') - core.addPath(chocoPath); -} +// async function choco(tool: Tool, version: string): Promise { +// core.info(`Attempting to install ${tool} ${version} using chocolatey`); +// // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. +// console.log('::stop-commands::SetupHaskellStopCommands'); +// const args = [ +// 'choco', +// 'install', +// tool, +// '--version', +// version, +// '-m', +// '--no-progress', +// '-r' +// ]; +// if ((await exec('powershell', args)) !== 0) +// await exec('powershell', [...args, '--pre']); +// console.log('::SetupHaskellStopCommands::'); // Re-enable command execution +// // Add GHC to path automatically because it does not add until the end of the step and we check the path. +// const chocoPath = await getChocoPath(tool, version); +// if (tool == 'ghc') core.addPath(chocoPath); +// } async function ghcupBin(os) { - const cachedBin = tc.find('ghcup', opts_1.ghcup_version); - if (cachedBin) - return (0, path_1.join)(cachedBin, 'ghcup'); - const bin = await tc.downloadTool(`https://downloads.haskell.org/ghcup/${opts_1.ghcup_version}/x86_64-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${opts_1.ghcup_version}`); - await fs_1.promises.chmod(bin, 0o755); - return (0, path_1.join)(await tc.cacheFile(bin, 'ghcup', 'ghcup', opts_1.ghcup_version), 'ghcup'); + return os ? 'ghcup' : 'ghcup'; // Always pre-installed + // const cachedBin = tc.find('ghcup', ghcup_version); + // if (cachedBin) return join(cachedBin, 'ghcup'); + // const bin = await tc.downloadTool( + // `https://downloads.haskell.org/ghcup/${ghcup_version}/x86_64-${ + // os === 'darwin' ? 'apple-darwin' : 'linux' + // }-ghcup-${ghcup_version}` + // ); + // await afs.chmod(bin, 0o755); + // return join( + // await tc.cacheFile(bin, 'ghcup', 'ghcup', ghcup_version), + // 'ghcup' + // ); } async function ghcup(tool, version, os) { core.info(`Attempting to install ${tool} ${version} using ghcup`); @@ -272,21 +284,26 @@ async function ghcupGHCHead() { if (returnCode === 0) await exec(bin, ['set', 'ghc', 'head']); } -async function getChocoPath(tool, version) { - // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon - // fallback to C:\\tools for now until variable is available - const chocoToolsLocation = process_1.default.env.ChocolateyToolsLocation ?? - (0, path_1.join)(`${process_1.default.env.SystemDrive}`, 'tools'); - // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) - let chocoToolPath = (0, path_1.join)(chocoToolsLocation, `${tool}-${version}`); - // choco packages GHC < 9.x - if (!fs.existsSync(chocoToolPath)) { - chocoToolPath = (0, path_1.join)(`${process_1.default.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`); - } - const pattern = `${chocoToolPath}/**/${tool}.exe`; - const globber = await glob.create(pattern); - for await (const file of globber.globGenerator()) { - return (0, path_1.dirname)(file); - } - return ''; -} +// async function getChocoPath(tool: Tool, version: string): Promise { +// // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon +// // fallback to C:\\tools for now until variable is available +// const chocoToolsLocation = +// process.env.ChocolateyToolsLocation ?? +// join(`${process.env.SystemDrive}`, 'tools'); +// // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) +// let chocoToolPath = join(chocoToolsLocation, `${tool}-${version}`); +// // choco packages GHC < 9.x +// if (!fs.existsSync(chocoToolPath)) { +// chocoToolPath = join( +// `${process.env.ChocolateyInstall}`, +// 'lib', +// `${tool}.${version}` +// ); +// } +// const pattern = `${chocoToolPath}/**/${tool}.exe`; +// const globber = await glob.create(pattern); +// for await (const file of globber.globGenerator()) { +// return dirname(file); +// } +// return ''; +// } diff --git a/setup/lib/setup-haskell.js b/setup/lib/setup-haskell.js index 480c16e0..1772baa6 100644 --- a/setup/lib/setup-haskell.js +++ b/setup/lib/setup-haskell.js @@ -64,14 +64,13 @@ async function run(inputs) { // Blindly appending is fine. // Cabal merges these and picks the last defined option. const configFile = await cabalConfig(); - if (process.platform === 'win32') { - fs.appendFileSync(configFile, `store-dir: C:\\sr${os_1.EOL}`); - core.setOutput('cabal-store', 'C:\\sr'); - } - else { - core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); - } - // Workaround the GHC nopie linking errors for ancient GHC verions + // if (process.platform === 'win32') { + // fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`); + // core.setOutput('cabal-store', 'C:\\sr'); + // } else { + core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); + // } + // Workaround the GHC nopie linking errors for ancient GHC versions // NB: Is this _just_ for GHC 7.10.3? if (opts.ghc.resolved === '7.10.3') { fs.appendFileSync(configFile, ['program-default-options', ' ghc-options: -optl-no-pie'].join(os_1.EOL) + os_1.EOL); diff --git a/setup/lib/versions.json b/setup/lib/versions.json index 8d05d114..b5194c8b 100644 --- a/setup/lib/versions.json +++ b/setup/lib/versions.json @@ -1,7 +1,9 @@ { "ghc": [ + "9.4.3", "9.4.2", "9.4.1", + "9.2.5", "9.2.4", "9.2.3", "9.2.2", diff --git a/setup/src/installer.ts b/setup/src/installer.ts index ef221850..edb446fe 100644 --- a/setup/src/installer.ts +++ b/setup/src/installer.ts @@ -3,11 +3,13 @@ import {exec as e} from '@actions/exec'; import {which} from '@actions/io'; import * as tc from '@actions/tool-cache'; import {promises as afs} from 'fs'; -import {join, dirname} from 'path'; -import {ghcup_version, OS, Tool} from './opts'; +// import {join, dirname} from 'path'; +// import {join} from 'path'; +// import {ghcup_version, OS, Tool} from './opts'; +import {OS, Tool} from './opts'; import process from 'process'; import * as glob from '@actions/glob'; -import * as fs from 'fs'; +// import * as fs from 'fs'; import {compareVersions} from 'compare-versions'; // compareVersions can be used in the sense of > // Don't throw on non-zero. @@ -28,7 +30,9 @@ async function configureOutputs( if (tool == 'stack') { const sr = process.env['STACK_ROOT'] ?? - (os === 'win32' ? 'C:\\sr' : `${process.env.HOME}/.stack`); + //(os === 'win32' ? 'C:\\sr' : + `${process.env.HOME}/.stack`; + //); core.setOutput('stack-root', sr); if (os === 'win32') core.exportVariable('STACK_ROOT', sr); } @@ -85,17 +89,19 @@ async function isInstalled( const v = aptVersion(tool, version); const aptPath = `/opt/${tool}/${v}/bin`; - const chocoPath = await getChocoPath(tool, version); + // const chocoPath = await getChocoPath(tool, version); const locations = { stack: [], // Always installed into the tool cache cabal: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [], linux: [aptPath], darwin: [] }[os], ghc: { - win32: [chocoPath], + // win32: [chocoPath], + win32: [ghcupPath], linux: [aptPath, ghcupPath], darwin: [ghcupPath] }[os] @@ -117,7 +123,8 @@ async function isInstalled( } } - if (tool === 'cabal' && os !== 'win32') { + // if (tool === 'cabal' && os !== 'win32') { + if (tool === 'cabal') { const installedPath = await afs .access(`${ghcupPath}/cabal-${version}`) .then(() => ghcupPath) @@ -166,7 +173,8 @@ export async function installTool( await apt(tool, version); break; case 'win32': - await choco(tool, version); + await ghcup(tool, version, os); + // await choco(tool, version); break; case 'darwin': await ghcup(tool, version, os); @@ -200,7 +208,9 @@ export async function resetTool( await exec(bin, ['unset', tool]); return; case 'win32': - // We don't need to do anything here... yet + bin = await ghcupBin(os); + await exec(bin, ['unset', tool]); + // // We don't need to do anything here... yet return; } } @@ -255,44 +265,45 @@ async function apt(tool: Tool, version: string): Promise { ); } -async function choco(tool: Tool, version: string): Promise { - core.info(`Attempting to install ${tool} ${version} using chocolatey`); - // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. - console.log('::stop-commands::SetupHaskellStopCommands'); - const args = [ - 'choco', - 'install', - tool, - '--version', - version, - '-m', - '--no-progress', - '-r' - ]; - if ((await exec('powershell', args)) !== 0) - await exec('powershell', [...args, '--pre']); - console.log('::SetupHaskellStopCommands::'); // Re-enable command execution - // Add GHC to path automatically because it does not add until the end of the step and we check the path. - - const chocoPath = await getChocoPath(tool, version); - - if (tool == 'ghc') core.addPath(chocoPath); -} +// async function choco(tool: Tool, version: string): Promise { +// core.info(`Attempting to install ${tool} ${version} using chocolatey`); +// // Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this. +// console.log('::stop-commands::SetupHaskellStopCommands'); +// const args = [ +// 'choco', +// 'install', +// tool, +// '--version', +// version, +// '-m', +// '--no-progress', +// '-r' +// ]; +// if ((await exec('powershell', args)) !== 0) +// await exec('powershell', [...args, '--pre']); +// console.log('::SetupHaskellStopCommands::'); // Re-enable command execution +// // Add GHC to path automatically because it does not add until the end of the step and we check the path. + +// const chocoPath = await getChocoPath(tool, version); + +// if (tool == 'ghc') core.addPath(chocoPath); +// } async function ghcupBin(os: OS): Promise { - const cachedBin = tc.find('ghcup', ghcup_version); - if (cachedBin) return join(cachedBin, 'ghcup'); - - const bin = await tc.downloadTool( - `https://downloads.haskell.org/ghcup/${ghcup_version}/x86_64-${ - os === 'darwin' ? 'apple-darwin' : 'linux' - }-ghcup-${ghcup_version}` - ); - await afs.chmod(bin, 0o755); - return join( - await tc.cacheFile(bin, 'ghcup', 'ghcup', ghcup_version), - 'ghcup' - ); + return os ? 'ghcup' : 'ghcup'; // Always pre-installed + // const cachedBin = tc.find('ghcup', ghcup_version); + // if (cachedBin) return join(cachedBin, 'ghcup'); + + // const bin = await tc.downloadTool( + // `https://downloads.haskell.org/ghcup/${ghcup_version}/x86_64-${ + // os === 'darwin' ? 'apple-darwin' : 'linux' + // }-ghcup-${ghcup_version}` + // ); + // await afs.chmod(bin, 0o755); + // return join( + // await tc.cacheFile(bin, 'ghcup', 'ghcup', ghcup_version), + // 'ghcup' + // ); } async function ghcup(tool: Tool, version: string, os: OS): Promise { @@ -315,31 +326,31 @@ async function ghcupGHCHead(): Promise { if (returnCode === 0) await exec(bin, ['set', 'ghc', 'head']); } -async function getChocoPath(tool: Tool, version: string): Promise { - // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon - // fallback to C:\\tools for now until variable is available - const chocoToolsLocation = - process.env.ChocolateyToolsLocation ?? - join(`${process.env.SystemDrive}`, 'tools'); - - // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) - let chocoToolPath = join(chocoToolsLocation, `${tool}-${version}`); - - // choco packages GHC < 9.x - if (!fs.existsSync(chocoToolPath)) { - chocoToolPath = join( - `${process.env.ChocolateyInstall}`, - 'lib', - `${tool}.${version}` - ); - } - - const pattern = `${chocoToolPath}/**/${tool}.exe`; - const globber = await glob.create(pattern); - - for await (const file of globber.globGenerator()) { - return dirname(file); - } - - return ''; -} +// async function getChocoPath(tool: Tool, version: string): Promise { +// // Environment variable 'ChocolateyToolsLocation' will be added to Hosted images soon +// // fallback to C:\\tools for now until variable is available +// const chocoToolsLocation = +// process.env.ChocolateyToolsLocation ?? +// join(`${process.env.SystemDrive}`, 'tools'); + +// // choco packages GHC 9.x are installed on different path (C:\\tools\ghc-9.0.1) +// let chocoToolPath = join(chocoToolsLocation, `${tool}-${version}`); + +// // choco packages GHC < 9.x +// if (!fs.existsSync(chocoToolPath)) { +// chocoToolPath = join( +// `${process.env.ChocolateyInstall}`, +// 'lib', +// `${tool}.${version}` +// ); +// } + +// const pattern = `${chocoToolPath}/**/${tool}.exe`; +// const globber = await glob.create(pattern); + +// for await (const file of globber.globGenerator()) { +// return dirname(file); +// } + +// return ''; +// } diff --git a/setup/src/setup-haskell.ts b/setup/src/setup-haskell.ts index 519dee7b..75a7e172 100644 --- a/setup/src/setup-haskell.ts +++ b/setup/src/setup-haskell.ts @@ -52,14 +52,14 @@ export default async function run( // Blindly appending is fine. // Cabal merges these and picks the last defined option. const configFile = await cabalConfig(); - if (process.platform === 'win32') { - fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`); - core.setOutput('cabal-store', 'C:\\sr'); - } else { - core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); - } + // if (process.platform === 'win32') { + // fs.appendFileSync(configFile, `store-dir: C:\\sr${EOL}`); + // core.setOutput('cabal-store', 'C:\\sr'); + // } else { + core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`); + // } - // Workaround the GHC nopie linking errors for ancient GHC verions + // Workaround the GHC nopie linking errors for ancient GHC versions // NB: Is this _just_ for GHC 7.10.3? if (opts.ghc.resolved === '7.10.3') { fs.appendFileSync( diff --git a/setup/src/versions.json b/setup/src/versions.json index 5c8362c2..d89e5693 100644 --- a/setup/src/versions.json +++ b/setup/src/versions.json @@ -1,7 +1,9 @@ { "ghc": [ + "9.4.3", "9.4.2", "9.4.1", + "9.2.5", "9.2.4", "9.2.3", "9.2.2",