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

Commit 6315d94

Browse files
committed
New outputs ghc/cabal/stack-version (resolved versions)
Fixes #77
1 parent 7bfeeb6 commit 6315d94

File tree

6 files changed

+51
-24
lines changed

6 files changed

+51
-24
lines changed

.github/workflows/workflow.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ jobs:
140140
- uses: actions/checkout@v3
141141

142142
- uses: ./setup
143+
id: setup
143144
with:
144145
ghc-version: ${{ matrix.plan.ghc }}
145146
ghcup-release-channel: ${{ matrix.ghcup_release_channel }}
@@ -152,6 +153,16 @@ jobs:
152153
ghc --version
153154
echo "$PATH"
154155
156+
- name: Confirm resolved and installed versions match
157+
shell: bash
158+
run: |
159+
CABALVER="$(cabal --numeric-version)"
160+
GHCVER="$(ghc --numeric-version)"
161+
echo "CABALVER=${CABALVER}" >> "${GITHUB_ENV}"
162+
echo "GHCVER=${GHCVER}" >> "${GITHUB_ENV}"
163+
[[ "${CABALVER}" == "${{ steps.setup.outputs.cabal-version }}" ]] && \
164+
[[ "${GHCVER}" == "${{ steps.setup.outputs.ghc-version }}" ]]
165+
155166
- name: Test runghc
156167
run: |
157168
runghc --version
@@ -185,8 +196,6 @@ jobs:
185196
# - ghc: major and minor version
186197
# pure bash startsWith
187198
run: |
188-
CABALVER="$(cabal --numeric-version)"
189-
GHCVER="$(ghc --numeric-version)"
190199
if [[ "${{ matrix.plan.cabal }}" =~ ^([0-9]+\.[0-9]+) ]]; then cabalmajor="${BASH_REMATCH[1]}"; fi
191200
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+) ]]; then ghcmajor="${BASH_REMATCH[1]}"; fi
192201
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then ghcver="${BASH_REMATCH[1]}"; fi

setup/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This action sets up a Haskell environment for use in actions by:
66

77
- 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`,
88
- if requested, installing a version of [Stack](https://haskellstack.org) and adding it to the `PATH`,
9-
- outputting of `ghc-exe/path`, `cabal-exe/path`, `stack-exe/path`, `stack-root` and `cabal-store` (for the requested components).
9+
- outputting of `ghc-version/exe/path`, `cabal-version/exe/path`, `stack-version/exe/path`, `stack-root` and `cabal-store` (for the requested components).
1010

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

212212
## Outputs
213213

214-
| Name | Description | Type |
215-
| ------------- | -------------------------------------------------------------------------------------------------------------------------- | ------ |
216-
| `ghc-path` | The path of the ghc executable _directory_ | string |
217-
| `cabal-path` | The path of the cabal executable _directory_ | string |
218-
| `stack-path` | The path of the stack executable _directory_ | string |
219-
| `cabal-store` | The path to the cabal store | string |
220-
| `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 |
221-
| `ghc-exe` | The path of the ghc _executable_ | string |
222-
| `cabal-exe` | The path of the cabal _executable_ | string |
223-
| `stack-exe` | The path of the stack _executable_ | string |
214+
The action outputs parameters for the components it installed.
215+
E.g. if `ghc-version: 8.10` is requested, the action will output `ghc-version: 8.10.7` if installation succeeded,
216+
and `ghc-exe` and `ghc-path` will be set accordingly.
217+
(Details on version resolution see next section.)
218+
219+
| Name | Description | Type |
220+
| --------------- | -------------------------------------------------------------------------------------------------------------------------- | ------ |
221+
| `ghc-version` | The resolved version of `ghc` | string |
222+
| `cabal-version` | The resolved version of `cabal` | string |
223+
| `stack-version` | The resolved version of `stack` | string |
224+
| `ghc-exe` | The path of the `ghc` _executable_ | string |
225+
| `cabal-exe` | The path of the `cabal` _executable_ | string |
226+
| `stack-exe` | The path of the `stack` _executable_ | string |
227+
| `ghc-path` | The path of the `ghc` executable _directory_ | string |
228+
| `cabal-path` | The path of the `cabal` executable _directory_ | string |
229+
| `stack-path` | The path of the `stack` executable _directory_ | string |
230+
| `cabal-store` | The path to the cabal store | string |
231+
| `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 |
224232

225233
## Version Support
226234

setup/action.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ inputs:
3737
required: false
3838
description: 'If specified, disables match messages from GHC as GitHub CI annotations.'
3939
outputs:
40+
ghc-version:
41+
description: 'The resolved version of ghc'
42+
cabal-version:
43+
description: 'The resolved version of cabal'
44+
stack-version:
45+
description: 'The resolved version of stack'
46+
ghc-exe:
47+
description: 'The path of the ghc _executable_'
48+
cabal-exe:
49+
description: 'The path of the cabal _executable_'
50+
stack-exe:
51+
description: 'The path of the stack _executable_'
4052
ghc-path:
4153
description: 'The path of the ghc executable _directory_'
4254
cabal-path:
@@ -47,12 +59,6 @@ outputs:
4759
description: 'The path to the cabal store'
4860
stack-root:
4961
description: 'The path to the stack root (equal to the STACK_ROOT environment variable if it is set; otherwise an OS-specific default)'
50-
ghc-exe:
51-
description: 'The path of the ghc _executable_'
52-
cabal-exe:
53-
description: 'The path of the cabal _executable_'
54-
stack-exe:
55-
description: 'The path of the stack _executable_'
5662
runs:
5763
using: 'node16'
5864
main: 'dist/index.js'

setup/dist/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/lib/installer.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup/src/installer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function failed(tool: Tool, version: string): void {
2020

2121
async function configureOutputs(
2222
tool: Tool,
23+
version: string,
2324
path: string,
2425
os: OS
2526
): Promise<void> {
@@ -32,6 +33,7 @@ async function configureOutputs(
3233
core.setOutput('stack-root', sr);
3334
if (os === 'win32') core.exportVariable('STACK_ROOT', sr);
3435
}
36+
core.setOutput(`${tool}-version`, version);
3537
}
3638

3739
async function success(
@@ -41,7 +43,7 @@ async function success(
4143
os: OS
4244
): Promise<true> {
4345
core.addPath(path);
44-
await configureOutputs(tool, path, os);
46+
await configureOutputs(tool, version, path, os);
4547
core.info(
4648
`Found ${tool} ${version} in cache at path ${path}. Setup successful.`
4749
);

0 commit comments

Comments
 (0)