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

Neutral in the choice of build tools #12

Open
L-TChen opened this issue Dec 19, 2020 · 8 comments
Open

Neutral in the choice of build tools #12

L-TChen opened this issue Dec 19, 2020 · 8 comments

Comments

@L-TChen
Copy link

L-TChen commented Dec 19, 2020

It does not seem necessary to set up cabal whenever this action is used, if the intended build tool is stack. Setting up cabal is currently costly (about 30s), since the action downloads the version 3.2 of cabal instead of using the one 3.4 provided by runner.

Also, it will be nice to have an option for stack to choose the system GHC by default.

@vrom911
Copy link
Member

vrom911 commented Dec 19, 2020

Also, it will be nice to have an option for stack to choose the system GHC by default.

I think this is the question to Stack, but it already has this option. You can use:

stack ... --system-ghc

From help:

  --[no-]system-ghc        Enable/disable using the system installed GHC (on the
                           PATH) if it is available and its version matches.
                           Disabled by default.

Regarding the initial question, I am not sure if this is what you mean, but in the action, there is already this option:

  stack-no-global:
    required: false
    description: 'If specified, enable-stack must be set. Prevents installing GHC and Cabal globally'

@L-TChen
Copy link
Author

L-TChen commented Dec 19, 2020

Also, it will be nice to have an option for stack to choose the system GHC by default.

I think this is the question to Stack, but it already has this option. You can use:

stack ... --system-ghc

From help:

  --[no-]system-ghc        Enable/disable using the system installed GHC (on the
                           PATH) if it is available and its version matches.
                           Disabled by default.

Yes, I know it can be set via this option from CLI or from the local/global configuration. Yet, it will just make life easier by setting up a global stack configuration altogether via this action directly.

Regarding the initial question, I am not sure if this is what you mean, but in the action, there is already this option:

  stack-no-global:
    required: false
    description: 'If specified, enable-stack must be set. Prevents installing GHC and Cabal globally'

Hum, it looks so. The description is confusing to me, since it is not clear what would happen if I have stack-no-global true but ghc-version specified.

@L-TChen
Copy link
Author

L-TChen commented Dec 19, 2020

Right, stack-no-global prevents installing GHC and Cabal, but there is no way to have GHC enabled but Cabal disabled.

actions/setup/src/opts.ts

Lines 96 to 106 in 0386b0a

const opts: Options = {
ghc: {
raw: verInpt.ghc,
resolved: resolve(verInpt.ghc, ghc.supported, 'ghc', os),
enable: !stackNoGlobal
},
cabal: {
raw: verInpt.cabal,
resolved: resolve(verInpt.cabal, cabal.supported, 'cabal', os),
enable: !stackNoGlobal
},

It will be really great if there are options

  • global-ghc which defaults to true
  • enable-cabal which defaults to true and requires global-ghc to be true

so that these options will not break existing workflows but add enough flexibility. In this case, stack-no-global will be an option to set both false.

@hazelweakly
Copy link
Collaborator

This has actually come up before. At the time, the runner was correctly synced with the latest version of cabal, so there was no runtime hit to install it and what I did was just prevented cabal-update from running if stack was enabled, which wasn't necessarily the most correct solution, but it was the most minimal change.

I would like to improve the situation, though; I've always intended for this action to be neutral in build tool choice.

Splitting out stack-no-global into its two separate options and leaving it as the shortcut to enable both makes sense to me. How about this addition to action.yml?

  enable-cabal:
    required: false
    description: 'If specified, will install the specified version of cabal-install globally'
  enable-ghc:
    required: false
    description: 'If specified, will install the specified version of GHC globally'
    default: 'true'
  stack-use-system-ghc:
    required: false
    description: 'If specified, enable-ghc must be set. Will configure stack to use the globally installed GHC.'

stack-use-system-ghc would append the setting system-ghc: true to /etc/stack/config.yaml. Would that work?

@L-TChen
Copy link
Author

L-TChen commented Dec 20, 2020

Thanks! That looks great to me.

Regarding system-ghc, appending system-ghc: true to the global configuration should work. That is also what I am doing in a separate step after invoking this action.

@hazelweakly
Copy link
Collaborator

Glad to hear it! I'll implement that and have it merged in after the cache: true PR gets merged.

@andreasabel
Copy link
Member

Disabling cabal is a natural feature I also have been looking for and it would restore the symmetry to enable-stack. Would be great to have!

@jared-w : Any progress on this?

I'll implement that and have it merged in after the cache: true PR gets merged.

This PR (#11) looks stalled. Is it a prerequisite?

@hazelweakly
Copy link
Collaborator

It is not actually a prerequisite. At the time, the PR wasn't stalled and I didn't want to cause a lot of churn work. But, well, here we are :)

I'd welcome a PR to implement this as I can't promise any time in the next few weeks, but I'm hoping to have some more time in October to clean things up once my life settles down a bit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants