diff --git a/README.md b/README.md index 92fc34c..a1b401d 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,7 @@ Go [read the full docs](https://www.iffycan.com/lin/linlib.html), but here's a h Other helpful hints: - Sequences can include other sequences, thus chaining them together. See the `includes` param. + +# GitHub Actions + +When run on a Github Actions runner, step output will be put into folds by default. To disable this, set `LIN_DISABLE_FOLDS=true` diff --git a/changes/new-Fold-output-in-20250813-101858.md b/changes/new-Fold-output-in-20250813-101858.md new file mode 100644 index 0000000..351697c --- /dev/null +++ b/changes/new-Fold-output-in-20250813-101858.md @@ -0,0 +1 @@ +Fold output in Github Actions diff --git a/src/linpkg/linlib.nim b/src/linpkg/linlib.nim index c1b9088..9c9b101 100644 --- a/src/linpkg/linlib.nim +++ b/src/linpkg/linlib.nim @@ -297,6 +297,8 @@ proc stamp(d:Duration):string = proc run*(lin:Lin, args:openArray[string]):bool = addExitProc(resetAttributes) + let isGITHUBACTIONS = getEnv("GITHUB_ACTIONS") == "true" + let doGithubActionsGrouping = isGITHUBACTIONS and getEnv("LIN_DISABLE_FOLDS") == "" let steps = lin.collectSteps(args) let grand_start = getTime() result = true @@ -314,6 +316,10 @@ proc run*(lin:Lin, args:openArray[string]):bool = res:RunStatus start = getTime() step_total: Duration + if doGithubActionsGrouping: + stderr.writeLine &"::group::{fq_stepnumber} {step.fullname}" + stdout.flushFile() + stderr.flushFile() stderr.styledWrite(styleDim, "[lin] ") stderr.styledWriteLine(styleReverse, &"{fq_stepnumber} {step.fullname}") try: @@ -348,6 +354,10 @@ proc run*(lin:Lin, args:openArray[string]):bool = color = fgCyan code = "skipped" + if doGithubActionsGrouping: + stderr.flushFile() + stderr.writeLine "::endgroup::" + stdout.flushFile() stderr.styledWrite(styleDim, "[lin] ") stderr.styledWrite(color, styleReverse, &"{fq_stepnumber} {step.fullname}") stderr.styledWriteLine(color, &" done {code} {step_total.stamp} {msg}")