diff --git a/.github/workflows/packcheck.yml b/.github/workflows/packcheck.yml index edd0157..cd321c3 100644 --- a/.github/workflows/packcheck.yml +++ b/.github/workflows/packcheck.yml @@ -149,8 +149,8 @@ jobs: command: cabal ghc_version: 9.14.1 # WARNING! cannot use # comments inside pack_options. - #pack_options: >- - # CABAL_PROJECT=cabal.project + pack_options: >- + CABAL_PROJECT=cabal.project.Werror - name: ci runner: macos-latest diff --git a/.packcheck.ignore b/.packcheck.ignore index 068de0c..b233951 100644 --- a/.packcheck.ignore +++ b/.packcheck.ignore @@ -1,6 +1,6 @@ .packcheck.ignore .github/workflows/packcheck.yml .gitignore -cabal.project.user +cabal.project.Werror flake.lock flake.nix diff --git a/README.md b/README.md index f37a293..2c8d88a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,39 @@ packdiff diff ``` -**Limitations:** +## API Diff Output + +``` +--------------------------------- +API Annotations +--------------------------------- + +[A] : Added +[R] : Removed +[C] : Changed +[O] : Old definition +[N] : New definition +[D] : Deprecated + +--------------------------------- +API diff +--------------------------------- + +[C] Streamly.Data.Stream.Prelude + [A] useAcquire :: AcquireIO -> Config -> Config + [D] parEval :: MonadAsync m => (Config -> Config) -> Stream m a -> Stream m a +[C] Streamly.Data.Fold.Prelude + [C] toHashMapIO + [O] toHashMapIO :: (MonadIO m, Hashable k, Ord k) => (a -> k) -> Fold m a b -> Fold m a (HashMap k b) + [N] toHashMapIO :: (MonadIO m, Hashable k) => (a -> k) -> Fold m a b -> Fold m a (HashMap k b) +``` + +## CI Integration + +For CI integration check out packdiff github CI in the streamly repo: +https://github.com/composewell/streamly. + +## Limitations Packdiff uses the hoogle file created by haddock to generate and compare the difference between multiple versions of a package diff --git a/cabal.project.Werror b/cabal.project.Werror new file mode 100644 index 0000000..341ecff --- /dev/null +++ b/cabal.project.Werror @@ -0,0 +1,4 @@ +packages: . + +package packdiff + ghc-options: -Werror diff --git a/cabal.project.user b/cabal.project.user deleted file mode 100644 index e6fdbad..0000000 --- a/cabal.project.user +++ /dev/null @@ -1 +0,0 @@ -packages: . diff --git a/cli/Main.hs b/cli/Main.hs index 76edc34..c3838dc 100644 --- a/cli/Main.hs +++ b/cli/Main.hs @@ -1,3 +1,11 @@ +-- | +-- Module : Main +-- Copyright : (c) 2022 Composewell Technologies +-- License : BSD-3-Clause +-- Maintainer : streamly@composewell.com +-- Stability : released +-- Portability : GHC + module Main ( main ) where @@ -17,9 +25,10 @@ import System.Environment (getArgs) import qualified Data.Map as Map import qualified Streamly.Data.Fold as Fold import qualified Streamly.Data.Stream as Stream -import qualified Streamly.Internal.FileSystem.File as File +import qualified Streamly.Internal.FileSystem.FileIO as File import qualified Streamly.Internal.System.Command as Command import qualified Streamly.Internal.Unicode.Stream as Unicode +import qualified Streamly.FileSystem.Path as Path import Diff import HoogleFileParser @@ -67,7 +76,7 @@ checkoutAndGenerateHoogleFile target rev = do fileToLines :: String -> Stream IO String fileToLines path = - File.readChunks path & Unicode.decodeUtf8Chunks + File.readChunks (Path.fromString_ path) & Unicode.decodeUtf8Chunks & Stream.foldMany (Fold.takeEndBy_ (== '\n') Fold.toList) isDeprecated :: [Annotation] -> Bool diff --git a/packdiff.cabal b/packdiff.cabal index 2c39309..16c0ec2 100644 --- a/packdiff.cabal +++ b/packdiff.cabal @@ -1,19 +1,32 @@ cabal-version: 2.2 --- Initial package description 'packdiff.cabal' generated by 'cabal --- init'. For further documentation, see --- http://haskell.org/cabal/users-guide/ - name: packdiff version: 0.1.0.0 --- synopsis: --- description: --- bug-reports: +synopsis: Find API changes between different versions of a package +description: + Packdiff compares different Git commits or Hackage versions of a package to + identify: + . + * Signature changes. + * Deprecated functions. + * Added or removed functions. + . + It helps you to: + . + * Generate API changelogs automatically. + * Generate API diff on pull requests. + * Compare new changes against published Hackage releases. + * Decide the new version of a package. + * Find breaking changes in the new release. + . + See the README for more details. + . +bug-reports: https://github.com/composewell/packdiff/issues license: Apache-2.0 license-file: LICENSE author: Composewell Technologies maintainer: streamly@composewell.com copyright: 2022 Composewell Technologies --- category: +category: Development, Package Management, Cabal, PVP build-type: Simple tested-with: GHC==9.14.1 @@ -23,6 +36,10 @@ tested-with: , GHC==9.6.3 extra-doc-files: README.md, CHANGELOG.md +source-repository head + type: git + location: https://github.com/composewell/packdiff + common compile-options default-language: Haskell2010 ghc-options: -Weverything @@ -30,12 +47,15 @@ common compile-options -Wno-implicit-prelude -Wno-missing-import-lists -Wno-missing-deriving-strategies + -Wno-missing-kind-signatures -Wno-missing-local-signatures + -Wno-missing-role-annotations -Wno-missing-safe-haskell-mode -Wno-missed-specialisations -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-unsafe + -Wno-x-partial library import: compile-options diff --git a/src/Diff.hs b/src/Diff.hs index b4e199a..d97f1c6 100644 --- a/src/Diff.hs +++ b/src/Diff.hs @@ -1,3 +1,11 @@ +-- | +-- Module : Diff +-- Copyright : (c) 2022 Composewell Technologies +-- License : BSD-3-Clause +-- Maintainer : streamly@composewell.com +-- Stability : released +-- Portability : GHC + module Diff ( StatusTag(..) , diffAPI diff --git a/src/HoogleFileParser.hs b/src/HoogleFileParser.hs index 63801b7..8f7a0ba 100644 --- a/src/HoogleFileParser.hs +++ b/src/HoogleFileParser.hs @@ -1,3 +1,10 @@ +-- | +-- Module : HoogleFileParser +-- Copyright : (c) 2022 Composewell Technologies +-- License : BSD-3-Clause +-- Maintainer : streamly@composewell.com +-- Stability : released +-- Portability : GHC module HoogleFileParser ( -- Types diff --git a/src/Pretty.hs b/src/Pretty.hs index 666c5d5..dc90b7f 100644 --- a/src/Pretty.hs +++ b/src/Pretty.hs @@ -1,3 +1,10 @@ +-- | +-- Module : Pretty +-- Copyright : (c) 2022 Composewell Technologies +-- License : BSD-3-Clause +-- Maintainer : streamly@composewell.com +-- Stability : released +-- Portability : GHC module Pretty ( prettyAPI @@ -24,11 +31,13 @@ import Diff -- Printing helpers -------------------------------------------------------------------------------- +{- prettyTag :: StatusTag s -> String prettyTag Added = "[A]" prettyTag Removed = "[R]" prettyTag Same = "[S]" prettyTag (Changed _) = "[C]" +-} isDeprecated :: [Annotation] -> Bool isDeprecated anns = @@ -72,12 +81,13 @@ prettyD0_ _ (Tagged (Attach (DBoth annsL annsR) Same) b) = if isDeprecated annsR && not (isDeprecated annsL) then ["[D] " ++ showECT b] else [""] +prettyD0_ _ _ = error "prettyD0_: impossible pattern" prettyD1_ :: String -> Tagged (Attach (Diff [Annotation]) (StatusTag ())) (Map String (Tagged (Attach (Diff [Annotation]) (StatusTag EntityContextType)) EntityContextType)) -> [String] -prettyD1_ k (Tagged (Attach (DLeft anns) Removed) b) = +prettyD1_ k (Tagged (Attach (DLeft anns) Removed) _) = if isDeprecated anns then [""] else ["[R] " ++ k] @@ -93,17 +103,18 @@ prettyD1_ k (Tagged (Attach (DBoth annsL annsR) (Changed ())) b) = else if not (isDeprecated annsR) && isDeprecated annsL then [""] else concat [["[C] " ++ k], indenter 4 (prettyD0 b)] -prettyD1_ k (Tagged (Attach (DBoth annsL annsR) Same) b) = +prettyD1_ k (Tagged (Attach (DBoth annsL annsR) Same) _) = if isDeprecated annsR && not (isDeprecated annsL) then ["[D] " ++ k] else [""] +prettyD1_ _ _ = error "prettyD1_: impossible pattern" prettyAPI_ :: [Element] -> ModuleName -> Tagged (Attach (Diff [Annotation]) (StatusTag ())) (ModuleContextDefault (Attach (Diff [Annotation]) (StatusTag ())) (Attach (Diff [Annotation]) (StatusTag EntityContextType))) -> [String] -prettyAPI_ _ k (Tagged (Attach (DLeft anns) Removed) b) = +prettyAPI_ _ k (Tagged (Attach (DLeft anns) Removed) _) = if isDeprecated anns then [""] else ["[R] " ++ k] @@ -119,10 +130,11 @@ prettyAPI_ elems k (Tagged (Attach (DBoth annsL annsR) (Changed ())) b) = else if not (isDeprecated annsR) && isDeprecated annsL then [""] else concat [["[C] " ++ k], indenter 4 (prettyMC elems b)] -prettyAPI_ _ k (Tagged (Attach (DBoth annsL annsR) Same) b) = +prettyAPI_ _ k (Tagged (Attach (DBoth annsL annsR) Same) _) = if isDeprecated annsR && not (isDeprecated annsL) then ["[D] " ++ k] else [""] +prettyAPI_ _ _ _ = error "prettyAPI_: impossible pattern" indenter :: Int -> [String] -> [String] indenter i = map (replicate i ' ' ++) @@ -156,7 +168,7 @@ prettyD1 :: Bool -> Map String (Tagged (Attach (Diff [Annotation]) (StatusTag ())) (Map String (Tagged (Attach (Diff [Annotation]) (StatusTag EntityContextType)) EntityContextType))) -> [String] -prettyD1 l = SMap.foldlWithKey step initial +prettyD1 _ = SMap.foldlWithKey step initial where