Skip to content

create draft release (triggered by master branch update) #1585

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

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# What's Changed

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

categories:
- title: 'Breaking'
label: 'breaking-change'
- title: 'New'
label: 'enhancement'
- title: 'Bug Fixes'
label: 'bug'
- title: 'Maintenance'
labels:
- 'maintenance'
- 'chore'
- title: 'Documentation'
label: 'documentation'
- title: 'Other changes'
- title: 'Dependency Updates'
label: 'dependencies'
collapse-after: 5

version-resolver:
major:
labels:
- 'breaking-change'
minor:
labels:
- 'enhancement'
patch:
labels:
- 'bug'
- 'chore'
- 'maintenance'
- 'documentation'
- 'dependencies'
- 'security'
default: patch

exclude-labels:
- 'skip-changelog'
17 changes: 17 additions & 0 deletions .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
prerelease: true
prerelease-identifier: beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions Documentation/GlobalTool.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Options:
--use-source-link Specifies whether to use SourceLink URIs in place of file system paths.
--does-not-return-attribute Attributes that mark methods that do not return.
--exclude-assemblies-without-sources Specifies behaviour of heuristic to ignore assemblies with missing source documents.
--use-mapping-file Specifies the path to a SourceRootsMappings file.
--version Show version information
-?, -h, --help Show help and usage information
```
Expand Down Expand Up @@ -237,6 +238,18 @@ You can also include coverage of the test assembly itself by specifying the `--i

Coverlet supports [SourceLink](https://github.com/dotnet/sourcelink) custom debug information contained in PDBs. When you specify the `--use-source-link` flag, Coverlet will generate results that contain the URL to the source files in your source control instead of local file paths.

## Path Mappings

Coverlet has the ability to map the paths contained inside the debug sources into a local path where the source is currently located using the option `--source-mapping-file`. This is useful if the source was built using a deterministic build which sets the path to `/_/` or if it was built on a different host where the source is located in a different path.

The value for `--source-mapping-file` should be a file with each line being in the format `|path to map to=path in debug symbol`. For example to map the local checkout of a project `C:\git\coverlet` to project that was built with `<Deterministic>true</Deterministic>` which sets the sources to `/_/*` the following line must be in the mapping file.

```
|C:\git\coverlet\=/_/
```

During coverage collection, Coverlet will translate any path that starts with `/_/` to `C:\git\coverlet\` allowing the collector to find the source file.

## Exit Codes

Coverlet outputs specific exit codes to better support build automation systems for determining the kind of failure so the appropriate action can be taken.
Expand Down
69 changes: 37 additions & 32 deletions Documentation/ReleasePlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,45 @@ This is the steps to release new packages to nuget.org

Do a PR and merge to master.

2. Clone repo, **remember to build packages from master and not from your fork or metadata links will point to your forked repo.** . Run `git log -5` from repo root to verify last commit.

3. From new cloned, aligned and versions updated repo root run pack command

```shell
dotnet pack -c release /p:TF_BUILD=true /p:PublicRelease=true
...
coverlet.console -> D:\git\coverlet\src\coverlet.console\bin\Release\net6.0\coverlet.console.dll
coverlet.console -> D:\git\coverlet\src\coverlet.console\bin\Release\net6.0\publish\
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.nupkg'.
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.collector.6.0.1-preview.6.g918cd179e0.snupkg'.
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.nupkg'.
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.msbuild.6.0.1-preview.6.g918cd179e0.snupkg'.
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.nupkg'.
Successfully created package 'D:\git\coverlet\bin\Release\Packages\coverlet.console.6.0.1-preview.6.g918cd179e0.snupkg'.
```

4. Sign the packages using SignClient tool <https://www.nuget.org/packages/SignClient>

```powershell
❯ SignClient "Sign" `
>> --baseDirectory "REPO ROOT DIRECTORY\bin" `
>> --input "**/*.nupkg" `
>> --config "ROOT REPO DIRECTORY\eng\signclient.json" `
>> --user "USER" `
>> --secret "SECRET" `
>> --name "Coverlet" `
>> --description "Coverlet" `
>> --descriptionUrl "https://github.com/coverlet-coverage/coverlet"
```
1. Clone repo, **remember to build packages from master and not from your fork or metadata links will point to your forked repo.** . Run `git log -5` from repo root to verify last commit.

1. From new cloned, aligned and versions updated repo root run build command

```shell
dotnet pack -c release /p:TF_BUILD=true /p:PublicRelease=true
...
coverlet.core -> C:\GitHub\coverlet\artifacts\bin\coverlet.core\release_netstandard2.0\coverlet.core.dll
coverlet.core -> C:\GitHub\coverlet\artifacts\bin\coverlet.core\release_net6.0\coverlet.core.dll
coverlet.collector -> C:\GitHub\coverlet\artifacts\bin\coverlet.collector\release_netstandard2.0\coverlet.collector.dll
coverlet.collector -> C:\GitHub\coverlet\artifacts\bin\coverlet.collector\release_net6.0\coverlet.collector.dll
coverlet.msbuild.tasks -> C:\GitHub\coverlet\artifacts\bin\coverlet.msbuild.tasks\release_netstandard2.0\coverlet.msbuild.tasks.dll
coverlet.msbuild.tasks -> C:\GitHub\coverlet\artifacts\bin\coverlet.msbuild.tasks\release_net6.0\coverlet.msbuild.tasks.dll
coverlet.console -> C:\GitHub\coverlet\artifacts\bin\coverlet.console\release\coverlet.console.dll
coverlet.console -> C:\GitHub\coverlet\artifacts\bin\coverlet.console\release\coverlet.console.exe
...
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.6.0.1.nupkg'.
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.msbuild.6.0.1.snupkg'.
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.6.0.1.nupkg'.
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.collector.6.0.1.snupkg'.
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.6.0.1.nupkg'.
Successfully created package 'C:\GitHub\coverlet\artifacts\package\release\coverlet.console.6.0.1.snupkg'.
...
```

1. Sign nuget packages using sign <https://www.nuget.org/packages/sign>

```powershell
sign code azure-key-vault **/*.nupkg --base-directory [ROOT-DIRECTORY]\artifacts\package\release\ --file-digest sha256 --description Coverlet --description-url https://github.com/coverlet-coverage/coverlet `
--azure-key-vault-url [KEYVAULT-URL] `
--azure-key-vault-client-id [CLIENT-ID] `
--azure-key-vault-tenant-id [TENANT-ID] `
--azure-key-vault-client-secret [KEYVAULT-SECRET] `
--azure-key-vault-certificate [CERT-FRIENDLY-NAME]
```

5. Upload *.nupkg files to Nuget.org site. **Check all metadata(url links, deterministic build etc...) before "Submit"**
1. Upload *.nupkg files to Nuget.org site. **Check all metadata(url links, deterministic build etc...) before "Submit"**

6. **On your fork**:
1. **On your fork**:
* Align to master
* Bump version by one (fix part) and re-add `-preview.{height}`
* Create release on repo <https://github.com/coverlet-coverage/coverlet/releases>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Target Name="CopyCoverletDataCollectorFiles" AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<CoverletDataCollectorFiles Include="$(MSBuildThisFileDirectory)\*.*" />
<CoverletDataCollectorFiles Include="$(MSBuildThisFileDirectory)\**\*.*" />
<CoverletDataCollectorFiles Remove="@(ResolvedFileToPublish->'$(MSBuildThisFileDirectory)%(Filename)%(Extension)')" />
</ItemGroup>
<Copy SourceFiles="@(CoverletDataCollectorFiles)" DestinationFolder="$(PublishDir)%(RecursiveDir)" />

</Target>

<Target Name="SetXPlatDataCollectorPath" BeforeTargets="VSTest">
<PropertyGroup>
<VSTestTestAdapterPath>$(VSTestTestAdapterPath);$(MSBuildThisFileDirectory)</VSTestTestAdapterPath>
Expand Down
20 changes: 14 additions & 6 deletions src/coverlet.collector/coverlet.collector.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyTitle>coverlet.collector</AssemblyTitle>
<DevelopmentDependency>true</DevelopmentDependency>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Expand All @@ -14,7 +14,7 @@
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
<!-- Open issue https://github.com/NuGet/Home/issues/8941 -->
<NoWarn>$(NoWarn);NU5127</NoWarn>
<NoWarn>$(NoWarn);NU5127;NU5100</NoWarn>
<EnablePackageValidation>true</EnablePackageValidation>
<!-- disable transitive version update and use versions defined in coverlet.core -->
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
Expand Down Expand Up @@ -43,7 +43,6 @@
</ItemGroup>

<ItemGroup>
<None Update="build\**" Pack="true" PackagePath="" />
<None Include="$(MSBuildThisFileDirectory)..\..\_assets\coverlet-icon.png" Pack="true" PackagePath="\" />
<None Include="..\..\Documentation\VSTestIntegration.md" Link="VSTestIntegration.md" Pack="true" PackagePath="\">
<PackageCopyToOutput>true</PackageCopyToOutput>
Expand Down Expand Up @@ -81,11 +80,20 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)..\coverlet.core\coverlet.core.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="build\coverlet.collector.targets" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="PackBuildOutputs">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetDir)\*.dll" PackagePath="build\netstandard2.0\" />
<TfmSpecificPackageFile Include="$(TargetDir)\*.pdb" PackagePath="build\netstandard2.0\" />
<TfmSpecificPackageFile Include="$(TargetDir)\*.deps.json" PackagePath="build\netstandard2.0\" />
<TfmSpecificPackageFile Include="build\coverlet.collector.targets" PackagePath="build\$(TargetFramework)" />
<TfmSpecificPackageFile Include="$(TargetPath)" PackagePath="build\$(TargetFramework)" />
<TfmSpecificPackageFile Include="$(ProjectDepsFilePath)" PackagePath="build\$(TargetFramework)" />
<TfmSpecificPackageFile Include="@(DebugSymbolsProjectOutputGroupOutput)" PackagePath="build\$(TargetFramework)" />
<TfmSpecificPackageFile Include="%(_ResolvedProjectReferencePaths.Identity)" PackagePath="build\$(TargetFramework)" />
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths)" Exclude="@(_ResolvedProjectReferencePaths)" PackagePath="build\$(TargetFramework)\%(ReferenceCopyLocalPaths.DestinationSubPath)" />
</ItemGroup>
</Target>
</Project>
13 changes: 9 additions & 4 deletions src/coverlet.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static int Main(string[] args)
var useSourceLink = new Option<bool>("--use-source-link", "Specifies whether to use SourceLink URIs in place of file system paths.") { Arity = ArgumentArity.Zero };
var doesNotReturnAttributes = new Option<string[]>("--does-not-return-attribute", "Attributes that mark methods that do not return") { Arity = ArgumentArity.ZeroOrMore };
var excludeAssembliesWithoutSources = new Option<string>("--exclude-assemblies-without-sources", "Specifies behaviour of heuristic to ignore assemblies with missing source documents.") { Arity = ArgumentArity.ZeroOrOne };
var sourceMappingFile = new Option<string>("--source-mapping-file", "Specifies the path to a SourceRootsMappings file.") { Arity = ArgumentArity.ZeroOrOne };

RootCommand rootCommand = new()
{
Expand All @@ -71,7 +72,8 @@ static int Main(string[] args)
mergeWith,
useSourceLink,
doesNotReturnAttributes,
excludeAssembliesWithoutSources
excludeAssembliesWithoutSources,
sourceMappingFile
};

rootCommand.Description = "Cross platform .NET Core code coverage tool";
Expand Down Expand Up @@ -99,6 +101,7 @@ static int Main(string[] args)
bool useSourceLinkValue = context.ParseResult.GetValueForOption(useSourceLink);
string[] doesNotReturnAttributesValue = context.ParseResult.GetValueForOption(doesNotReturnAttributes);
string excludeAssembliesWithoutSourcesValue = context.ParseResult.GetValueForOption(excludeAssembliesWithoutSources);
string sourceMappingFileValue = context.ParseResult.GetValueForOption(sourceMappingFile);

if (string.IsNullOrEmpty(moduleOrAppDirectoryValue) || string.IsNullOrWhiteSpace(moduleOrAppDirectoryValue))
throw new ArgumentException("No test assembly or application directory specified.");
Expand All @@ -123,7 +126,8 @@ static int Main(string[] args)
mergeWithValue,
useSourceLinkValue,
doesNotReturnAttributesValue,
excludeAssembliesWithoutSourcesValue);
excludeAssembliesWithoutSourcesValue,
sourceMappingFileValue);
context.ExitCode = taskStatus;

});
Expand All @@ -149,7 +153,8 @@ private static Task<int> HandleCommand(string moduleOrAppDirectory,
string mergeWith,
bool useSourceLink,
string[] doesNotReturnAttributes,
string excludeAssembliesWithoutSources
string excludeAssembliesWithoutSources,
string sourceMappingFile
)
{

Expand All @@ -160,7 +165,7 @@ string excludeAssembliesWithoutSources
serviceCollection.AddTransient<ILogger, ConsoleLogger>();
// We need to keep singleton/static semantics
serviceCollection.AddSingleton<IInstrumentationHelper, InstrumentationHelper>();
serviceCollection.AddSingleton<ISourceRootTranslator, SourceRootTranslator>(provider => new SourceRootTranslator(provider.GetRequiredService<ILogger>(), provider.GetRequiredService<IFileSystem>()));
serviceCollection.AddSingleton<ISourceRootTranslator, SourceRootTranslator>(provider => new SourceRootTranslator(sourceMappingFile, provider.GetRequiredService<ILogger>(), provider.GetRequiredService<IFileSystem>()));
serviceCollection.AddSingleton<ICecilSymbolHelper, CecilSymbolHelper>();

ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
Expand Down
9 changes: 6 additions & 3 deletions src/coverlet.core/CoverageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Coverlet.Core.Enums;
using Coverlet.Core.Instrumentation;

Expand All @@ -22,11 +23,13 @@ internal class Branches : List<BranchInfo> { }

internal class Method
{
internal Method()
[JsonConstructor]
public Method()
{
Lines = new Lines();
Branches = new Branches();
Lines = [];
Branches = [];
}

public Lines Lines;
public Branches Branches;
}
Expand Down
17 changes: 11 additions & 6 deletions src/coverlet.core/Helpers/SourceRootTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ internal class SourceRootTranslator : ISourceRootTranslator
private readonly IFileSystem _fileSystem;
private readonly Dictionary<string, List<SourceRootMapping>> _sourceRootMapping;
private readonly Dictionary<string, List<string>> _sourceToDeterministicPathMapping;
private readonly string _mappingFileName;
private Dictionary<string, string> _resolutionCacheFiles;

public SourceRootTranslator(ILogger logger, IFileSystem fileSystem)
Expand All @@ -32,6 +31,13 @@ public SourceRootTranslator(ILogger logger, IFileSystem fileSystem)
_sourceRootMapping = new Dictionary<string, List<SourceRootMapping>>();
}

public SourceRootTranslator(string sourceMappingFile, ILogger logger, IFileSystem fileSystem)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
_sourceRootMapping = LoadSourceRootMapping(sourceMappingFile);
}

public SourceRootTranslator(string moduleTestPath, ILogger logger, IFileSystem fileSystem, IAssemblyAdapter assemblyAdapter)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
Expand All @@ -46,11 +52,11 @@ public SourceRootTranslator(string moduleTestPath, ILogger logger, IFileSystem f
}

string assemblyName = assemblyAdapter.GetAssemblyName(moduleTestPath);
_mappingFileName = $"CoverletSourceRootsMapping_{assemblyName}";
string mappingFileName = $"CoverletSourceRootsMapping_{assemblyName}";

_logger.LogInformation($"_mapping file name: '{_mappingFileName}'", true);
_logger.LogInformation($"_mapping file name: '{mappingFileName}'", true);

_sourceRootMapping = LoadSourceRootMapping(Path.GetDirectoryName(moduleTestPath));
_sourceRootMapping = LoadSourceRootMapping(Path.Combine(Path.GetDirectoryName(moduleTestPath), mappingFileName));
_sourceToDeterministicPathMapping = LoadSourceToDeterministicPathMapping(_sourceRootMapping);
}

Expand All @@ -77,11 +83,10 @@ private static Dictionary<string, List<string>> LoadSourceToDeterministicPathMap
return sourceToDeterministicPathMapping;
}

private Dictionary<string, List<SourceRootMapping>> LoadSourceRootMapping(string directory)
private Dictionary<string, List<SourceRootMapping>> LoadSourceRootMapping(string mappingFilePath)
{
var mapping = new Dictionary<string, List<SourceRootMapping>>();

string mappingFilePath = Path.Combine(directory, _mappingFileName);
if (!_fileSystem.Exists(mappingFilePath))
{
return mapping;
Expand Down
2 changes: 1 addition & 1 deletion src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</None>
</ItemGroup>

<Target Name="PackBuildOutputs" DependsOnTargets="ResolveProjectReferences;SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;ResolveAssemblyReferences">
<Target Name="PackBuildOutputs">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetPath)" PackagePath="tasks\$(TargetFramework)" />
<TfmSpecificPackageFile Include="$(ProjectDepsFilePath)" PackagePath="tasks\$(TargetFramework)" />
Expand Down
Loading