diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-22 20:20:36 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-22 20:20:36 -0500 |
| commit | 99fe1c1cd540aea8054efe4f162e858df658d016 (patch) | |
| tree | 443e7f79eda37ff5a9b598262fbb98aefa0de3ee /Omni/Ci.hs | |
| parent | 0ffd8c74069fac5df18bf7dfd22b638c386144e1 (diff) | |
Omni/Ci: enhance error diagnostics and progress feedback
- Capture stderr from lint/test failures in git notes
- Add progress logging showing file counts
- Fix date format to use UTC
- Include truncated error messages for easier debugging
Diffstat (limited to 'Omni/Ci.hs')
| -rwxr-xr-x | Omni/Ci.hs | 51 |
1 files changed, 34 insertions, 17 deletions
@@ -61,7 +61,7 @@ move _ = do Environment.setEnv "BILD_ARGS" bildArgs -- 3. Get user info - at <- readProcess "date" ["-R"] "" |> fmap chomp + at <- readProcess "date" ["-u", "-R"] "" |> fmap chomp user <- readProcess "git" ["config", "--get", "user.name"] "" |> fmap chomp mail <- readProcess "git" ["config", "--get", "user.email"] "" |> fmap chomp @@ -88,7 +88,6 @@ move _ = do Log.info ["ci", "building lint"] callProcess "bild" [coderoot </> "Omni/Lint.hs"] - Log.info ["ci", "running lint"] -- if "$runlint" "${CODEROOT:?}"/**/* -- We need to expand **/* which shell does. -- Since we are in Haskell, we can just pass "." or call git ls-files or similar. @@ -110,6 +109,8 @@ move _ = do /> map Text.unpack /> filter (not <. null) + Log.info ["ci", "running lint on " <> show (length allFiles) <> " files"] + -- We can't pass all files as arguments if there are too many (ARG_MAX). -- But wait, Omni/Lint.hs takes arguments. -- If we want to check everything, maybe we should implement a "check all" mode in Lint or pass chunks. @@ -133,14 +134,14 @@ move _ = do -- it treats args as file paths. -- We will try to run it. - (exitCodeLint, _, _) <- Process.readProcessWithExitCode runlint allFiles "" + (exitCodeLint, _, lintStderr) <- Process.readProcessWithExitCode runlint allFiles "" pure <| case exitCodeLint of - Exit.ExitSuccess -> "good" - _ -> "fail" + Exit.ExitSuccess -> ("good", "") + _ -> ("fail", Text.pack lintStderr) -- 6. Run Tests -- if bild "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/* - Log.info ["ci", "running tests"] + Log.info ["ci", "running tests on " <> show (length allFiles) <> " namespaces"] testResult <- do -- similarly, bild takes targets. @@ -148,25 +149,41 @@ move _ = do -- We can pass namespaces. -- Let's try passing all files again. -- bild handles namespaces. - (exitCodeTest, _, _) <- Process.readProcessWithExitCode "bild" ("--test" : allFiles) "" + (exitCodeTest, _, testStderr) <- Process.readProcessWithExitCode "bild" ("--test" : allFiles) "" pure <| case exitCodeTest of - Exit.ExitSuccess -> "good" - _ -> "fail" + Exit.ExitSuccess -> ("good", "") + _ -> ("fail", Text.pack testStderr) -- 7. Create Note - let noteMsg = - Text.unlines - [ "Lint-is: " <> lintResult, - "Test-is: " <> testResult, - "Test-by: " <> user <> " <" <> mail <> ">", - "Test-at: " <> at - ] + let noteMsg = case (fst lintResult, fst testResult) of + ("good", "good") -> + Text.unlines + [ "Lint-is: " <> fst lintResult, + "Test-is: " <> fst testResult, + "Test-by: " <> user <> " <" <> mail <> ">", + "Test-at: " <> at + ] + _ -> + Text.unlines + <| filter + (not <. Text.null) + [ "Lint-is: " <> fst lintResult, + "Test-is: " <> fst testResult, + case snd lintResult of + "" -> "" + err -> "Lint-error: " <> Text.take 300 err, + case snd testResult of + "" -> "" + err -> "Test-error: " <> Text.take 300 err, + "Test-by: " <> user <> " <" <> mail <> ">", + "Test-at: " <> at + ] -- 8. Append Note callProcess "git" ["notes", "--ref=ci", "append", "-m", Text.unpack noteMsg] -- 9. Exit - if lintResult == "good" && testResult == "good" + if fst lintResult == "good" && fst testResult == "good" then Exit.exitSuccess else do Log.fail ["ci", "verification failed"] |
