Skip to content

Commit

Permalink
Fix #6638 Add notify-if-no-run-tests and notify-if-no-run-benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Aug 10, 2024
1 parent 34522bb commit 549f9d4
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 135 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Other enhancements:
* Add flags `--run-tests` and `--run-benchmarks` (the existing defaults) to
Stack's `build` command, which take precedence over the existing
`no-run-tests` and `no-run-benchmarks` configuration options, respectively.
* In configuration files, the `notify-if-no-run-tests` and
`notify-if-no-run-benchmarks` keys are introduced, to allow the exisitng
notification to be muted if unwanted.

Bug fixes:

Expand Down
18 changes: 18 additions & 0 deletions doc/configure/yaml/non-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,24 @@ Default: `true`
If Stack's integration with the Nix package manager is not enabled, should Stack
notify the user if a `nix` executable is on the PATH?

## notify-if-no-run-benchmarks

:octicons-tag-24: UNRELEASED

Default: `true`

Should Stack notify the user if the automatic running of a benchmark is
prevented by the `--no-run-benchmarks` flag?

## notify-if-no-run-tests

:octicons-tag-24: UNRELEASED

Default: `true`

Should Stack notify the user if the automatic running of a test suite is
prevented by the `--no-run-tests` flag?

## package-index

[:octicons-tag-24: 2.9.3](https://github.com/commercialhaskell/stack/releases/tag/v2.9.3)
Expand Down
9 changes: 7 additions & 2 deletions src/Stack/Build/ExecutePackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,9 @@ singleTest topts testsToRun ac ee task installedMap = do
pure True
TSUnknown -> pure True
else do
announce "Test running disabled by --no-run-tests flag."
notifyIfNoRunTests <- view $ configL . to (.notifyIfNoRunTests)
when notifyIfNoRunTests $
announce "Test running disabled by --no-run-tests flag."
pure False

when toRun $ do
Expand Down Expand Up @@ -1265,7 +1267,10 @@ singleBench beopts benchesToRun ac ee task installedMap = do
if beopts.runBenchmarks
then pure True
else do
announce "Benchmark running disabled by --no-run-benchmarks flag."
notifyIfNoRunBenchmarks <-
view $ configL . to (.notifyIfNoRunBenchmarks)
when notifyIfNoRunBenchmarks $
announce "Benchmark running disabled by --no-run-benchmarks flag."
pure False

when toRun $ do
Expand Down
5 changes: 5 additions & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ configFromConfigMonoid
notifyIfGhcUntested = fromFirstTrue configMonoid.notifyIfGhcUntested
notifyIfCabalUntested = fromFirstTrue configMonoid.notifyIfCabalUntested
notifyIfArchUnknown = fromFirstTrue configMonoid.notifyIfArchUnknown
notifyIfNoRunTests = fromFirstTrue configMonoid.notifyIfNoRunTests
notifyIfNoRunBenchmarks =
fromFirstTrue configMonoid.notifyIfNoRunBenchmarks
noRunCompile = fromFirstFalse configMonoid.noRunCompile
allowDifferentUser <-
case getFirst configMonoid.allowDifferentUser of
Expand Down Expand Up @@ -597,6 +600,8 @@ configFromConfigMonoid
, notifyIfGhcUntested
, notifyIfCabalUntested
, notifyIfArchUnknown
, notifyIfNoRunTests
, notifyIfNoRunBenchmarks
, noRunCompile
, stackDeveloperMode
, casa
Expand Down
140 changes: 73 additions & 67 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,152 +59,158 @@ import Stack.Types.Version ( VersionCheck (..), VersionRange )

-- | The top-level Stackage configuration.
data Config = Config
{ workDir :: !(Path Rel Dir)
{ workDir :: !(Path Rel Dir)
-- ^ this allows to override .stack-work directory
, userGlobalConfigFile :: !(Path Abs File)
, userGlobalConfigFile :: !(Path Abs File)
-- ^ The user-specific global configuration file.
, build :: !BuildOpts
, build :: !BuildOpts
-- ^ Build configuration
, docker :: !DockerOpts
, docker :: !DockerOpts
-- ^ Docker configuration
, nix :: !NixOpts
, nix :: !NixOpts
-- ^ Execution environment (e.g nix-shell) configuration
, processContextSettings :: !(EnvSettings -> IO ProcessContext)
, processContextSettings :: !(EnvSettings -> IO ProcessContext)
-- ^ Environment variables to be passed to external tools
, localProgramsBase :: !(Path Abs Dir)
, localProgramsBase :: !(Path Abs Dir)
-- ^ Non-platform-specific path containing local installations
, localPrograms :: !(Path Abs Dir)
, localPrograms :: !(Path Abs Dir)
-- ^ Path containing local installations (mainly GHC)
, hideTHLoading :: !Bool
, hideTHLoading :: !Bool
-- ^ Hide the Template Haskell "Loading package ..." messages from the
-- console
, prefixTimestamps :: !Bool
, prefixTimestamps :: !Bool
-- ^ Prefix build output with timestamps for each line.
, platform :: !Platform
, platform :: !Platform
-- ^ The platform we're building for, used in many directory names
, platformVariant :: !PlatformVariant
, platformVariant :: !PlatformVariant
-- ^ Variant of the platform, also used in directory names
, ghcVariant :: !(Maybe GHCVariant)
, ghcVariant :: !(Maybe GHCVariant)
-- ^ The variant of GHC requested by the user.
, ghcBuild :: !(Maybe CompilerBuild)
, ghcBuild :: !(Maybe CompilerBuild)
-- ^ Override build of the compiler distribution (e.g. standard, gmp4,
-- tinfo6)
, latestSnapshot :: !Text
, latestSnapshot :: !Text
-- ^ URL of a JSON file providing the latest LTS and Nightly snapshots.
, systemGHC :: !Bool
, systemGHC :: !Bool
-- ^ Should we use the system-installed GHC (on the PATH) if
-- available? Can be overridden by command line options.
, installGHC :: !Bool
, installGHC :: !Bool
-- ^ Should we automatically install GHC if missing or the wrong
-- version is available? Can be overridden by command line options.
, skipGHCCheck :: !Bool
, skipGHCCheck :: !Bool
-- ^ Don't bother checking the GHC version or architecture.
, skipMsys :: !Bool
, skipMsys :: !Bool
-- ^ On Windows: don't use a sandboxed MSYS
, msysEnvironment :: !(Maybe MsysEnvironment)
, msysEnvironment :: !(Maybe MsysEnvironment)
-- ^ On Windows: what MSYS2 environment to apply. Nothing on other operating
-- systems.
, compilerCheck :: !VersionCheck
, compilerCheck :: !VersionCheck
-- ^ Specifies which versions of the compiler are acceptable.
, compilerRepository :: !CompilerRepository
, compilerRepository :: !CompilerRepository
-- ^ Specifies the repository containing the compiler sources
, localBin :: !(Path Abs Dir)
, localBin :: !(Path Abs Dir)
-- ^ Directory we should install executables into
, fileWatchHook :: !(Maybe (Path Abs File))
, fileWatchHook :: !(Maybe (Path Abs File))
-- ^ Optional path of executable used to override --file-watch
-- post-processing.
, requireStackVersion :: !VersionRange
, requireStackVersion :: !VersionRange
-- ^ Require a version of Stack within this range.
, jobs :: !Int
, jobs :: !Int
-- ^ How many concurrent jobs to run, defaults to number of capabilities
, overrideGccPath :: !(Maybe (Path Abs File))
, overrideGccPath :: !(Maybe (Path Abs File))
-- ^ Optional gcc override path
, extraIncludeDirs :: ![FilePath]
, extraIncludeDirs :: ![FilePath]
-- ^ --extra-include-dirs arguments
, extraLibDirs :: ![FilePath]
, extraLibDirs :: ![FilePath]
-- ^ --extra-lib-dirs arguments
, customPreprocessorExts :: ![Text]
, customPreprocessorExts :: ![Text]
-- ^ List of custom preprocessors to complete the hard coded ones
, concurrentTests :: !Bool
, concurrentTests :: !Bool
-- ^ Run test suites concurrently
, templateParams :: !(Map Text Text)
, templateParams :: !(Map Text Text)
-- ^ Parameters for templates.
, scmInit :: !(Maybe SCM)
, scmInit :: !(Maybe SCM)
-- ^ Initialize SCM (e.g. git) when creating new projects.
, ghcOptionsByName :: !(Map PackageName [Text])
, ghcOptionsByName :: !(Map PackageName [Text])
-- ^ Additional GHC options to apply to specific packages.
, ghcOptionsByCat :: !(Map ApplyGhcOptions [Text])
, ghcOptionsByCat :: !(Map ApplyGhcOptions [Text])
-- ^ Additional GHC options to apply to categories of packages
, cabalConfigOpts :: !(Map CabalConfigKey [Text])
, cabalConfigOpts :: !(Map CabalConfigKey [Text])
-- ^ Additional options to be passed to ./Setup.hs configure
, setupInfoLocations :: ![String]
, setupInfoLocations :: ![String]
-- ^ URLs or paths to stack-setup.yaml files, for finding tools.
-- If none present, the default setup-info is used.
, setupInfoInline :: !SetupInfo
, setupInfoInline :: !SetupInfo
-- ^ Additional SetupInfo to use to find tools.
, pvpBounds :: !PvpBounds
, pvpBounds :: !PvpBounds
-- ^ How PVP upper bounds should be added to packages
, modifyCodePage :: !Bool
, modifyCodePage :: !Bool
-- ^ Force the code page to UTF-8 on Windows
, rebuildGhcOptions :: !Bool
, rebuildGhcOptions :: !Bool
-- ^ Rebuild on GHC options changes
, applyGhcOptions :: !ApplyGhcOptions
, applyGhcOptions :: !ApplyGhcOptions
-- ^ Which packages do --ghc-options on the command line apply to?
, applyProgOptions :: !ApplyProgOptions
, applyProgOptions :: !ApplyProgOptions
-- ^ Which packages do all and any --PROG-option options on the command line
-- apply to?
, allowNewer :: !(First Bool)
, allowNewer :: !(First Bool)
-- ^ Ignore version ranges in .cabal files. Funny naming chosen to
-- match cabal.
, allowNewerDeps :: !(Maybe [PackageName])
, allowNewerDeps :: !(Maybe [PackageName])
-- ^ Ignore dependency upper and lower bounds only for specified
-- packages. No effect unless allow-newer is enabled.
, defaultInitSnapshot :: !(First AbstractSnapshot)
, defaultInitSnapshot :: !(First AbstractSnapshot)
-- ^ An optional default snapshot to use with @stack init@ when none is
-- specified at the command line.
, defaultTemplate :: !(Maybe TemplateName)
, defaultTemplate :: !(Maybe TemplateName)
-- ^ The default template to use when none is specified.
-- (If Nothing, the 'default' default template is used.)
, allowDifferentUser :: !Bool
, allowDifferentUser :: !Bool
-- ^ Allow users other than the Stack root owner to use the Stack
-- installation.
, dumpLogs :: !DumpLogs
, dumpLogs :: !DumpLogs
-- ^ Dump logs of local non-dependencies when doing a build.
, project :: !(ProjectConfig (Project, Path Abs File))
, project :: !(ProjectConfig (Project, Path Abs File))
-- ^ Project information and stack.yaml file location
, allowLocals :: !Bool
, allowLocals :: !Bool
-- ^ Are we allowed to build local packages? The script
-- command disallows this.
, saveHackageCreds :: !FirstTrue
, saveHackageCreds :: !FirstTrue
-- ^ Should we save Hackage credentials to a file?
, hackageBaseUrl :: !Text
, hackageBaseUrl :: !Text
-- ^ Hackage base URL used when uploading packages
, runner :: !Runner
, pantryConfig :: !PantryConfig
, stackRoot :: !(Path Abs Dir)
, snapshot :: !(Maybe AbstractSnapshot)
, runner :: !Runner
, pantryConfig :: !PantryConfig
, stackRoot :: !(Path Abs Dir)
, snapshot :: !(Maybe AbstractSnapshot)
-- ^ Any snapshot override from the command line
, userStorage :: !UserStorage
, userStorage :: !UserStorage
-- ^ Database connection pool for user Stack database
, hideSourcePaths :: !Bool
, hideSourcePaths :: !Bool
-- ^ Enable GHC hiding source paths?
, recommendStackUpgrade :: !Bool
, recommendStackUpgrade :: !Bool
-- ^ Recommend a Stack upgrade?
, notifyIfNixOnPath :: !Bool
, notifyIfNixOnPath :: !Bool
-- ^ Notify if the Nix package manager (nix) is on the PATH, but
-- Stack's Nix integration is not enabled?
, notifyIfGhcUntested :: !Bool
, notifyIfGhcUntested :: !Bool
-- ^ Notify if Stack has not been tested with the GHC version?
, notifyIfCabalUntested :: !Bool
, notifyIfCabalUntested :: !Bool
-- ^ Notify if Stack has not been tested with the Cabal version?
, notifyIfArchUnknown :: !Bool
, notifyIfArchUnknown :: !Bool
-- ^ Notify if the specified machine architecture is unknown to Cabal (the
-- library)?
, noRunCompile :: !Bool
, notifyIfNoRunTests :: !Bool
-- ^ Notify if the --no-run-tests flag has prevented the running of a
-- targeted test suite?
, notifyIfNoRunBenchmarks :: !Bool
-- ^ Notify if the --no-run-benchmarks flag has prevented the running of a
-- targeted benchmark?
, noRunCompile :: !Bool
-- ^ Use --no-run and --compile options when using `stack script`
, stackDeveloperMode :: !Bool
, stackDeveloperMode :: !Bool
-- ^ Turn on Stack developer mode for additional messages?
, casa :: !(Maybe (CasaRepoPrefix, Int))
, casa :: !(Maybe (CasaRepoPrefix, Int))
-- ^ Optional Casa configuration
}

Expand Down
Loading

0 comments on commit 549f9d4

Please sign in to comment.