Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6293 Allow warnings about untested GHC/Cabal to be muted #6294

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Other enhancements:
command to allow uploading of documentation for packages to Hackage.
* `stack new` no longer rejects project templates that specify a `package.yaml`
in a subdirectory of the project directory.
* Stack will notify the user if Stack has not been tested with the version of
GHC that is being user or a version of Cabal (the library) that has been
found. In YAML configuration files, the `notify-if-ghc-untested` and
`notify-if-cabal-untested` keys are introduced, to allow the notification to
be muted if unwanted.

Bug fixes:

Expand Down
18 changes: 18 additions & 0 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,24 @@ for details).
For further information, see the
[Nix integration](nix_integration.md#configuration) documentation.

### notify-if-cabal-untested

:octicons-tag-24: UNRELEASED

Default: `true`

If Stack has not been tested with the version of Cabal (the library) that has
been found, should Stack notify the user of that?

### notify-if-ghc-untested

:octicons-tag-24: UNRELEASED

Default: `true`

If Stack has not been tested with the version of GHC that is being used, should
Stack notify the user of that?

### notify-if-nix-on-path

:octicons-tag-24: UNRELEASED
Expand Down
2 changes: 2 additions & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ configFromConfigMonoid
configHideSourcePaths = fromFirstTrue configMonoidHideSourcePaths
configRecommendUpgrade = fromFirstTrue configMonoidRecommendUpgrade
configNotifyIfNixOnPath = fromFirstTrue configMonoidNotifyIfNixOnPath
configNotifyIfGhcUntested = fromFirstTrue configMonoidNotifyIfGhcUntested
configNotifyIfCabalUntested = fromFirstTrue configMonoidNotifyIfCabalUntested
configNoRunCompile = fromFirstFalse configMonoidNoRunCompile
configAllowDifferentUser <-
case getFirst configMonoidAllowDifferentUser of
Expand Down
24 changes: 14 additions & 10 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,12 @@ ensureCompilerAndMsys sopts = do
pure (cp, paths)

-- | See <https://github.com/commercialhaskell/stack/issues/4246>
warnUnsupportedCompiler :: HasTerm env => Version -> RIO env Bool
warnUnsupportedCompiler ghcVersion =
warnUnsupportedCompiler ::
(HasConfig env, HasTerm env)
=> Version
-> RIO env Bool
warnUnsupportedCompiler ghcVersion = do
notifyIfGhcUntested <- view $ configL.to configNotifyIfGhcUntested
if
| ghcVersion < mkVersion [7, 8] -> do
prettyWarnL
Expand All @@ -1006,10 +1010,10 @@ warnUnsupportedCompiler ghcVersion =
, style Url "https://github.com/commercialhaskell/stack/issues/648" <> "."
]
pure True
| ghcVersion >= mkVersion [9, 7] -> do
| ghcVersion >= mkVersion [9, 7] && notifyIfGhcUntested -> do
prettyWarnL
[ flow "Stack has not been tested with GHC versions 9.8 and above, and \
\using"
[ flow "Stack has not been tested with GHC versions 9.8 and above, \
\and using"
, fromString (versionString ghcVersion) <> ","
, flow "this may fail."
]
Expand All @@ -1020,15 +1024,15 @@ warnUnsupportedCompiler ghcVersion =

-- | See <https://github.com/commercialhaskell/stack/issues/4246>
warnUnsupportedCompilerCabal ::
HasTerm env
(HasConfig env, HasTerm env)
=> CompilerPaths
-> Bool -- ^ already warned about GHC?
-> RIO env ()
warnUnsupportedCompilerCabal cp didWarn = do
unless didWarn $
void $ warnUnsupportedCompiler $ getGhcVersion $ cpCompilerVersion cp
let cabalVersion = cpCabalVersion cp

notifyIfCabalUntested <- view $ configL.to configNotifyIfCabalUntested
if
| cabalVersion < mkVersion [1, 24, 0] -> do
prettyWarnL
Expand All @@ -1040,10 +1044,10 @@ warnUnsupportedCompilerCabal cp didWarn = do
\resolver. Acceptable resolvers: lts-7.0/nightly-2016-05-26 \
\or later."
]
| cabalVersion >= mkVersion [3, 11] ->
| cabalVersion >= mkVersion [3, 11] && notifyIfCabalUntested ->
prettyWarnL
[ flow "Stack has not been tested with Cabal versions 3.12 and above, \
\but version"
[ flow "Stack has not been tested with Cabal versions 3.12 and \
\above, but version"
, fromString (versionString cabalVersion)
, flow "was found, this may fail."
]
Expand Down
4 changes: 4 additions & 0 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ data Config = Config
, configNotifyIfNixOnPath :: !Bool
-- ^ Notify if the Nix package manager (nix) is on the PATH, but
-- Stack's Nix integration is not enabled?
, configNotifyIfGhcUntested :: !Bool
-- ^ Notify if Stack has not been tested with the GHC version?
, configNotifyIfCabalUntested :: !Bool
-- ^ Notify if Stack has not been tested with the Cabal version?
, configNoRunCompile :: !Bool
-- ^ Use --no-run and --compile options when using `stack script`
, configStackDeveloperMode :: !Bool
Expand Down
14 changes: 14 additions & 0 deletions src/Stack/Types/ConfigMonoid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ data ConfigMonoid = ConfigMonoid
-- ^ See 'configRecommendUpgrade'
, configMonoidNotifyIfNixOnPath :: !FirstTrue
-- ^ See 'configNotifyIfNixOnPath'
, configMonoidNotifyIfGhcUntested :: !FirstTrue
-- ^ See 'configNotifyIfGhcUntested'
, configMonoidNotifyIfCabalUntested :: !FirstTrue
-- ^ See 'configNotifyIfCabalUntested'
, configMonoidCasaOpts :: !CasaOptsMonoid
-- ^ Casa configuration options.
, configMonoidCasaRepoPrefix :: !(First CasaRepoPrefix)
Expand Down Expand Up @@ -342,6 +346,10 @@ parseConfigMonoidObject rootDir obj = do
FirstTrue <$> obj ..:? configMonoidRecommendUpgradeName
configMonoidNotifyIfNixOnPath <-
FirstTrue <$> obj ..:? configMonoidNotifyIfNixOnPathName
configMonoidNotifyIfGhcUntested <-
FirstTrue <$> obj ..:? configMonoidNotifyIfGhcUntestedName
configMonoidNotifyIfCabalUntested <-
FirstTrue <$> obj ..:? configMonoidNotifyIfCabalUntestedName
configMonoidCasaOpts <-
jsonSubWarnings (obj ..:? configMonoidCasaOptsName ..!= mempty)
configMonoidCasaRepoPrefix <-
Expand Down Expand Up @@ -522,6 +530,12 @@ configMonoidRecommendUpgradeName = "recommend-stack-upgrade"
configMonoidNotifyIfNixOnPathName :: Text
configMonoidNotifyIfNixOnPathName = "notify-if-nix-on-path"

configMonoidNotifyIfGhcUntestedName :: Text
configMonoidNotifyIfGhcUntestedName = "notify-if-ghc-untested"

configMonoidNotifyIfCabalUntestedName :: Text
configMonoidNotifyIfCabalUntestedName = "notify-if-cabal-untested"

configMonoidCasaOptsName :: Text
configMonoidCasaOptsName = "casa"

Expand Down