First use of 'echo ::group::name' in script does not work properly

When running a bash script which uses grouping

#!/bin/bash

echo Text
echo ::group::Git stuff
git clone ...
echo ::endgroup::

called from workflow as

- name: something
run: ./my-script.sh

output of git clone is displayed before other script output.

Expected

Text
▶ Git stuff

Current

Cloning into..
Text
▶ Git stuff

runner v2.158.0

Hey @wipe2238 ,

Are you able to provide a link to the run where you are seeing this behavior? I have not been able to reproduce this issue. How frequently does this occur for you?

@thboop

Some random jobs from last 12h (can’t find a way to view anything older):

https://github.com/rotators/cron/runs/238777455#step:3:6

https://github.com/rotators/cron/runs/238778623#step:3:6

https://github.com/rotators/cron/runs/238711349#step:3:6

https://github.com/rotators/cron/runs/238712452#step:3:6

https://github.com/rotators/cron/runs/238587989#step:3:6

https://github.com/rotators/cron/runs/238520387#step:3:6

https://github.com/rotators/cron/runs/238396257#step:3:6

https://github.com/rotators/cron/runs/238268271#step:3:6

https://github.com/rotators/cron/runs/238230060#step:3:6

Script which causes it (there’s more than one in repo, but they’re basically tweaked copypaste):

https://github.com/rotators/cron/blob/2b6fd928f55504383d97bf028f778a096ef062d9/fork-mirror.sh#L24-L34

https://github.com/rotators/cron/blob/2b6fd928f55504383d97bf028f778a096ef062d9/.github/workflows/fork-mirror.yml#L17-L20

It seems that either something changed in last few days, or i’m just lucky recently. Previously it was rare to see first ::group working properly, now it’s a bit better but still present and easy to spot in my scenario (all workflows are schedule-only).

Hey @wipe2238 ,

Thanks so much for the report and detailed examples! I’ve been able to reproduce and find the root cause.

We have filed a bug for this issue so our team can work on a fix:

Items sent to stderr may be processed before stdout commands are processed, resulting in what you are seeing.

As for current workarounds:

You may want try piping git output from stderr to stdout.

It appears git clone outputs to the error stream: https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-clone.html

Thanks again!

2 Likes