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

Enable defining test options #2525

Closed
wants to merge 1 commit into from
Closed

Conversation

chcosta
Copy link
Member

@chcosta chcosta commented Apr 15, 2019

Validation job is here

To use this feature, a repo would change their azure-pipelines.yml file from using the Boolean enablePublishTestResults parameter...

jobs:
- template: /eng/common/templates/job/job.yml
  parameters:
    enablePublishTestResults: true

to specifying the publishTestResults object parameter...

jobs:
- template: /eng/common/templates/job/job.yml
  parameters:
    publishTestResults:
      testRunTitle: My test results

@dsplaisted

@chcosta
Copy link
Member Author

chcosta commented Apr 16, 2019

@alexperovich PTAL

@alexperovich
Copy link
Member

Why are we adding parameters to the template that is literally the parameters to the publish test results task? This feels like something that just makes it harder to reason about what the build is doing. IMO repos should just add a publish test results step themselves, its no more code than this is.

@chcosta
Copy link
Member Author

chcosta commented Apr 16, 2019

The difference is

publishTestResults:
  testResultsTitle: SomeTitle

vs

- task: PublishTestResults@2 
      displayName: Publish Test Results 
      inputs: 
        testResultsFormat: 'xUnit' 
        testResultsFiles: '*.xml'  
        searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
        testResultsTitle: 'SomeTitle`

Your argument could be made for all templates.

@alexperovich
Copy link
Member

For me the second is easier to grok than the contents of job.yml. Its just a bunch of characters that add some defaults to the parameters, but I had to parse out all of those if statements before I actually knew what it was doing. I don't have a super strong opinion either way though.

@chcosta
Copy link
Member Author

chcosta commented Apr 16, 2019

That's fair. The only reason I think this has merit to be supported is because we build in a lot of expectations about paths throughout Arcade and keeping that defined within the templates means that we can change those without breaking every repo that decided to custom implement some usage of a task...

searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)

@alexperovich
Copy link
Member

Is there a way to make the defaults more "defaulty", something like a: ${{ parameters.a or 'defaultA' }}?

@tmat
Copy link
Member

tmat commented Apr 16, 2019

Thanks to @zsd4yr, we can use VSO variables now:
https://github.com/dotnet/arcade/blob/master/eng/common/tools.ps1#L521-L523

Maybe it's time to add Artifacts.TestResults?

@chcosta
Copy link
Member Author

chcosta commented Apr 16, 2019

That's an interesting idea... It'd be great to get all of the paths out of the templates...

@@ -38,8 +38,23 @@ parameters:
enablePublishBuildAssets: false

# Optional: Include PublishTestResults task
# Note: the publishTestResults parameter (below) can be used to provide more control over publishing test results.
# You should use either "enablePublishTestResults" or "publishTestResults", not both. If both are present and
# either parameter is set to "enable=false", then publishing test results will be disabled
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be true. It seems that if both are present and either is set to true then publishing will occur?

Copy link
Member Author

Choose a reason for hiding this comment

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

Um, technically you're correct, however... nope, that's all; you're right, the statement is not accurate.

@chcosta
Copy link
Member Author

chcosta commented Apr 16, 2019

We should probably wait until #2038 is complete before rewriting this stuff.

@dsplaisted , I like the idea of using the Azure DevOps variables, but that does mean that you would have to remove "enablePublishTestResults" from your yaml and explicitly add the corresponding "PublishBuildArtifacts" step. Does that sound reasonable? If it does, then you can make that change now and then use the variable once it is available.

@dsplaisted
Copy link
Member

If possible, what I think is best is for the defaults to do the thing that is usually best, and be able to override that when necessary. So ideally by default in arcade you would get test results with meaningful titles without doing anything extra.

I don't need an ideal solution now though, so if I can figure out how to add my own publish step that sets the title, I'll be happy.

@dsplaisted
Copy link
Member

@chcosta Here's a PR to core-sdk which:

  • Includes test results as part of build artifacts
  • Sets test run title and build artifact filename to correspond to leg it came from

To do this we have to turn of the default arcade Azure Pipeline tasks. I think ideally this should eventually be the default for arcade, possibly with some ability to customize for common scenarios.

@chcosta
Copy link
Member Author

chcosta commented Apr 19, 2019

I presume that this is the PR you're referring to @dsplaisted

@dsplaisted
Copy link
Member

@chcosta Oops, yes :-)

@dsplaisted
Copy link
Member

@chcosta Any update? The default arcade logic doesn't give us helpful names, so we have to do this specifically in each of our repos.

dotnet/sdk#3221 (comment)
dotnet/installer#1609

@chcosta
Copy link
Member Author

chcosta commented May 13, 2019

#2038 hasn't quite landed yet. I'm going to close this PR as I think this isn't the right fix given the direction Arcade is heading.

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