Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ghcup binary location #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
| `stack-setup-ghc` | If set, `enable-stack` must be set. Runs stack setup to install the specified GHC. (Note: setting this does _not_ imply `stack-no-global`.) | "boolean" | false/unset |
| `disable-matcher` | If set, disables match messages from GHC as GitHub CI annotations. | "boolean" | false/unset |
| `cabal-update` | If set to `false`, skip `cabal update` step. | `boolean` | `true` |
| `ghcup-release-channel` | If set, add a [release channel](https://www.haskell.org/ghcup/guide/#metadata) to ghcup. | `URL` | none |
| `ghcup-release-channel` | If set, add a [release channel](https://www.haskell.org/ghcup/guide/#metadata) to ghcup. | `URL` | none |

Note: "boolean" types are set/unset, not true/false.
That is, setting any "boolean" to a value other than the empty string (`""`) will be considered true/set.
Expand Down Expand Up @@ -228,6 +228,7 @@ and `ghc-exe` and `ghc-path` will be set accordingly.
| `stack-path` | The path of the `stack` executable _directory_ | string |
| `cabal-store` | The path to the cabal store | string |
| `stack-root` | The path to the stack root (equal to the `STACK_ROOT` environment variable if it is set; otherwise an OS-specific default) | string |
| `ghcup-command` | The path of the `ghcup` _executable_. Might not be an absolute file path. | string |

## Version Support

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ outputs:
description: 'The resolved version of stack'
ghc-exe:
description: 'The path of the ghc _executable_'
ghcup-command:
description: 'The path of the ghcup _executable_'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We should check whether the -exe outputs are indeed absolute paths.
  • The help text here should not say "path" but something like "The command to invoke ghcup (might not be an absolute path)".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check whether the -exe outputs are indeed absolute paths.

Any hints for writing a test? I don't see right away where such a test could be added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!

There is some code in CI that validates the -version outputs of the actions, maybe something similar could be done for the -exe outputs:

- name: Confirm resolved and installed versions match
shell: bash
run: |
CABALVER="$(cabal --numeric-version)"
GHCVER="$(ghc --numeric-version)"
echo "CABALVER=${CABALVER}" >> "${GITHUB_ENV}"
echo "GHCVER=${GHCVER}" >> "${GITHUB_ENV}"
if [[ "${{ steps.setup.outputs.ghc-version }}" == "latest-nightly" ]]
then

cabal-exe:
description: 'The path of the cabal _executable_'
stack-exe:
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js

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

7 changes: 6 additions & 1 deletion lib/installer.js

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

5 changes: 5 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function failed(tool: Tool, version: string): void {
throw new Error(`All install methods for ${tool} ${version} failed`);
}

export async function configureGhcupOutput(os: OS, arch: Arch): Promise<void> {
const bin = await ghcupBin(os, arch);
core.setOutput('ghcup-command', bin);
}

async function configureOutputs(
tool: Tool,
version: string,
Expand Down
9 changes: 8 additions & 1 deletion src/setup-haskell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import * as fs from 'fs';
import * as path from 'path';
import {EOL} from 'os';
import {getOpts, getDefaults, Tool} from './opts';
import {addGhcupReleaseChannel, installTool, resetTool} from './installer';
import {
addGhcupReleaseChannel,
configureGhcupOutput,
installTool,
resetTool
} from './installer';
import type {Arch, OS} from './opts';
import {exec} from '@actions/exec';

Expand Down Expand Up @@ -40,6 +45,8 @@ export default async function run(
core.debug(`run: os = ${JSON.stringify(os)}`);
core.debug(`run: opts = ${JSON.stringify(opts)}`);

await configureGhcupOutput(os, arch);

if (opts.ghcup.releaseChannel) {
await core.group(`Preparing ghcup environment`, async () =>
addGhcupReleaseChannel(opts.ghcup.releaseChannel!, os, arch)
Expand Down
Loading