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

Output actual ghc-version, stack-version, and cabal-version #77

Closed
andreasabel opened this issue Sep 21, 2021 · 3 comments · Fixed by #249
Closed

Output actual ghc-version, stack-version, and cabal-version #77

andreasabel opened this issue Sep 21, 2021 · 3 comments · Fixed by #249
Assignees
Labels
re: outputs Concerning the outputs of this action
Milestone

Comments

@andreasabel
Copy link
Member

Using latest as input for ghc-version, stack-version and cabal-version is very convenient, but then it is not so convenient later in the workflow when one needs these versions.

Suggestion: Also output these three variables, filling them with the actually chosen versions of the tools.

This would also open the path for other wildcards for versions, like ghc-version: 8.10.latest etc. which could be used conveniently.

@andreasabel
Copy link
Member Author

A workaround is to insert a step like:

      - shell: bash
        run: |
          echo "GHC_VER=$(ghc --numeric-version)" >> ${GITHUB_ENV}
          echo "CABAL_VER=$(cabal --numeric-version)" >> ${GITHUB_ENV}
          echo "STACK_VER=$(stack --numeric-version)" >> ${GITHUB_ENV}

Then, these variables can be used in the next steps, e.g.:

      - run: |
          echo "GHC_VER   = ${{ env.GHC_VER   }}"
          echo "CABAL_VER = ${{ env.CABAL_VER }}"
          echo "STACK_VER = ${{ env.STACK_VER }}"

Or, in shell commands, as environment variables:

      - run: |
          echo "GHC_VER   = $GHC_VER"
          echo "CABAL_VER = $CABAL_VER"
          echo "STACK_VER = $STACK_VER"

However, this is all a bit more manual, brittle and OS-specific than getting these directly as outputs from the setup-action. @jared-w

@hazelweakly
Copy link
Collaborator

That sounds like a great idea. The 'latest' variables are resolved to their "actual" ones fairly early on in the code-path and there's a very natural insertion point to include an output for this (the configureOutputs function merely needs to also be passed the version of the installed tool which the caller function already has access to).

cabal-version stack-version and ghc-version would fit the naming convention used by this action already (which was modeled after the other standard language setup actions at the time)

@andreasabel
Copy link
Member Author

The resolved versions are available at the end of getOpts (and returned from there):

actions/setup/src/opts.ts

Lines 130 to 131 in f0ecab9

core.debug(`Options are: ${JSON.stringify(opts)}`);
return opts;

There, or after it returns, in the run function, the outputs could be written via core.setOutput(variable, value).
const opts = getOpts(getDefaults(os), os, inputs);
for (const [t, {resolved}] of Object.entries(opts).filter(o => o[1].enable))
await core.group(`Installing ${t} version ${resolved}`, async () =>
installTool(t as Tool, resolved, os)
);

@andreasabel andreasabel added this to the 3.0.0 milestone Jan 10, 2023
@andreasabel andreasabel self-assigned this May 6, 2023
@andreasabel andreasabel added the re: outputs Concerning the outputs of this action label May 6, 2023
@andreasabel andreasabel modified the milestones: 3.0.0, 2.4.0 May 6, 2023
andreasabel added a commit that referenced this issue May 6, 2023
andreasabel added a commit to haskell-actions/setup that referenced this issue May 6, 2023
mihaimaruseac pushed a commit to haskell-actions/hlint-setup that referenced this issue Sep 17, 2023
mihaimaruseac pushed a commit to haskell-actions/hlint-run that referenced this issue Sep 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
re: outputs Concerning the outputs of this action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants