diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index 6dab57705b9bc..1ca8cfdb56184 100644 --- a/cli/internal/run/run.go +++ b/cli/internal/run/run.go @@ -129,12 +129,11 @@ func optsFromArgs(args *turbostate.ParsedArgsFromRust) (*Opts, error) { } func configureRun(base *cmdutil.CmdBase, opts *Opts, signalWatcher *signals.Watcher) *run { - // TODO: We currently don't respect the user's input if they ask for task prefixes on - // GitHub Actions and forcibly strip tasks from their logs even if they specify - // that they want it. This should be fixed in Go and Rust at the same time. if opts.runOpts.LogOrder == "auto" && ci.Constant() == "GITHUB_ACTIONS" { opts.runOpts.LogOrder = "grouped" - opts.runOpts.LogPrefix = "none" + if opts.runOpts.LogPrefix != "task" { + opts.runOpts.LogPrefix = "none" + } opts.runOpts.IsGithubActions = true } diff --git a/crates/turborepo-lib/src/opts.rs b/crates/turborepo-lib/src/opts.rs index 93a070700a7e9..fcb8354fd0c01 100644 --- a/crates/turborepo-lib/src/opts.rs +++ b/crates/turborepo-lib/src/opts.rs @@ -114,12 +114,15 @@ impl<'a> TryFrom<&'a RunArgs> for RunOpts<'a> { }); let (is_github_actions, log_order, log_prefix) = match args.log_order { - // TODO: We currently don't respect the user's input if they ask for task prefixes on - // GitHub Actions and forcibly strip tasks from their logs even if they specify - // that they want it. This should be fixed in Go and Rust at the same time. - LogOrder::Auto if turborepo_ci::Vendor::get_constant() == Some("GITHUB_ACTIONS") => { - (true, ResolvedLogOrder::Grouped, ResolvedLogPrefix::None) - } + LogOrder::Auto if turborepo_ci::Vendor::get_constant() == Some("GITHUB_ACTIONS") => ( + true, + ResolvedLogOrder::Grouped, + match args.log_prefix { + LogPrefix::Task => ResolvedLogPrefix::Task, + _ => ResolvedLogPrefix::None, + }, + ), + // Streaming is the default behavior except when running on GitHub Actions LogOrder::Auto | LogOrder::Stream => { (false, ResolvedLogOrder::Stream, args.log_prefix.into()) diff --git a/turborepo-tests/integration/tests/ordered/github.t b/turborepo-tests/integration/tests/ordered/github.t index a2e205f179ade..04f70383e8116 100644 --- a/turborepo-tests/integration/tests/ordered/github.t +++ b/turborepo-tests/integration/tests/ordered/github.t @@ -5,8 +5,7 @@ # Build as if we are in Github Actions Note that we need to use (re) for lines that start with '> ' because otherwise prysk interprets them as multiline commands - $ export GITHUB_ACTIONS=1 - $ ${TURBO} run build --force + $ GITHUB_ACTIONS=1 ${TURBO} run build --force \xe2\x80\xa2 Packages in scope: my-app, util (esc) \xe2\x80\xa2 Running build in 2 packages (esc) \xe2\x80\xa2 Remote caching disabled (esc) @@ -33,8 +32,28 @@ because otherwise prysk interprets them as multiline commands Cached: 0 cached, 2 total Time:\s*[\.0-9]+m?s (re) +# Build as if we are in Github Actions with a task log prefix. + $ GITHUB_ACTIONS=1 ${TURBO} run build --force --log-prefix="task" --filter=util + \xe2\x80\xa2 Packages in scope: util (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + ::group::util:build + util:build: cache bypass, force executing 90d7154e362e3386 + util:build: + util:build: > build + util:build: > sleep 0.5 && echo 'building' && sleep 1 && echo 'completed' + util:build: + util:build: building + util:build: completed + ::endgroup:: + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + + Verify that errors are grouped properly - $ ${TURBO} run fail + $ GITHUB_ACTIONS=1 ${TURBO} run fail \xe2\x80\xa2 Packages in scope: my-app, util (esc) \xe2\x80\xa2 Running fail in 2 packages (esc) \xe2\x80\xa2 Remote caching disabled (esc)