Skip to content

Commit

Permalink
nixpkgsreview: handle missing report
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Oct 31, 2024
1 parent 2063b5e commit 525c2e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/NixpkgsReview.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Language.Haskell.TH.Env (envQ)
import OurPrelude
import Polysemy.Output (Output, output)
import qualified Process as P
import System.Directory (doesFileExist)
import System.Environment.XDG.BaseDir (getUserCacheDir)
import System.Exit ()
import qualified Utils
Expand All @@ -29,7 +30,7 @@ revDir :: FilePath -> Text -> FilePath
revDir cache commit = cache <> "/rev-" <> T.unpack commit

run ::
Members '[F.File, P.Process, Output Text] r =>
Members '[F.File, P.Process, Output Text, Embed IO] r =>
FilePath ->
Text ->
Sem r Text
Expand All @@ -48,7 +49,13 @@ run cache commit =
ExitFailure 124 -> do
output $ "[check][nixpkgs-review] took longer than " <> timeout <> " and timed out"
return $ "nixpkgs-review took longer than " <> timeout <> " and timed out"
_ -> F.read $ (revDir cache commit) <> "/report.md"
_ -> do
reportExists <- embed $ doesFileExist (revDir cache commit <> "/report.md")
if reportExists
then F.read $ (revDir cache commit) <> "/report.md"
else do
output $ "[check][nixpkgs-review] report.md does not exist"
return $ "nixpkgs-review failed"

-- Assumes we are already in nixpkgs dir
runReport :: (Text -> IO ()) -> Text -> IO Text
Expand Down

0 comments on commit 525c2e4

Please sign in to comment.