From 00b0824635f1ab030234124d79af4fbea1d0053c Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sun, 3 Sep 2023 21:39:04 +0200 Subject: [PATCH] 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. --- maintainers/scripts/haskell/hydra-report.hs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/maintainers/scripts/haskell/hydra-report.hs b/maintainers/scripts/haskell/hydra-report.hs index 5f7e40a28bc..3dbd66f2e4c 100755 --- a/maintainers/scripts/haskell/hydra-report.hs +++ b/maintainers/scripts/haskell/hydra-report.hs @@ -151,15 +151,18 @@ data Build = Build } deriving (Generic, ToJSON, FromJSON, Show) +data RequestLogsFlag = RequestLogs | NoRequestLogs + main :: IO () main = do args <- getArgs case args of ["get-report"] -> getBuildReports ["ping-maintainers"] -> printMaintainerPing - ["mark-broken-list"] -> printMarkBrokenList + ["mark-broken-list", "--no-request-logs"] -> printMarkBrokenList NoRequestLogs + ["mark-broken-list"] -> printMarkBrokenList RequestLogs ["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 = getXdgDirectory XdgCache "haskell-updates-build-report.json" @@ -775,16 +778,20 @@ printMaintainerPing = do textBuildSummary = printBuildSummary eval fetchTime buildSum topBrokenRdeps Text.putStrLn textBuildSummary -printMarkBrokenList :: IO () -printMarkBrokenList = do +printMarkBrokenList :: RequestLogsFlag -> IO () +printMarkBrokenList reqLogs = do (_, fetchTime, buildReport) <- readBuildReports runReq defaultHttpConfig $ forM_ buildReport \build@Build{job, id} -> case (getBuildState build, Text.splitOn "." $ unJobName job) of (Failed, ["haskellPackages", name, "x86_64-linux"]) -> do - -- Fetch build log from hydra to figure out the cause of the error. - build_log <- ByteString.lines <$> hydraPlainQuery ["build", showT id, "nixlog", "1", "raw"] -- We use the last probable error cause found in the build log file. - let error_message = fromMaybe " failure " $ safeLast $ mapMaybe probableErrorCause build_log + 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. + build_log <- ByteString.lines <$> hydraPlainQuery ["build", showT id, "nixlog", "1", "raw"] + pure $ 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 _ -> pure ()