Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move test for Azure DevOps environment up #128

Merged
merged 2 commits into from
Dec 7, 2022

Conversation

josundt
Copy link
Contributor

@josundt josundt commented Dec 3, 2021

I recently contributed with PR #126 to support color (level 1) in Azure DevOps pipelines.

I have now tried latest chalk version including my changes in an Azure DevOps pipeline, but unfortunately it did not work.
I then found that new condition in the code from my PR was added too late in the function; a preceding condition terminates the function/returns before hitting my code (see code comment).

I have done some better testing now, and moved my Azure DevOps check higher up, right before the condition that terminated the function. With this change I have verified that it works in Azure DevOps.
Sorry for not testing better in the first PR, I assumed that my check would work close to the other CI Platform checks.

I hope you can accept this update, hopefully followed up by a new release of chalk.

And BTW: Related to the ESM only vs. hybrid package strategy topic from my previous PR: I actually salute you for your ESM only strategy to force the node ecosystem towards ESM. Your strategy worked on me, I spent close to one week updating my company's 30+ internal npm packages to ESM only packages, and found a temporary solution to Jest unit tests while waiting for better built-in ESM support.

if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
return 1;
}

if (haveStream && !streamIsTTY && forceColor === undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition evalutes to true in Azure DevOps, I therefore needed to move my check higher up.

@josundt
Copy link
Contributor Author

josundt commented Dec 7, 2021

Any chance for this be approved/merged/released?

@sindresorhus
Copy link
Member

Are you sure that Azure DevOps pipelines does not run in TTY? It could be that it's your script, not Azure that is not TTY.

@josundt
Copy link
Contributor Author

josundt commented Dec 9, 2021

@sindresorhus I actually made a copy of the supports-color script and added a console.log statement right before each of the return statements. Then I ran the script it in an Azure DevOps pipeline to see in the build logs from which condition the function returned.

It turned out that the condition...

(haveStream && !streamIsTTY && forceColor === undefined)

...was true. That's why I needed to move the check before this one.

In Azure DevOps (and probably other Hosted CI platforms), the capabilities of the terminal in which the build scripts are being executed is maybe not as important as the capabilities to convert the special color character sequences from the build logs into the the format expected by the UI that displays the logs. Users never witnesses the actual terminal output, just the logs (or "head" of logs while the build is running).

The Azure DevOps Web UI is capable of correctly displaying the build logs with colors in HTML/CSS.

@korostelevm
Copy link

This whole exclusion logic seems very flaky, especially if sequence matters.

This should probably be a long the lines of >

if ('CI' in env) {

The best solution would be to add a check for force color/ disable color environment variable in the same way the flag is implemented. This way you can just set it in your ci as needed

@Qix-
Copy link
Member

Qix- commented Jan 15, 2022

Alternatively, open an issue with Microsoft and ask them to implement a proper terminal for their CI pipelines.

Copy link

@Goyo1269 Goyo1269 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No me es util

@sindresorhus sindresorhus merged commit 848b80e into chalk:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants