Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/packcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .packcheck.ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.packcheck.ignore
.github/workflows/packcheck.yml
.gitignore
cabal.project.user
cabal.project.Werror
flake.lock
flake.nix
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,39 @@
packdiff diff <package-name> <rev1> <package-name> <rev2>
```

**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
Expand Down
4 changes: 4 additions & 0 deletions cabal.project.Werror
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .

package packdiff
ghc-options: -Werror
1 change: 0 additions & 1 deletion cabal.project.user

This file was deleted.

13 changes: 11 additions & 2 deletions cli/Main.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 28 additions & 8 deletions packdiff.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,19 +36,26 @@ 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
-Wno-all-missed-specialisations
-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
Expand Down
8 changes: 8 additions & 0 deletions src/Diff.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/HoogleFileParser.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 17 additions & 5 deletions src/Pretty.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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 ' ' ++)
Expand Down Expand Up @@ -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

Expand Down
Loading