actions icon indicating copy to clipboard operation
actions copied to clipboard

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

Open andreasabel opened this issue 3 years ago • 3 comments

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 avatar Sep 21 '21 07:09 andreasabel

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

andreasabel avatar Sep 21 '21 18:09 andreasabel

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)

hazelweakly avatar Sep 21 '21 23:09 hazelweakly

The resolved versions are available at the end of getOpts (and returned from there): https://github.com/haskell/actions/blob/f0ecab9af1c178879d2243035bba5832e5529b43/setup/src/opts.ts#L130-L131 There, or after it returns, in the run function, the outputs could be written via core.setOutput(variable, value). https://github.com/haskell/actions/blob/f0ecab9af1c178879d2243035bba5832e5529b43/setup/src/setup-haskell.ts#L25-L30

andreasabel avatar Oct 05 '21 09:10 andreasabel