Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

use ghcup on windows (clone of #192) #206

Merged
merged 19 commits into from
May 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP Fix GHC prerelease install on Windows
FinleyMcIlwaine authored and andreasabel committed Mar 13, 2023
commit 3140c9f4f0a97ef53ead6d124be2bf65b51df618
44 changes: 42 additions & 2 deletions setup/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions setup/lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions setup/lib/opts.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions setup/lib/opts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions setup/lib/setup-haskell.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions setup/src/installer.ts
Original file line number Diff line number Diff line change
@@ -91,8 +91,8 @@ async function isInstalled(
stack: [], // Always installed into the tool cache
cabal: {
win32: [ghcupPath],
linux: [aptPath],
darwin: []
linux: [ghcupPath, aptPath],
darwin: [ghcupPath]
}[os],
ghc: {
win32: [ghcupPath],
@@ -105,14 +105,22 @@ async function isInstalled(
core.info(`isInstalled whereis ${f}`);

for (const p of locations[tool]) {
core.info(`Attempting to access tool ${tool} at location ${p}`);
const installedPath = await afs
.access(p)
.then(() => p)
.catch(() => undefined);

if (installedPath == undefined) {
core.info(`Failed to access tool ${tool} at location ${p}`);
} else {
core.info(`Succeeded accessing tool ${tool} at location ${p}`);
}

if (installedPath) {
// Make sure that the correct ghc is used, even if ghcup has set a
// default prior to this action being ran.
core.info(`isInstalled installedPath: ${installedPath}`);
if (installedPath === ghcupPath) {
// If the result of this `ghcup set` is non-zero, the version we want
// is probably not actually installed
@@ -128,6 +136,7 @@ async function isInstalled(
.access(`${installedPath}/cabal-${version}`)
.then(() => p)
.catch(() => undefined);
core.info(`isInstalled cabalPath ${cabalPath}`);
if (cabalPath) {
return success(tool, version, installedPath, os);
}
28 changes: 28 additions & 0 deletions setup/src/opts.ts
Original file line number Diff line number Diff line change
@@ -35,6 +35,34 @@ export type Defaults = Record<Tool, Version> & {
general: {matcher: {enable: boolean}};
};

/**
* Reads the example `actions.yml` file and selects the `inputs` key. The result
* will be a key-value map of the following shape:
* ```
* {
* 'ghc-version': {
* required: false,
* description: '...',
* default: 'latest'
* },
* 'cabal-version': {
* required: false,
* description: '...',
* default: 'latest'
* },
* 'stack-version': {
* required: false,
* description: '...',
* default: 'latest'
* },
* 'enable-stack': {
* required: false,
* default: 'latest'
* },
* ...
* }
* ```
*/
export const yamlInputs: Record<string, {default: string}> = (
load(
readFileSync(join(__dirname, '..', 'action.yml'), 'utf8')
3 changes: 3 additions & 0 deletions setup/src/setup-haskell.ts
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@ export default async function run(
core.info('Preparing to setup a Haskell environment');
const os = process.platform as OS;
const opts = getOpts(getDefaults(os), os, inputs);
core.debug(`run: inputs = ${JSON.stringify(inputs)}`);
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);

if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () =>