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

Commit

Permalink
New outputs ghc/cabal/stack-version
Browse files Browse the repository at this point in the history
Fixes #77
  • Loading branch information
andreasabel committed May 6, 2023
1 parent 8ab495b commit 8e68a92
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 28 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ jobs:
- uses: actions/checkout@v3

- uses: ./setup
id: setup
with:
ghc-version: ${{ matrix.plan.ghc }}
ghcup-release-channel: ${{ matrix.ghcup_release_channel }}
Expand All @@ -152,6 +153,16 @@ jobs:
ghc --version
echo "$PATH"
- 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}"
[[ "${CABALVER}" == "${{ steps.setup.outputs.cabal-version }}" ]] && \
[[ "${GHCVER}" == "${{ steps.setup.outputs.ghc-version }}" ]]
- name: Test runghc
run: |
runghc --version
Expand Down Expand Up @@ -185,8 +196,6 @@ jobs:
# - ghc: major and minor version
# pure bash startsWith
run: |
CABALVER="$(cabal --numeric-version)"
GHCVER="$(ghc --numeric-version)"
if [[ "${{ matrix.plan.cabal }}" =~ ^([0-9]+\.[0-9]+) ]]; then cabalmajor="${BASH_REMATCH[1]}"; fi
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+) ]]; then ghcmajor="${BASH_REMATCH[1]}"; fi
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then ghcver="${BASH_REMATCH[1]}"; fi
Expand Down
30 changes: 19 additions & 11 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This action sets up a Haskell environment for use in actions by:

- if requested, installing a version of [ghc](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/) and [cabal](https://www.haskell.org/cabal/) and adding them to `PATH`,
- if requested, installing a version of [Stack](https://haskellstack.org) and adding it to the `PATH`,
- outputting of `ghc-exe/path`, `cabal-exe/path`, `stack-exe/path`, `stack-root` and `cabal-store` (for the requested components).
- outputting of `ghc-version/exe/path`, `cabal-version/exe/path`, `stack-version/exe/path`, `stack-root` and `cabal-store` (for the requested components).

The GitHub runners come with [pre-installed versions of GHC and Cabal](https://github.com/actions/runner-images).
Those will be used whenever possible.
Expand Down Expand Up @@ -211,16 +211,24 @@ In contrast, a proper `boolean` input like `cabal-update` only accepts values `t

## Outputs

| Name | Description | Type |
| ------------- | -------------------------------------------------------------------------------------------------------------------------- | ------ |
| `ghc-path` | The path of the ghc executable _directory_ | string |
| `cabal-path` | The path of the cabal executable _directory_ | string |
| `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 |
| `ghc-exe` | The path of the ghc _executable_ | string |
| `cabal-exe` | The path of the cabal _executable_ | string |
| `stack-exe` | The path of the stack _executable_ | string |
The action outputs parameters for the components it installed.
E.g. if `ghc-version: 8.10` is requested, the action will output `ghc-version: 8.10.7` if installation succeeded,
and `ghc-exe` and `ghc-path` will be set accordingly.
(Details on version resolution see next section.)

| Name | Description | Type |
| --------------- | -------------------------------------------------------------------------------------------------------------------------- | ------ |
| `ghc-version` | The resolved version of `ghc` | string |
| `cabal-version` | The resolved version of `cabal` | string |
| `stack-version` | The resolved version of `stack` | string |
| `ghc-exe` | The path of the `ghc` _executable_ | string |
| `cabal-exe` | The path of the `cabal` _executable_ | string |
| `stack-exe` | The path of the `stack` _executable_ | string |
| `ghc-path` | The path of the `ghc` executable _directory_ | string |
| `cabal-path` | The path of the `cabal` executable _directory_ | string |
| `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 |

## Version Support

Expand Down
18 changes: 12 additions & 6 deletions setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ inputs:
required: false
description: 'If specified, disables match messages from GHC as GitHub CI annotations.'
outputs:
ghc-version:
description: 'The resolved version of ghc'
cabal-version:
description: 'The resolved version of cabal'
stack-version:
description: 'The resolved version of stack'
ghc-exe:
description: 'The path of the ghc _executable_'
cabal-exe:
description: 'The path of the cabal _executable_'
stack-exe:
description: 'The path of the stack _executable_'
ghc-path:
description: 'The path of the ghc executable _directory_'
cabal-path:
Expand All @@ -47,12 +59,6 @@ outputs:
description: 'The path to the cabal store'
stack-root:
description: 'The path to the stack root (equal to the STACK_ROOT environment variable if it is set; otherwise an OS-specific default)'
ghc-exe:
description: 'The path of the ghc _executable_'
cabal-exe:
description: 'The path of the cabal _executable_'
stack-exe:
description: 'The path of the stack _executable_'
runs:
using: 'node16'
main: 'dist/index.js'
26 changes: 22 additions & 4 deletions setup/dist/index.js

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

5 changes: 3 additions & 2 deletions setup/lib/installer.js

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

1 change: 1 addition & 0 deletions setup/lib/opts.d.ts

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

21 changes: 19 additions & 2 deletions setup/lib/opts.js

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

4 changes: 3 additions & 1 deletion setup/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function failed(tool: Tool, version: string): void {

async function configureOutputs(
tool: Tool,
version: string,
path: string,
os: OS
): Promise<void> {
Expand All @@ -32,6 +33,7 @@ async function configureOutputs(
core.setOutput('stack-root', sr);
if (os === 'win32') core.exportVariable('STACK_ROOT', sr);
}
core.setOutput(`${tool}-version`, version);
}

async function success(
Expand All @@ -41,7 +43,7 @@ async function success(
os: OS
): Promise<true> {
core.addPath(path);
await configureOutputs(tool, path, os);
await configureOutputs(tool, version, path, os);
core.info(
`Found ${tool} ${version} in cache at path ${path}. Setup successful.`
);
Expand Down

0 comments on commit 8e68a92

Please sign in to comment.