maintainers/haskell/hydra-report.hs: allow disabling log requesting
Since every failure in the jobset means one request to get the log when generating the list of newly broken packages, we need to add an option to disable log requesting in case a lot of new breakage needs to be entered.
This commit is contained in:
parent
7511d5bfbf
commit
00b0824635
|
@ -151,15 +151,18 @@ data Build = Build
|
||||||
}
|
}
|
||||||
deriving (Generic, ToJSON, FromJSON, Show)
|
deriving (Generic, ToJSON, FromJSON, Show)
|
||||||
|
|
||||||
|
data RequestLogsFlag = RequestLogs | NoRequestLogs
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
case args of
|
case args of
|
||||||
["get-report"] -> getBuildReports
|
["get-report"] -> getBuildReports
|
||||||
["ping-maintainers"] -> printMaintainerPing
|
["ping-maintainers"] -> printMaintainerPing
|
||||||
["mark-broken-list"] -> printMarkBrokenList
|
["mark-broken-list", "--no-request-logs"] -> printMarkBrokenList NoRequestLogs
|
||||||
|
["mark-broken-list"] -> printMarkBrokenList RequestLogs
|
||||||
["eval-info"] -> printEvalInfo
|
["eval-info"] -> printEvalInfo
|
||||||
_ -> putStrLn "Usage: get-report | ping-maintainers | mark-broken-list | eval-info"
|
_ -> putStrLn "Usage: get-report | ping-maintainers | mark-broken-list [--no-request-logs] | eval-info"
|
||||||
|
|
||||||
reportFileName :: IO FilePath
|
reportFileName :: IO FilePath
|
||||||
reportFileName = getXdgDirectory XdgCache "haskell-updates-build-report.json"
|
reportFileName = getXdgDirectory XdgCache "haskell-updates-build-report.json"
|
||||||
|
@ -775,16 +778,20 @@ printMaintainerPing = do
|
||||||
textBuildSummary = printBuildSummary eval fetchTime buildSum topBrokenRdeps
|
textBuildSummary = printBuildSummary eval fetchTime buildSum topBrokenRdeps
|
||||||
Text.putStrLn textBuildSummary
|
Text.putStrLn textBuildSummary
|
||||||
|
|
||||||
printMarkBrokenList :: IO ()
|
printMarkBrokenList :: RequestLogsFlag -> IO ()
|
||||||
printMarkBrokenList = do
|
printMarkBrokenList reqLogs = do
|
||||||
(_, fetchTime, buildReport) <- readBuildReports
|
(_, fetchTime, buildReport) <- readBuildReports
|
||||||
runReq defaultHttpConfig $ forM_ buildReport \build@Build{job, id} ->
|
runReq defaultHttpConfig $ forM_ buildReport \build@Build{job, id} ->
|
||||||
case (getBuildState build, Text.splitOn "." $ unJobName job) of
|
case (getBuildState build, Text.splitOn "." $ unJobName job) of
|
||||||
(Failed, ["haskellPackages", name, "x86_64-linux"]) -> do
|
(Failed, ["haskellPackages", name, "x86_64-linux"]) -> do
|
||||||
|
-- We use the last probable error cause found in the build log file.
|
||||||
|
error_message <- fromMaybe "failure" <$>
|
||||||
|
case reqLogs of
|
||||||
|
NoRequestLogs -> pure Nothing
|
||||||
|
RequestLogs -> do
|
||||||
-- Fetch build log from hydra to figure out the cause of the error.
|
-- Fetch build log from hydra to figure out the cause of the error.
|
||||||
build_log <- ByteString.lines <$> hydraPlainQuery ["build", showT id, "nixlog", "1", "raw"]
|
build_log <- ByteString.lines <$> hydraPlainQuery ["build", showT id, "nixlog", "1", "raw"]
|
||||||
-- We use the last probable error cause found in the build log file.
|
pure $ safeLast $ mapMaybe probableErrorCause build_log
|
||||||
let error_message = fromMaybe " failure " $ safeLast $ mapMaybe probableErrorCause build_log
|
|
||||||
liftIO $ putStrLn $ " - " <> Text.unpack name <> " # " <> error_message <> " in job https://hydra.nixos.org/build/" <> show id <> " at " <> formatTime defaultTimeLocale "%Y-%m-%d" fetchTime
|
liftIO $ putStrLn $ " - " <> Text.unpack name <> " # " <> error_message <> " in job https://hydra.nixos.org/build/" <> show id <> " at " <> formatTime defaultTimeLocale "%Y-%m-%d" fetchTime
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue