From e77fdc7381744f6eb5a5944cd17f5b1a08204d20 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 13 Nov 2024 11:51:50 -0600 Subject: [PATCH] add reporting to cache build --- pkgs/oizys/src/oizys/nix.nim | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkgs/oizys/src/oizys/nix.nim b/pkgs/oizys/src/oizys/nix.nim index df389ac..ccf8a7b 100644 --- a/pkgs/oizys/src/oizys/nix.nim +++ b/pkgs/oizys/src/oizys/nix.nim @@ -297,6 +297,23 @@ func outputsPaths(o: OizysDerivation): seq[string] = for _, output in o.drv.outputs: result.add output.path +proc reportResults(results: seq[(OizysDerivation, BuildResult)]) = + let rows = collect( + for (drv, res) in results: + let (name, hash) = splitDrv(drv.name) + fmt"| {name} | `{hash}` | " & ( + if res.successful: ":white_check_mark:" + else: ":x:" + ) & " |" + ) + let summaryFilePath = getEnv("GITHUB_STEP_SUMMARY") + if summaryFilePath == "": fatalQuit "no github step summary found" + let output = open(summaryFilePath,fmAppend) + output.writeLine("| derivation | hash | build successful |\n|---|---|---|") + output.writeLine(rows.join("\n")) + close output + + proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: int) = ## build individual derivations not cached and push to cache if findExe(service) == "": fatalQuit fmt"is {service} installed?" @@ -312,12 +329,14 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i for drv in drvs: (drv, build(drv, rest)) - # TODO: add back reporting to GITHUB SUMMARY var outs: seq[string] for (drv, res) in results: if res.successful: outs &= drv.outputsPaths + if isCi(): + reportResults(results) + # TODO: push after build not at once? var cmd = service cmd.addArg "push"