Skip to content

Commit

Permalink
Remove HLint support
Browse files Browse the repository at this point in the history
Use separate workflow like in
ekmett/lens#1066
  • Loading branch information
phadej committed Apr 21, 2024
1 parent 5a32e94 commit 96673e1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 342 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions haskell-ci.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions src/HaskellCI/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -79,7 +77,6 @@ data Config = Config
, cfgIrcIfInOriginRepo :: Bool
, cfgEmailNotifications :: Bool
, cfgProjectName :: Maybe String
, cfgFolds :: S.Set Fold
, cfgGhcHead :: !Bool
, cfgPostgres :: !Bool
, cfgGoogleChrome :: !Bool
Expand All @@ -98,7 +95,6 @@ data Config = Config
, cfgErrorMissingMethods :: !PackageScope
, cfgDoctest :: !DoctestConfig
, cfgDocspec :: !DocspecConfig
, cfgHLint :: !HLintConfig
, cfgConstraintSets :: [ConstraintSet]
, cfgRawProject :: [C.PrettyField ()]
, cfgRawTravis :: !String
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
69 changes: 0 additions & 69 deletions src/HaskellCI/Config/Folds.hs

This file was deleted.

72 changes: 0 additions & 72 deletions src/HaskellCI/Config/HLint.hs

This file was deleted.

48 changes: 2 additions & 46 deletions src/HaskellCI/GitHub.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
]
Expand Down Expand Up @@ -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")
]
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 96673e1

Please sign in to comment.