haskell / actions

Github actions for Haskell CI
147 stars 54 forks source link

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

Closed andreasabel closed 1 year ago

andreasabel commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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