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
Azure Devops & Github Actions error logging #1996
Conversation
I will need to add some tests for this as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nicer if the option was more generic, azdo can do also warning and info (IIRC). Even if this PR would implement just the errors, having just a single option for enabling the azdo formatted output would be better.
We should also ensure that user can override this in config to be disabled even if the env variable is set. Or vice versa.
Changed this to be draft, because it is work in progress. |
64e1aaf
to
6aa4324
Compare
Thanks for the feedback. Agree fully about making option more generic. I've renamed it to For overriding the option to |
There is PS> $c = New-PesterConfiguration
PS> $c.CodeCoverage.Enabled.Value -eq $false
True
PS> $c.CodeCoverage.Enabled.IsOriginalValue()
True
PS> $c.CodeCoverage.Enabled = $false
PS> $c.CodeCoverage.Enabled.IsOriginalValue()
False I look at this during the merging, so this is probably automatic, I think the setting to pester preference happens before merging it to user provided config, and in that case user provided value will take precedence if they set it explicitly. |
Sounds complicated, give me some time to come up with some better name. @fflaten do you have any opinion? |
Ah that's perfect, Yeah I don't like Perhaps something like |
Do we need a ADO-specific option? Today it's Azure, tomorrow it's GitHub Actions (if we can use https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions from Pester), Travis CI etc. I'm not familiar with all the different CI/CD systems. Maybe some will require a different Output-plugin in the future, but if Github Actions is possible, I'd expect it to be built-in like ADO. 🙂 Would a enum like Output.CIFormat be better? Since it modifies the output while supporting only one value should be supported at a time (None being default). |
I'm happy to create a I'm also wondering what levels of output would we support? ADO supports the following: Write-Host "##[section] This is colored green!"
Write-Host "##[command] This is colored blue!"
Write-Host "##[debug] This is colored purple!"
Write-Host "##[warning] This is colored orange!"
Write-Host "##vso[task.logissue type=warning;]This is colored orange!"
Write-Host "##[error] This is colored red!"
Write-Host "##vso[task.logissue type=error;]This is colored red!" Which looks like this: For now it seems errors and warnings should definitely be supported. Should we support the other format types as well? Like Debug for instance.
Also agree on this. The error logs get flooded with what I've currently done and limiting just the first line makes it less noisy. GitHub Actions will need to do the same. We could also do TravisCI but I honestly have very little experience using it. |
Option name Coloring with just a single issue: Is original value, will probably by set after merging on the $PesterPreference, that we do few lines above. You need to move the code before |
Levels: I would support only error for now. |
Isn't this limiting? Color itself is better handled with ANSI as it's generic and supported in many CI-systems. The added benefit with this type of support is the integration with CI-summary/reports. |
AutodetectCI and specify what that means for each CI in the help? |
So this autodetect option would be set to |
If the merged configuration falsely reports IsOriginalValue=false for options even though it wasn't modified in neither Configuration nor callerPreference, then that sounds more like a bug in Merger imho. I haven't tested it, but I'd expect it to report correct status even after merging considering it only intends to change already user-modified settings. We include the merged one in the result-object so users should be able to detect modified/default options if they want.
Sounds like it might conflict with the Personally I like
|
6aa4324
to
c17260f
Compare
Thanks @fflaten, I added some commits to disable this for deliberate failing tests. If I have to test and/or add more more changes I will stash these commits and apply them later. The current build doesn't have any of these errors highlighted anymore. @nohwnd This is probably ready for review again. I've updated the PR description with the new changes. Let me know what you guys think 🙂 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 Added some thoughts.
Not sure if we decided on the option-name and values, but that's up to you two. Starting to see the benefit of only None vs Auto like @nohwnd mentioned , and just mention AzDO and GHA as currently supported in the option string/description.
I will have another look on this later this week. |
I made some changes to the GHA formatting, where the messages under the error header are collapsed into an expandable group. Screenshots are in the PR description. Also added CI formatting in |
The output looks great, and I am reasonably happy about the naming (can't come up with better one though). Only a small nit pick about the variables in tests, and then it's imho ready to merge. Will wait for the changes, and @fflaten approve. |
… are always set even after failure
Great work @ArmaanMcleod ! 🎉 I've been busy the last days, but I didn't have anything to add in a review. It's mostly the option-design/name I'm not sure about, but I think we've settled on this for now. Maybe we get some feedback from other users with the now released alpha. 👍 |
PR Summary
Fix #1364.
I've added functionality to highlight CI errors in red for ADO and GithubActions.
This is configured from the
Output.CIFormat
, which covers the following options:For AzureDevops, we check the
TF_BUILD
environment variable is equal toTrue
.For GithubActions, we check the
GITHUB_ACTIONS
environment variable is equal toTrue
.For AzureDevops we can use
##vso[task.logissue type=error]
to highlight the error header, and##[error]
to highlight the messages. This ensures only the error header is reported in the build log.For GithubActions, you can only set an error, so I had to limit this to just the header, as shown below. The messages are also collapsed under the header using expandable groups.
Azure Devops Output
Build Log
Github Actions
Build Log
I did testing in my own repo by running a simple github action to test out this code: https://github.com/ArmaanMcleod/TestGithubActions/actions/runs/952195814
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.