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

Allow to set root directory for ExcludeAssembliesWithoutSources heuristic or other way to exclude internal nuget dependencies on shared CI nodes. #1668

Open
EraYaN opened this issue Jun 27, 2024 · 3 comments
Labels
question This issue is a question waiting for customer Waiting for customer action

Comments

@EraYaN
Copy link

EraYaN commented Jun 27, 2024

Currently we are running coverlet in self hosted CI runners and these runners cache other builds as well. This causes coverlet to go up the directory tree to find a bunch of old builds that match some of the assemblies. I'd like to be able to pass the current root so any file outside of that will just be ignored.

We currently run the tests like so:

- task: DotNetCoreCLI@2
  displayName: "Run Tests"
  condition: and(succeeded(), ${{ parameters.runTests }})
  env: ${{ parameters.testEnv }}
  inputs:
    command: "test"
    projects: ${{ parameters.testProjects }}
    arguments: '--configuration Release --collect:"XPlat Code Coverage" --settings "${{ parameters.testSettingsFile }}" --verbosity minimal'
    publishTestResults: true
    testRunTitle: $(Agent.JobName)
    workingDirectory: "$(Build.SourcesDirectory)"

with runsettings liek this:

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>cobertura</Format>
          <Exclude>[coverlet.*.Testss?]*,[*]Coverlet.Core*,[*]Moq*</Exclude> <!-- [Assembly-Filter]Type-Filter -->
          <ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
          <SingleHit>false</SingleHit>
          <UseSourceLink>false</UseSourceLink>
          <IncludeTestAssembly>false</IncludeTestAssembly>
          <ExcludeAssembliesWithoutSources>MissingAny</ExcludeAssembliesWithoutSources>
          <InstrumentModulesWithoutLocalSources>false</InstrumentModulesWithoutLocalSources>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

I'd like to inject the $(Build.SourcesDirectory) as a root so everything outside that is recognized as a "Third-Party" assembly. Alternatively, it'd be sweet if this worked by reading the csproj files and excluding all <packagereference> items.

Or maybe parse a .deps.json file and exclude everything that has .libraries[].type=='package'.

The main issue is that we have some very large projects that are dependencies and are tested separately and the report generation for the thousands of types takes forever.

EDIT: I potentially overlooked IncludeDirectories/IncludeDirectory, oops, I'll try running a quick test suite.
UPDATE: -p:IncludeDirectory="$(Build.SourcesDirectory)" does not seem to work to filter out anything outside of this directory.

@github-actions github-actions bot added the untriaged To be investigated label Jun 27, 2024
@Bertk
Copy link
Collaborator

Bertk commented Jul 27, 2024

Please see (answer) #1498

@EraYaN
Copy link
Author

EraYaN commented Aug 2, 2024

That does not seem to properly exclude the files. I was not including those projects in the first place, they live somewhere on the accesible filesystem tree near the root, far from the actual source and working directory. It just so happens that Nuget packages that are installed have those exact paths in their metadata and so coverlet goes and tries to find them, making the heuristics for exclusion fail. Include directory does not seem to work as a negative (exclude everything outside of these directories) when it is specified.

@Bertk
Copy link
Collaborator

Bertk commented Aug 3, 2024

Microsoft introduced simplified output paths with .NET 8.0. coverlet uses this feature already.
This feature might be helpful for your scenario and I think using $(Build.SourcesDirectory) is not an appropriate solution.

Typically the project binaries are separated and coverlet will uses the DLLs within the output folder. Did you customized the build output folder by yourself?

@Bertk Bertk added question This issue is a question waiting for customer Waiting for customer action and removed untriaged To be investigated labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This issue is a question waiting for customer Waiting for customer action
Projects
None yet
Development

No branches or pull requests

2 participants