@@ -10,7 +10,7 @@ import { formatDuration, indentLines, transformLines } from './formatting.js';
1010import { settlePromise } from './promises.js' ;
1111
1212type GroupColor = Extract < AnsiColors , 'cyan' | 'magenta' > ;
13- type CiPlatform = 'GitHub Actions ' | 'GitLab CI/CD ' ;
13+ type CiPlatform = 'GitHub' | 'GitLab' ;
1414
1515/** Additional options for log methods */
1616export type LogOptions = {
@@ -43,9 +43,9 @@ export class Logger {
4343 #isVerbose = isEnvVarEnabled ( 'CP_VERBOSE' ) ;
4444 #isCI = isEnvVarEnabled ( 'CI' ) ;
4545 #ciPlatform: CiPlatform | undefined = isEnvVarEnabled ( 'GITHUB_ACTIONS' )
46- ? 'GitHub Actions '
46+ ? 'GitHub'
4747 : isEnvVarEnabled ( 'GITLAB_CI' )
48- ? 'GitLab CI/CD '
48+ ? 'GitLab'
4949 : undefined ;
5050 #groupColor: GroupColor | undefined ;
5151
@@ -350,15 +350,23 @@ export class Logger {
350350 start : ( title : string ) => string ;
351351 end : ( ) => string ;
352352 } {
353- switch ( this . #ciPlatform) {
354- case 'GitHub Actions' :
353+ // Nx typically renders native log groups for each target in GitHub
354+ // + GitHub doesn't support nested log groups: https://github.com/actions/toolkit/issues/1001
355+ // => skip native GitHub log groups if run within Nx target
356+ const platform =
357+ this . #ciPlatform === 'GitHub' && process . env [ 'NX_TASK_TARGET_TARGET' ] // https://nx.dev/docs/reference/environment-variables
358+ ? undefined
359+ : this . #ciPlatform;
360+
361+ switch ( platform ) {
362+ case 'GitHub' :
355363 // https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#grouping-log-lines
356364 return {
357365 start : title =>
358366 `::group::${ this . #formatGroupTitle( title , { prefix : false } ) } ` ,
359367 end : ( ) => '::endgroup::' ,
360368 } ;
361- case 'GitLab CI/CD ' :
369+ case 'GitLab' :
362370 // https://docs.gitlab.com/ci/jobs/job_logs/#custom-collapsible-sections
363371 const ansiEscCode = '\u001B[0K' ; // '\e' ESC character only works for `echo -e`, Node console must use '\u001B'
364372 const id = Math . random ( ) . toString ( HEX_RADIX ) . slice ( 2 ) ;
0 commit comments