()
| 341 | } |
| 342 | |
| 343 | #createGroupMarkers(): { |
| 344 | start: (title: string) => string; |
| 345 | end: () => string; |
| 346 | } { |
| 347 | // Nx typically renders native log groups for each target in GitHub |
| 348 | // + GitHub doesn't support nested log groups: https://github.com/actions/toolkit/issues/1001 |
| 349 | // => skip native GitHub log groups if run within Nx target |
| 350 | const platform = |
| 351 | this.#ciPlatform === 'GitHub' && process.env['NX_TASK_TARGET_TARGET'] // https://nx.dev/docs/reference/environment-variables |
| 352 | ? undefined |
| 353 | : this.#ciPlatform; |
| 354 | |
| 355 | switch (platform) { |
| 356 | case 'GitHub': |
| 357 | // https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#grouping-log-lines |
| 358 | return { |
| 359 | start: title => |
| 360 | `::group::${this.#formatGroupTitle(title, { prefix: false })}`, |
| 361 | end: () => '::endgroup::', |
| 362 | }; |
| 363 | case 'GitLab': |
| 364 | // https://docs.gitlab.com/ci/jobs/job_logs/#custom-collapsible-sections |
| 365 | const ansiEscCode = '\u001B[0K'; // '\e' ESC character only works for `echo -e`, Node console must use '\u001B' |
| 366 | const id = Math.random().toString(HEX_RADIX).slice(2); |
| 367 | const sectionId = `code_pushup_logs_group_${id}`; |
| 368 | return { |
| 369 | start: title => { |
| 370 | const sectionHeader = this.#formatGroupTitle(title, { |
| 371 | prefix: true, |
| 372 | }); |
| 373 | const options = this.#isVerbose ? '' : '[collapsed=true]'; |
| 374 | // return `${ansiEscCode}section_start:${dateToUnixTimestamp(new Date())}:${sectionId}${options}${ansiEscCode}${sectionHeader}`; |
| 375 | return `${ansiEscCode}section_start:${dateToUnixTimestamp(new Date())}:${sectionId}${options}\r${ansiEscCode}${sectionHeader}`; |
| 376 | }, |
| 377 | end: () => |
| 378 | // `${ansiEscCode}section_end:${dateToUnixTimestamp(new Date())}:${sectionId}${ansiEscCode}`, |
| 379 | `${ansiEscCode}section_end:${dateToUnixTimestamp(new Date())}:${sectionId}\r${ansiEscCode}`, |
| 380 | }; |
| 381 | case undefined: |
| 382 | return { |
| 383 | start: title => this.#formatGroupTitle(title, { prefix: true }), |
| 384 | end: () => '', |
| 385 | }; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | #formatGroupTitle(title: string, symbols: { prefix: boolean }): string { |
| 390 | const text = symbols.prefix |
no test coverage detected