Skip to content

Commit 1d6a2ba

Browse files
committed
Lint changelogs in CI
1 parent 261f086 commit 1d6a2ba

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

.github/workflows/haskell.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ jobs:
5252

5353
- name: Run tests
5454
run: cabal test all
55+
56+
- name: Lint changelogs
57+
run: |
58+
cabal run -- cardano-ledger-release-tool changelogs -i $(git ls-files '*CHANGELOG.md')
59+
git diff --exit-code

changelogs/Changelogs.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
module Changelogs (name, subcmd, version) where
66

77
import Changelog
8-
import Control.Monad (unless)
9-
import Data.Either (lefts)
10-
import Data.Foldable (for_)
8+
import Control.Monad (when, (<=<))
9+
import Data.Bitraversable (bitraverse)
10+
import Data.Either (isLeft)
1111
import Data.Functor ((<&>))
1212
import Data.Text.Lazy (Text, unpack)
1313
import Data.Traversable (for)
@@ -68,12 +68,10 @@ subcmd :: Mod CommandFields (Global.Options -> IO ())
6868
subcmd =
6969
command "changelogs" $
7070
options <&> \Options {..} Global.Options {} -> do
71-
errs <- fmap lefts . for optChangelogs $ \fp -> do
72-
tryAny $ do
71+
failure <- fmap (any isLeft) . for optChangelogs $ \fp -> do
72+
bitraverse (hPrint stderr) pure <=< tryAny $ do
7373
let
7474
throwError e = errorWithoutStackTrace $ fp <> ": " <> TL.unpack e
7575
writeLog = optWriteFile fp . renderChangelog optBulletHierarchy
7676
either throwError writeLog . parseChangelog =<< TL.readFile fp
77-
for_ errs $
78-
hPrint stderr
79-
unless (null errs) exitFailure
77+
when failure exitFailure

0 commit comments

Comments
 (0)