[Git][ghc/ghc][master] Add linting of `base` to the CI

Marge Bot gitlab at gitlab.haskell.org
Fri Oct 9 12:44:36 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00
Add linting of `base` to the CI

- - - - -


10 changed files:

- .gitlab-ci.yml
- libraries/base/GHC/Event/EPoll.hsc
- libraries/base/GHC/Event/KQueue.hsc
- libraries/base/GHC/Event/Poll.hsc
- libraries/base/GHC/ExecutionStack/Internal.hsc
- libraries/base/GHC/IO/Handle/Lock/LinuxOFD.hsc
- libraries/base/GHC/IO/Handle/Lock/Windows.hsc
- libraries/base/GHC/RTS/Flags.hsc
- libraries/base/System/Environment/ExecutablePath.hsc
- libraries/base/tests/Concurrent/ThreadDelay001.hs


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -2,7 +2,7 @@ variables:
   GIT_SSL_NO_VERIFY: "1"
 
   # Commit of ghc/ci-images repository from which to pull Docker images
-  DOCKER_REV: e1cdfaea745989faa266f09c1d6c4c981aa34dc6
+  DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8
 
   # Sequential version number capturing the versions of all tools fetched by
   # .gitlab/ci.sh.
@@ -17,13 +17,14 @@ variables:
   GIT_SUBMODULE_STRATEGY: "recursive"
 
 stages:
-  - lint        # Source linting
-  - quick-build # A very quick smoke-test to weed out broken commits
-  - build       # A quick smoke-test to weed out broken commits
-  - full-build  # Build all the things
-  - packaging   # Source distribution, etc.
-  - testing     # head.hackage correctness and compiler performance testing
-  - deploy      # push documentation
+  - tool-lint      # Source linting of the tools
+  - quick-build    # A very quick smoke-test to weed out broken commits
+  - lint           # Source linting of GHC
+  - build          # A quick smoke-test to weed out broken commits
+  - full-build     # Build all the things
+  - packaging      # Source distribution, etc.
+  - testing        # head.hackage correctness and compiler performance testing
+  - deploy         # push documentation
 
 # Note [The CI Story]
 # ~~~~~~~~~~~~~~~~~~~
@@ -81,11 +82,11 @@ workflow:
 
 
 ############################################################
-# Linting
+# tool linting
 ############################################################
 
 ghc-linters:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
@@ -105,7 +106,7 @@ ghc-linters:
 
 # Run mypy Python typechecker on linter scripts.
 lint-linters:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
     - mypy .gitlab/linters/*.py
@@ -115,7 +116,7 @@ lint-linters:
 
 # Check that .T files all parse by listing broken tests.
 lint-testsuite:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   script:
     - make -Ctestsuite list_broken TEST_HC=$GHC
@@ -125,7 +126,7 @@ lint-testsuite:
 
 # Run mypy Python typechecker on testsuite driver
 typecheck-testsuite:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
     - mypy testsuite/driver/runtests.py
@@ -137,7 +138,7 @@ typecheck-testsuite:
 # accommodate, e.g., haddock changes not yet upstream) but not on `master` or
 # Marge jobs.
 .lint-submods:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
     - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
@@ -169,7 +170,7 @@ lint-submods-branch:
     - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/'
 
 .lint-changelogs:
-  stage: lint
+  stage: tool-lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   dependencies: []
   tags:
@@ -189,7 +190,6 @@ lint-release-changelogs:
   rules:
     - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/'
 
-
 ############################################################
 # Validation via Pipelines (hadrian)
 ############################################################
@@ -235,10 +235,12 @@ lint-release-changelogs:
 
 validate-x86_64-linux-deb9-hadrian:
   extends: .validate-linux-hadrian
+  needs: [hadrian-ghc-in-ghci]
   stage: build
 
 validate-x86_64-linux-deb9-unreg-hadrian:
   extends: .validate-linux-hadrian
+  needs: [validate-x86_64-linux-deb9-hadrian]
   stage: full-build
   variables:
     CONFIGURE_ARGS: --enable-unregisterised
@@ -246,6 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian:
 
 hadrian-ghc-in-ghci:
   stage: quick-build
+  needs: [ghc-linters, lint-linters, lint-submods]
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   before_script:
     # workaround for docker permissions
@@ -273,6 +276,37 @@ hadrian-ghc-in-ghci:
     paths:
       - cabal-cache
 
+############################################################
+# GHC source code linting
+############################################################
+
+.lint-params:
+  stage: lint
+  needs: [ghc-linters, lint-submods]
+  tags:
+    - lint
+  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
+  before_script:
+    - export PATH="/opt/toolchain/bin:$PATH"
+    # workaround for docker permissions
+    - sudo chown ghc:ghc -R .
+    - git submodule sync --recursive
+    - git submodule update --init --recursive
+    - git checkout .gitmodules
+    - .gitlab/ci.sh setup
+    - cabal update
+    - cd hadrian; cabal new-build -j`../mk/detect-cpu-count.sh` --with-compiler=$GHC --project-file=ci.project; cd ..
+  variables:
+    GHC_FLAGS: -Werror
+
+lint-base:
+  extends: .lint-params
+  script:
+    - hadrian/build -c -j stage1:lib:base
+    - hadrian/build -j lint:base
+  cache:
+    key: lint
+
 ############################################################
 # Validation via Pipelines (make)
 ############################################################
@@ -301,7 +335,9 @@ hadrian-ghc-in-ghci:
 #################################
 
 .build-x86_64-freebsd:
+  stage: full-build
   extends: .validate
+  needs: [validate-x86_64-linux-deb9-hadrian]
   tags:
     - x86_64-freebsd
   allow_failure: true
@@ -331,23 +367,19 @@ hadrian-ghc-in-ghci:
 # Conditional due to lack of builder capacity
 validate-x86_64-freebsd:
   extends: .build-x86_64-freebsd
-  stage: full-build
   rules:
     - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/'
 
 nightly-x86_64-freebsd:
   <<: *nightly
   extends: .build-x86_64-freebsd
-  stage: full-build
 
 release-x86_64-freebsd:
   <<: *release
   extends: .build-x86_64-freebsd
-  stage: full-build
 
 .build-x86_64-freebsd-hadrian:
   extends: .validate-hadrian
-  stage: full-build
   tags:
     - x86_64-freebsd
   allow_failure: true
@@ -374,7 +406,6 @@ release-x86_64-freebsd:
 # Disabled due to lack of builder capacity
 .validate-x86_64-freebsd-hadrian:
   extends: .build-x86_64-freebsd-hadrian
-  stage: full-build
 
 #################################
 # x86_64-darwin
@@ -382,6 +413,7 @@ release-x86_64-freebsd:
 
 validate-x86_64-darwin:
   extends: .validate
+  needs: [validate-x86_64-linux-deb9-hadrian]
   stage: full-build
   tags:
     - x86_64-darwin
@@ -411,6 +443,7 @@ validate-x86_64-darwin:
 # Disabled because of OS X CI capacity
 .validate-x86_64-darwin-hadrian:
   stage: full-build
+  needs: [validate-x86_64-linux-deb9-hadrian]
   tags:
     - x86_64-darwin
   variables:
@@ -440,6 +473,7 @@ validate-x86_64-darwin:
 
 .validate-linux:
   extends: .validate
+  needs: [validate-x86_64-linux-deb9-hadrian]
   tags:
     - x86_64-linux
   variables:
@@ -809,6 +843,7 @@ validate-x86_64-linux-fedora27:
 
 .build-windows:
   # For the reasons given in #17777 this build isn't reliable.
+  needs: [validate-x86_64-linux-deb9-hadrian]
   allow_failure: true
   before_script:
     - git clean -xdf
@@ -929,6 +964,7 @@ release-x86_64-windows-integer-simple:
 
 doc-tarball:
   stage: packaging
+  needs: [validate-x86_64-linux-deb9-debug, validate-x86_64-windows-hadrian, validate-x86_64-linux-deb9-unreg-hadrian]
   tags:
     - x86_64-linux
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
@@ -964,6 +1000,7 @@ doc-tarball:
 
 source-tarball:
   stage: packaging
+  needs: [validate-x86_64-linux-deb9-unreg-hadrian]
   tags:
     - x86_64-linux
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
@@ -998,6 +1035,7 @@ source-tarball:
 
 .hackage:
   stage: testing
+  needs: [doc-tarball]
   image: ghcci/x86_64-linux-deb9:0.2
   tags:
     - x86_64-linux
@@ -1026,6 +1064,7 @@ nightly-hackage:
 
 perf-nofib:
   stage: testing
+  needs: [validate-x86_64-linux-deb9-dwarf, doc-tarball]
   dependencies:
     - validate-x86_64-linux-deb9-dwarf
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
@@ -1062,6 +1101,7 @@ perf-nofib:
 
 perf:
   stage: testing
+  needs: [validate-x86_64-linux-deb9-dwarf, doc-tarball]
   dependencies:
     - validate-x86_64-linux-deb9-dwarf
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
@@ -1097,6 +1137,7 @@ perf:
 
 pages:
   stage: deploy
+  needs: [doc-tarball]
   dependencies:
     - doc-tarball
   image: ghcci/x86_64-linux-deb9:0.2


=====================================
libraries/base/GHC/Event/EPoll.hsc
=====================================
@@ -1,8 +1,7 @@
-{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving
-           , NoImplicitPrelude
-           , BangPatterns
-  #-}
+{-# LANGUAGE BangPatterns               #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE NoImplicitPrelude          #-}
+{-# LANGUAGE Trustworthy                #-}
 
 -----------------------------------------------------------------------------
 -- |
@@ -50,8 +49,7 @@ import GHC.Base
 import GHC.Num (Num(..))
 import GHC.Real (fromIntegral, div)
 import GHC.Show (Show)
-import System.Posix.Internals (c_close)
-import System.Posix.Internals (setCloseOnExec)
+import System.Posix.Internals (c_close, setCloseOnExec)
 import System.Posix.Types (Fd(..))
 
 import qualified GHC.Event.Array    as A


=====================================
libraries/base/GHC/Event/KQueue.hsc
=====================================
@@ -1,10 +1,11 @@
-{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE CApiFFI
-           , GeneralizedNewtypeDeriving
-           , NoImplicitPrelude
-           , RecordWildCards
-           , BangPatterns
-  #-}
+{-# LANGUAGE BangPatterns               #-}
+{-# LANGUAGE CApiFFI                    #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE NoImplicitPrelude          #-}
+{-# LANGUAGE Trustworthy                #-}
+
+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
+{-# HLINT ignore "Unused LANGUAGE pragma" #-}
 
 module GHC.Event.KQueue
     (


=====================================
libraries/base/GHC/Event/Poll.hsc
=====================================
@@ -91,7 +91,7 @@ poll p mtout f = do
         c_pollLoop ptr (fromIntegral len) (fromTimeout tout)
       Nothing   ->
         c_poll_unsafe ptr (fromIntegral len) 0
-  when (n /= 0) $ do
+  when (n /= 0) $
     A.loop a 0 $ \i e -> do
       let r = pfdRevents e
       if r /= 0


=====================================
libraries/base/GHC/ExecutionStack/Internal.hsc
=====================================
@@ -171,7 +171,7 @@ stackFrames st@(StackTrace fptr) = unsafePerformIO $ withSession $ \sess -> do
             frame' = frame `plusPtr` sizeOf (undefined :: Addr)
 
         lookupFrame :: Addr -> IO (Maybe Location)
-        lookupFrame pc = withForeignPtr fptr $ const $ do
+        lookupFrame pc = withForeignPtr fptr $ const $
             allocaBytes locationSize $ \buf -> do
                 ret <- withForeignPtr sess $ \sessPtr -> libdw_lookup_location sessPtr buf pc
                 case ret of


=====================================
libraries/base/GHC/IO/Handle/Lock/LinuxOFD.hsc
=====================================
@@ -60,7 +60,7 @@ instance Storable FLock where
         #{poke struct flock, l_start}  ptr (l_start x)
         #{poke struct flock, l_len}    ptr (l_len x)
         #{poke struct flock, l_pid}    ptr (l_pid x)
-    peek ptr = do
+    peek ptr =
         FLock <$> #{peek struct flock, l_type}   ptr
               <*> #{peek struct flock, l_whence} ptr
               <*> #{peek struct flock, l_start}  ptr


=====================================
libraries/base/GHC/IO/Handle/Lock/Windows.hsc
=====================================
@@ -1,7 +1,5 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE InterruptibleFFI #-}
-{-# LANGUAGE LambdaCase #-}
-{-# LANGUAGE MultiWayIf #-}
 {-# LANGUAGE NoImplicitPrelude #-}
 
 -- | File locking for Windows.


=====================================
libraries/base/GHC/RTS/Flags.hsc
=====================================
@@ -1,6 +1,5 @@
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE RecordWildCards   #-}
 
 -- | Accessors to GHC RTS flags.
 -- Descriptions of flags can be seen in
@@ -392,7 +391,7 @@ data RTSFlags = RTSFlags
 foreign import ccall "&RtsFlags" rtsFlagsPtr :: Ptr RTSFlags
 
 getRTSFlags :: IO RTSFlags
-getRTSFlags = do
+getRTSFlags =
   RTSFlags <$> getGCFlags
            <*> getConcFlags
            <*> getMiscFlags


=====================================
libraries/base/System/Environment/ExecutablePath.hsc
=====================================
@@ -132,7 +132,7 @@ foreign import ccall unsafe "readlink"
 -- See readlink(2)
 readSymbolicLink :: FilePath -> IO FilePath
 readSymbolicLink file =
-    allocaArray0 4096 $ \buf -> do
+    allocaArray0 4096 $ \buf ->
         withFilePath file $ \s -> do
             len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $
                    c_readlink s buf 4096


=====================================
libraries/base/tests/Concurrent/ThreadDelay001.hs
=====================================
@@ -1,5 +1,7 @@
-{-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# HLINT ignore "Unused LANGUAGE pragma" #-}
+
 
 -- Test that threadDelay actually sleeps for (at least) as long as we
 -- ask it
@@ -16,6 +18,7 @@ import Data.Time
 #if defined(mingw32_HOST_OS)
 import GHC.Event.Windows.Clock
 #endif
+
 main :: IO ()
 main = mapM_ delay (0 : take 7 (iterate (*5) 100))
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7e2fff96975128397e2dab7d57da3c9c6b8c76b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7e2fff96975128397e2dab7d57da3c9c6b8c76b
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201009/b326361e/attachment-0001.html>


More information about the ghc-commits mailing list