From 96673e13850b91bcde361138ef151131d8e8b815 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 21 Apr 2024 15:09:24 +0300 Subject: [PATCH] Remove HLint support Use separate workflow like in https://github.com/ekmett/lens/pull/1066 --- .github/workflows/haskell-ci.yml | 4 +- cabal.haskell-ci | 10 ---- haskell-ci.cabal | 4 +- src/HaskellCI/Config.hs | 12 +---- src/HaskellCI/Config/Folds.hs | 69 ------------------------- src/HaskellCI/Config/HLint.hs | 72 -------------------------- src/HaskellCI/GitHub.hs | 48 +----------------- src/HaskellCI/Tools.hs | 56 --------------------- src/HaskellCI/Travis.hs | 86 +++++--------------------------- 9 files changed, 19 insertions(+), 342 deletions(-) delete mode 100644 src/HaskellCI/Config/Folds.hs delete mode 100644 src/HaskellCI/Config/HLint.hs diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 5efc04dd..36f4780d 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -163,7 +163,7 @@ jobs: - name: cache (tools) uses: actions/cache/restore@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-e27a5680 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-4fd5cdc7 path: ~/.haskell-ci-tools - name: install cabal-plan run: | @@ -191,7 +191,7 @@ jobs: uses: actions/cache/save@v4 if: always() with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-e27a5680 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-4fd5cdc7 path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v4 diff --git a/cabal.haskell-ci b/cabal.haskell-ci index 7bbf52db..8a9a71fc 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -67,16 +67,6 @@ branches: master -- irc-password: ${{ secrets.MyIrcBotPassword }} -- irc-if-in-origin-repo: True --- Sections to fold in the build output -folds: constraint-sets - --- Run HLint -hlint: True -hlint-job: 9.2.4 -hlint-yaml: .hlint.yaml -hlint-download-binary: True --- hlint-version: ==3.1.* - -- Run doctest (on GHC-8.0+ which support .ghc.environment) doctest: <9 doctest-options: --fast diff --git a/haskell-ci.cabal b/haskell-ci.cabal index 1f89b337..085a4989 100644 --- a/haskell-ci.cabal +++ b/haskell-ci.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: haskell-ci -version: 0.19.20240420 +version: 0.19.20240421 synopsis: Cabal package script generator for Travis-CI description: Script generator (@haskell-ci@) for @@ -94,8 +94,6 @@ library haskell-ci-internal HaskellCI.Config.Doctest HaskellCI.Config.Dump HaskellCI.Config.Empty - HaskellCI.Config.Folds - HaskellCI.Config.HLint HaskellCI.Config.Installed HaskellCI.Config.Jobs HaskellCI.Config.PackageScope diff --git a/src/HaskellCI/Config.hs b/src/HaskellCI/Config.hs index f75cb2f5..8ebbff45 100644 --- a/src/HaskellCI/Config.hs +++ b/src/HaskellCI/Config.hs @@ -29,8 +29,6 @@ import HaskellCI.Config.CopyFields import HaskellCI.Config.Docspec import HaskellCI.Config.Doctest import HaskellCI.Config.Empty -import HaskellCI.Config.Folds -import HaskellCI.Config.HLint import HaskellCI.Config.Installed import HaskellCI.Config.Jobs import HaskellCI.Config.PackageScope @@ -79,7 +77,6 @@ data Config = Config , cfgIrcIfInOriginRepo :: Bool , cfgEmailNotifications :: Bool , cfgProjectName :: Maybe String - , cfgFolds :: S.Set Fold , cfgGhcHead :: !Bool , cfgPostgres :: !Bool , cfgGoogleChrome :: !Bool @@ -98,7 +95,6 @@ data Config = Config , cfgErrorMissingMethods :: !PackageScope , cfgDoctest :: !DoctestConfig , cfgDocspec :: !DocspecConfig - , cfgHLint :: !HLintConfig , cfgConstraintSets :: [ConstraintSet] , cfgRawProject :: [C.PrettyField ()] , cfgRawTravis :: !String @@ -118,7 +114,6 @@ emptyConfig = case runEG configGrammar of configGrammar :: ( OptionsGrammar c g, Applicative (g Config) - , c (Identity HLintJob) , c (Identity PackageScope) , c (Identity TestedWithJobs) , c (Identity Ubuntu) @@ -127,11 +122,11 @@ configGrammar , c (Identity Version) , c (Identity Natural) , c (Identity Components) - , c Env, c Folds, c CopyFields, c HeadVersion + , c Env, c CopyFields, c HeadVersion , c (C.List C.FSep (Identity Installed) Installed) , Applicative (g DoctestConfig) , Applicative (g DocspecConfig) - , Applicative (g HLintConfig)) + ) => g Config Config configGrammar = Config <$> C.optionalFieldDefAla "cabal-install-version" HeadVersion (field @"cfgCabalInstallVersion") defaultCabalInstallVersion @@ -200,8 +195,6 @@ configGrammar = Config ^^^ help "Disable email notifications" <*> C.optionalFieldAla "project-name" C.Token' (field @"cfgProjectName") ^^^ metahelp "NAME" "Project name (used for IRC notifications), defaults to package name or name of first package listed in cabal.project file" - <*> C.monoidalFieldAla "folds" Folds (field @"cfgFolds") - ^^^ metahelp "FOLD" "Build steps to fold" <*> C.booleanFieldDef "ghc-head" (field @"cfgGhcHead") False ^^^ help "Add ghc-head job" <*> C.booleanFieldDef "postgresql" (field @"cfgPostgres") False @@ -236,7 +229,6 @@ configGrammar = Config ^^^ metahelp "PKGSCOPE" "Insert -Werror=missing-methods for package scope (none, local, all)" <*> C.blurFieldGrammar (field @"cfgDoctest") doctestConfigGrammar <*> C.blurFieldGrammar (field @"cfgDocspec") docspecConfigGrammar - <*> C.blurFieldGrammar (field @"cfgHLint") hlintConfigGrammar <*> pure [] -- constraint sets <*> pure [] -- raw project fields <*> C.freeTextFieldDef "raw-travis" (field @"cfgRawTravis") diff --git a/src/HaskellCI/Config/Folds.hs b/src/HaskellCI/Config/Folds.hs deleted file mode 100644 index 938b540c..00000000 --- a/src/HaskellCI/Config/Folds.hs +++ /dev/null @@ -1,69 +0,0 @@ -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -module HaskellCI.Config.Folds where - -import HaskellCI.Prelude - -import qualified Data.Map.Strict as M -import qualified Data.Set as S -import qualified Distribution.Compat.CharParsing as C -import qualified Distribution.Compat.Newtype as C -import qualified Distribution.Parsec as C -import qualified Distribution.Pretty as C -import qualified Text.PrettyPrint as PP - -data Fold - = FoldSDist - | FoldUnpack - | FoldBuild - | FoldBuildInstalled - | FoldBuildEverything - | FoldTest - | FoldHaddock - | FoldStackage - | FoldCheck - | FoldDoctest - | FoldHLint - | FoldConstraintSets - deriving (Eq, Ord, Show, Enum, Bounded) - -------------------------------------------------------------------------------- --- Functions -------------------------------------------------------------------------------- - -showFold :: Fold -> String -showFold = dashise . drop 4 . show - where - dashise = intercalate "-" . map (map toLower) . split - - split [] = [] - split xs0 = - let (ys, xs1) = span isUpper xs0 - (zs, xs2) = break isUpper xs1 - in (ys ++ zs) : split xs2 - -possibleFolds :: [Fold] -possibleFolds = [minBound .. maxBound] - -------------------------------------------------------------------------------- --- Folds -------------------------------------------------------------------------------- - -newtype Folds = Folds { getFolds :: S.Set Fold } - deriving anyclass (C.Newtype (S.Set Fold)) - -instance C.Parsec Folds where - parsec = fmap (Folds . S.unions) $ manySpaces $ do - t <- C.parsecToken' - case t of - "all" -> return $ S.fromList possibleFolds - "all-but-test" -> return $ S.delete FoldTest $ S.fromList possibleFolds - n -> case M.lookup n ps of - Just n' -> return $ S.singleton n' - Nothing -> fail $ "Illegal fold name: " ++ n - where - ps = M.fromList $ map (\x -> (showFold x, x)) possibleFolds - manySpaces p = C.many (p <* C.spaces) - -instance C.Pretty Folds where - pretty = PP.fsep . map (PP.text . showFold) . S.toList . getFolds diff --git a/src/HaskellCI/Config/HLint.hs b/src/HaskellCI/Config/HLint.hs deleted file mode 100644 index 10a2d25b..00000000 --- a/src/HaskellCI/Config/HLint.hs +++ /dev/null @@ -1,72 +0,0 @@ -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeApplications #-} -module HaskellCI.Config.HLint where - -import HaskellCI.Prelude - -import Distribution.Version (withinVersion) - -import qualified Distribution.Compat.CharParsing as C -import qualified Distribution.FieldGrammar as C -import qualified Distribution.Parsec as C -import qualified Distribution.Pretty as C -import qualified Text.PrettyPrint as PP - -import HaskellCI.OptionsGrammar - -data HLintConfig = HLintConfig - { cfgHLintEnabled :: !Bool - , cfgHLintJob :: !HLintJob - , cfgHLintYaml :: !(Maybe FilePath) - , cfgHLintOptions :: [String] - , cfgHLintVersion :: !VersionRange - , cfgHLintDownload :: !Bool - } - deriving (Show, Generic, Binary) - -------------------------------------------------------------------------------- --- Default -------------------------------------------------------------------------------- - -defaultHLintVersion :: VersionRange -defaultHLintVersion = withinVersion (mkVersion [3,5]) - -------------------------------------------------------------------------------- --- HLintJob -------------------------------------------------------------------------------- - -data HLintJob - = HLintJobLatest -- ^ run with latest GHC - | HLintJob Version -- ^ run with specified GHC version - deriving (Eq, Show, Generic, Binary) - -instance C.Parsec HLintJob where - parsec = HLintJobLatest <$ C.string "latest" - <|> HLintJob <$> C.parsec - -instance C.Pretty HLintJob where - pretty HLintJobLatest = PP.text "latest" - pretty (HLintJob v) = C.pretty v - -------------------------------------------------------------------------------- --- Grammar -------------------------------------------------------------------------------- - -hlintConfigGrammar - :: (OptionsGrammar c g, Applicative (g HLintConfig), c (Identity HLintJob)) - => g HLintConfig HLintConfig -hlintConfigGrammar = HLintConfig - <$> C.booleanFieldDef "hlint" (field @"cfgHLintEnabled") False - ^^^ help "Enable HLint job" - <*> C.optionalFieldDef "hlint-job" (field @"cfgHLintJob") HLintJobLatest - ^^^ metahelp "JOB" "Specify HLint job" - <*> C.optionalFieldAla "hlint-yaml" C.FilePathNT (field @"cfgHLintYaml") - ^^^ metaActionHelp "PATH" "file" "Use specific .hlint.yaml" - <*> C.monoidalFieldAla "hlint-options" (C.alaList' C.NoCommaFSep C.Token') (field @"cfgHLintOptions") - ^^^ metahelp "OPTS" "Additional HLint options" - <*> C.optionalFieldDef "hlint-version" (field @"cfgHLintVersion") defaultHLintVersion - ^^^ metahelp "RANGE" "HLint version" - <*> C.booleanFieldDef "hlint-download-binary" (field @"cfgHLintDownload") True - ^^^ help "Download HLint binary release" diff --git a/src/HaskellCI/GitHub.hs b/src/HaskellCI/GitHub.hs index 2a992f7f..a3e60f7f 100644 --- a/src/HaskellCI/GitHub.hs +++ b/src/HaskellCI/GitHub.hs @@ -35,7 +35,6 @@ import HaskellCI.Config import HaskellCI.Config.ConstraintSet import HaskellCI.Config.Docspec import HaskellCI.Config.Doctest -import HaskellCI.Config.HLint import HaskellCI.Config.Installed import HaskellCI.Config.Jobs import HaskellCI.Config.PackageScope @@ -310,10 +309,9 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do let toolsConfigHash :: String toolsConfigHash = take 8 $ BS8.unpack $ Base16.encode $ SHA256.hashlazy $ Binary.runPut $ do Binary.put cfgDoctest - Binary.put cfgHLint Binary.put cfgGhcupJobs -- GHC location affects doctest, e.g - when (doctestEnabled || cfgHLintEnabled cfgHLint) $ githubUses "cache (tools)" "actions/cache/restore@v4" + when (doctestEnabled) $ githubUses "cache (tools)" "actions/cache/restore@v4" [ ("key", "${{ runner.os }}-${{ matrix.compiler }}-tools-" ++ toolsConfigHash) , ("path", "~/.haskell-ci-tools") ] @@ -350,31 +348,7 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do sh_if range $ "$CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 doctest" ++ doctestVersionConstraint sh_if range "doctest --version" - let hlintVersionConstraint - | C.isAnyVersion (cfgHLintVersion cfgHLint) = "" - | otherwise = " --constraint='hlint " ++ prettyShow (cfgHLintVersion cfgHLint) ++ "'" - when (cfgHLintEnabled cfgHLint) $ githubRun "install hlint" $ do - let forHLint = sh_if (hlintJobVersionRange allVersions cfgHeadHackage (cfgHLintJob cfgHLint)) - if cfgHLintDownload cfgHLint - then do - -- install --dry-run and use perl regex magic to find a hlint version - -- -v is important - forHLint $ "HLINTVER=$(cd /tmp && (${CABAL} v2-install -v $ARG_COMPILER --dry-run hlint " ++ hlintVersionConstraint ++ " | perl -ne 'if (/\\bhlint-(\\d+(\\.\\d+)*)\\b/) { print \"$1\"; last; }')); echo \"HLint version $HLINTVER\"" - forHLint $ "if [ ! -e $HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint ]; then " ++ unwords - [ "echo \"Downloading HLint version $HLINTVER\";" - , "mkdir -p $HOME/.haskell-ci-tools;" - , "curl --write-out 'Status Code: %{http_code} Redirects: %{num_redirects} Total time: %{time_total} Total Dsize: %{size_download}\\n' --silent --location --output $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz \"https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz\";" - , "tar -xzv -f $HOME/.haskell-ci-tools/hlint-$HLINTVER.tar.gz -C $HOME/.haskell-ci-tools;" - , "fi" - ] - forHLint "mkdir -p $CABAL_DIR/bin && ln -sf \"$HOME/.haskell-ci-tools/hlint-$HLINTVER/hlint\" $CABAL_DIR/bin/hlint" - forHLint "hlint --version" - - else do - forHLint $ "$CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 hlint" ++ hlintVersionConstraint - forHLint "hlint --version" - - when (doctestEnabled || cfgHLintEnabled cfgHLint) $ githubUsesIf "save cache (tools)" "actions/cache/save@v4" "always()" + when (doctestEnabled) $ githubUsesIf "save cache (tools)" "actions/cache/save@v4" "always()" [ ("key", "${{ runner.os }}-${{ matrix.compiler }}-tools-" ++ toolsConfigHash) , ("path", "~/.haskell-ci-tools") ] @@ -550,24 +524,6 @@ makeGitHub _argv config@Config {..} gitconfig prj jobs@JobVersions {..} = do sh_if docspecRange' "$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all" sh_if docspecRange' cabalDocspec - -- hlint - when (cfgHLintEnabled cfgHLint) $ githubRun "hlint" $ do - let "" <+> ys = ys - xs <+> "" = xs - xs <+> ys = xs ++ " " ++ ys - - prependSpace "" = "" - prependSpace xs = " " ++ xs - - let hlintOptions = prependSpace $ maybe "" ("-h ${GITHUB_WORKSPACE}/source/" ++) (cfgHLintYaml cfgHLint) <+> unwords (cfgHLintOptions cfgHLint) - - for_ pkgs $ \Pkg{pkgName,pkgGpd,pkgJobs} -> do - for_ (hlintArgs pkgGpd) $ \args -> do - let args' = unwords args - unless (null args) $ - sh_if (hlintJobVersionRange allVersions cfgHeadHackage (cfgHLintJob cfgHLint) /\ RangePoints pkgJobs) $ - "(cd " ++ pkgNameDirVariable pkgName ++ " && hlint" ++ hlintOptions ++ " " ++ args' ++ ")" - -- cabal check when cfgCheck $ githubRun "cabal check" $ do for_ pkgs $ \Pkg{pkgName,pkgJobs} -> do diff --git a/src/HaskellCI/Tools.hs b/src/HaskellCI/Tools.hs index a3480bf3..fcd101b2 100644 --- a/src/HaskellCI/Tools.hs +++ b/src/HaskellCI/Tools.hs @@ -3,14 +3,10 @@ module HaskellCI.Tools ( -- * Doctest doctestJobVersionRange, doctestArgs, - -- * HLint - hlintJobVersionRange, - hlintArgs, ) where import HaskellCI.Prelude -import qualified Data.Set as S import qualified Distribution.PackageDescription as C import qualified Distribution.PackageDescription.Configuration as C import qualified Distribution.Pretty as C @@ -22,7 +18,6 @@ import qualified Distribution.Types.BuildInfo.Lens as L import qualified Distribution.Types.PackageDescription.Lens as L import HaskellCI.Compiler -import HaskellCI.Config.HLint ------------------------------------------------------------------------------- -- Doctest @@ -41,8 +36,6 @@ doctestJobVersionRange = RangeGHC /\ Range (C.orLaterVersion $ C.mkVersion [8,0] -- -- * Also add default-extensions -- --- /Note:/ same argument work for hlint too, but not exactly --- doctestArgs :: C.GenericPackageDescription -> [[String]] doctestArgs gpd = nub $ [ libraryModuleArgs c @@ -66,52 +59,3 @@ libraryModuleArgs l lang = maybe [] (pure . ("-X" ++) . C.prettyShow) (C.defaultLanguage bi) exts = map (("-X" ++) . C.prettyShow) (C.defaultExtensions bi) - -executableModuleArgs :: C.Executable -> [String] -executableModuleArgs e - | null dirsOrMods = [] - | otherwise = lang ++ exts ++ dirsOrMods - where - bi = e ^. L.buildInfo - - dirsOrMods - -- note: we don't try to find main_is location, if hsSourceDirs is empty. - | null (C.hsSourceDirs bi) = map C.prettyShow (C.otherModules bi) - | otherwise = map C.getSymbolicPath $ C.hsSourceDirs bi - - lang = maybe [] (pure . ("-X" ++) . C.prettyShow) (C.defaultLanguage bi) - - exts = map (("-X" ++) . C.prettyShow) (C.defaultExtensions bi) - -------------------------------------------------------------------------------- --- HLint -------------------------------------------------------------------------------- - -hlintJobVersionRange - :: Set CompilerVersion -- ^ all compilers - -> VersionRange -- ^ head.hackage - -> HLintJob -- ^ hlint-jobs - -> CompilerRange -hlintJobVersionRange vs headHackage HLintJobLatest = case S.maxView vs' of - Just (v, _) -> RangePoints (S.singleton (GHC v)) - _ -> RangePoints S.empty - where - -- remove non GHC versions, and head.hackage versions - vs' = S.fromList - $ filter (\v -> not $ C.withinRange v headHackage) - $ mapMaybe (maybeGHC Nothing Just) - $ S.toList vs - -hlintJobVersionRange _ _ (HLintJob v) = RangePoints (S.singleton (GHC v)) - -hlintArgs :: C.GenericPackageDescription -> [[String]] -hlintArgs gpd = nub $ - [ libraryModuleArgs c - | c <- toListOf (L.library . traverse) (C.flattenPackageDescription gpd) - ] ++ - [ libraryModuleArgs c - | c <- toListOf (L.subLibraries . traverse) (C.flattenPackageDescription gpd) - ] ++ - [ executableModuleArgs c - | c <- toListOf (L.executables . traverse) (C.flattenPackageDescription gpd) - ] diff --git a/src/HaskellCI/Travis.hs b/src/HaskellCI/Travis.hs index b370cfc4..e095332f 100644 --- a/src/HaskellCI/Travis.hs +++ b/src/HaskellCI/Travis.hs @@ -24,8 +24,6 @@ import HaskellCI.Compiler import HaskellCI.Config import HaskellCI.Config.ConstraintSet import HaskellCI.Config.Doctest -import HaskellCI.Config.Folds -import HaskellCI.Config.HLint import HaskellCI.Config.Installed import HaskellCI.Config.Jobs import HaskellCI.Config.PackageScope @@ -33,7 +31,6 @@ import HaskellCI.Config.Validity import HaskellCI.HeadHackage import HaskellCI.Jobs import HaskellCI.List -import HaskellCI.MonadErr import HaskellCI.Package import HaskellCI.Sh import HaskellCI.ShVersionRange @@ -219,29 +216,6 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do shForJob (Range (cfgDoctestEnabled cfgDoctest) /\ doctestJobVersionRange) $ cabal $ "v2-install $WITHCOMPILER --ignore-project -j2 doctest" ++ doctestVersionConstraint - -- Install hlint - let hlintVersionConstraint - | C.isAnyVersion (cfgHLintVersion cfgHLint) = "" - | otherwise = " --constraint='hlint " ++ C.prettyShow (cfgHLintVersion cfgHLint) ++ "'" - when (cfgHLintEnabled cfgHLint) $ do - let forHLint = shForJob (hlintJobVersionRange allVersions cfgHeadHackage (cfgHLintJob cfgHLint)) - if cfgHLintDownload cfgHLint - then do - -- install --dry-run and use perl regex magic to find a hlint version - -- -v is important - forHLint $ "HLINTVER=$(cd /tmp && (${CABAL} v2-install -v $WITHCOMPILER --dry-run hlint " ++ hlintVersionConstraint ++ " | perl -ne 'if (/\\bhlint-(\\d+(\\.\\d+)*)\\b/) { print \"$1\"; last; }')); echo \"HLint version $HLINTVER\"" - forHLint $ "if [ ! -e $HOME/.hlint/hlint-$HLINTVER/hlint ]; then " ++ unwords - [ "echo \"Downloading HLint version $HLINTVER\";" - , "mkdir -p $HOME/.hlint;" - , "curl --write-out 'Status Code: %{http_code} Redirects: %{num_redirects} Total time: %{time_total} Total Dsize: %{size_download}\\n' --silent --location --output $HOME/.hlint/hlint-$HLINTVER.tar.gz \"https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz\";" - , "tar -xzv -f $HOME/.hlint/hlint-$HLINTVER.tar.gz -C $HOME/.hlint;" - , "fi" - ] - forHLint "mkdir -p $CABALHOME/bin && ln -sf \"$HOME/.hlint/hlint-$HLINTVER/hlint\" $CABALHOME/bin/hlint" - forHLint "hlint --version" - - else forHLint $ cabal $ "v2-install $WITHCOMPILER --ignore-project -j2 hlint" ++ hlintVersionConstraint - -- Install cabal-plan (for ghcjs tests) when (anyGHCJS && cfgGhcjsTests) $ do shForJob RangeGHCJS $ cabal "v2-install -w ghc-8.4.4 --ignore-project -j2 cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe'" @@ -276,11 +250,11 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do sh "DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)" -- sdist - foldedSh FoldSDist "Packaging..." cfgFolds $ do + foldedSh "Packaging..." $ do sh $ cabal "v2-sdist all" -- unpack - foldedSh FoldUnpack "Unpacking..." cfgFolds $ do + foldedSh "Unpacking..." $ do sh "mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/" sh "cd ${DISTDIR} || false" -- fail explicitly, makes SC happier sh "find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \\;" @@ -303,17 +277,17 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do ] -- build no-tests no-benchmarks - unless (equivVersionRanges C.noVersion cfgNoTestsNoBench) $ foldedSh FoldBuild "Building..." cfgFolds $ do + unless (equivVersionRanges C.noVersion cfgNoTestsNoBench) $ foldedSh "Building..." $ do comment "this builds all libraries and executables (without tests/benchmarks)" shForJob (Range cfgNoTestsNoBench) $ cabal "v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all" -- build everything - foldedSh FoldBuildEverything "Building with tests and benchmarks..." cfgFolds $ do + foldedSh "Building with tests and benchmarks..." $ do comment "build & run tests, build benchmarks" sh $ cabal "v2-build $WITHCOMPILER ${TEST} ${BENCH} all --write-ghc-environment-files=always" -- cabal v2-test fails if there are no test-suites. - foldedSh FoldTest "Testing..." cfgFolds $ do + foldedSh "Testing..." $ do shForJob (RangeGHC /\ Range (cfgTests /\ cfgRunTests) /\ hasTests) $ cabal $ "v2-test $WITHCOMPILER ${TEST} ${BENCH} all" ++ testShowDetails @@ -327,7 +301,7 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do ] -- doctest - when doctestEnabled $ foldedSh FoldDoctest "Doctest..." cfgFolds $ do + when doctestEnabled $ foldedSh "Doctest..." $ do let doctestOptions = unwords $ cfgDoctestOptions cfgDoctest sh $ "$CABAL v2-build $WITHCOMPILER ${TEST} ${BENCH} all --dry-run" unless (null $ cfgDoctestFilterEnvPkgs cfgDoctest) $ do @@ -351,38 +325,20 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do unless (null args) $ shForJob vr $ "(cd " ++ pkgNameDirVariable pkgName ++ " && doctest " ++ doctestOptions ++ " " ++ args' ++ ")" - -- hlint - when (cfgHLintEnabled cfgHLint) $ foldedSh FoldHLint "HLint.." cfgFolds $ do - let "" <+> ys = ys - xs <+> "" = xs - xs <+> ys = xs ++ " " ++ ys - - prependSpace "" = "" - prependSpace xs = " " ++ xs - - let hlintOptions = prependSpace $ maybe "" ("-h ${TOP}/" ++) (cfgHLintYaml cfgHLint) <+> unwords (cfgHLintOptions cfgHLint) - - for_ pkgs $ \Pkg{pkgName,pkgGpd,pkgJobs} -> do - for_ (hlintArgs pkgGpd) $ \args -> do - let args' = unwords args - unless (null args) $ - shForJob (hlintJobVersionRange allVersions cfgHeadHackage (cfgHLintJob cfgHLint) /\ RangePoints pkgJobs) $ - "(cd " ++ pkgNameDirVariable pkgName ++ " && hlint" ++ hlintOptions ++ " " ++ args' ++ ")" - -- cabal check - when cfgCheck $ foldedSh FoldCheck "cabal check..." cfgFolds $ do + when cfgCheck $ foldedSh "cabal check..." $ do for_ pkgs $ \Pkg{pkgName,pkgJobs} -> shForJob (RangePoints pkgJobs) $ "(cd " ++ pkgNameDirVariable pkgName ++ " && ${CABAL} -vnormal check)" -- haddock unless (equivVersionRanges C.noVersion cfgHaddock) $ - foldedSh FoldHaddock "haddock..." cfgFolds $ + foldedSh "haddock..." $ shForJob (RangeGHC /\ Range cfgHaddock) $ cabal $ "v2-haddock --haddock-all $WITHCOMPILER " ++ withHaddock ++ " ${TEST} ${BENCH} all" -- unconstained build -- Have to build last, as we remove cabal.project.local unless (equivVersionRanges C.noVersion cfgUnconstrainted) $ - foldedSh FoldBuildInstalled "Building without installed constraints for packages in global-db..." cfgFolds $ do + foldedSh "Building without installed constraints for packages in global-db..." $ do shForJob (Range cfgUnconstrainted) "rm -f cabal.project.local" shForJob (Range cfgUnconstrainted) $ cabal "v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all" @@ -401,7 +357,7 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do let constraintFlags = map (\x -> "--constraint='" ++ x ++ "'") (csConstraints cs) let allFlags = unwords (testFlag : benchFlag : constraintFlags) - foldedSh' FoldConstraintSets name ("Constraint set " ++ name) cfgFolds $ do + foldedSh' name ("Constraint set " ++ name) $ do shForCs $ cabal $ "v2-build $WITHCOMPILER " ++ allFlags ++ " --dependencies-only -j2 all" shForCs $ cabal $ "v2-build $WITHCOMPILER " ++ allFlags ++ " all" when (csRunTests cs) $ @@ -527,26 +483,8 @@ makeTravis argv config@Config {..} prj jobs@JobVersions {..} = do -- https://github.com/travis-ci/docs-travis-ci-com/issues/949#issuecomment-276755003 -- https://github.com/travis-ci/travis-rubies/blob/9f7962a881c55d32da7c76baefc58b89e3941d91/build.sh#L38-L44 -- https://github.com/travis-ci/travis-build/blob/91bf066/lib/travis/build/shell/dsl.rb#L58-L63 - foldedSh' :: Fold -> String -> String -> Set Fold -> ShM () -> ShM () - foldedSh' label sfx plabel labels block - | label `S.notMember` labels = commentedBlock plabel block - | otherwise = case runSh block of - Left err -> throwErr err - Right shs - | all isComment shs -> pure () - | otherwise -> ShM $ \shs1 -> Right $ - ( shs1 - . (Comment plabel :) - . (Sh ("echo '" ++ plabel ++ "' && echo -en 'travis_fold:start:" ++ label' ++ "\\\\r'") :) - . (shs ++) - . (Sh ("echo -en 'travis_fold:end:" ++ label' ++ "\\\\r'") :) - -- return () - , () - ) - where - label' | null sfx = showFold label - | otherwise = showFold label ++ "-" ++ sfx - + foldedSh' :: String -> String -> ShM () -> ShM () + foldedSh' plabel _sfx block = commentedBlock plabel block -- GHC versions which need head.hackage headGhcVers :: Set CompilerVersion