Skip to content

Introduce coverlet DevContainer #1744

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
49 changes: 49 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "coverlet .NET 9.0)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "9.0.203",
"additionalVersions": ["6.0.428", "8.0.408"]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// "portsAttributes": {
// "5001": {
// "protocol": "https"
// }
// }

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.vscode-dotnet-runtime",
"visualstudioexptteam.vscodeintellicode",
"GitHub.vscode-pull-request-github",
"ms-dotnettools.csharp",
"ms-dotnettools.dotnet-interactive-vscode",
"ms-dotnettools.csdevkit",
"ms-vscode.powershell",
"ms-azure-devops.azure-pipelines",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-german",
"streetsidesoftware.code-spell-checker-english",
"fernandoescolar.vscode-solution-explorer"]
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 1 addition & 1 deletion eng/azure-pipelines-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
- task: UseDotNet@2
inputs:
useGlobalJson: true
displayName: Install .NET Core SDK 8.0.113
displayName: Install .NET Core SDK 8.0.114

- task: NuGetAuthenticate@1
displayName: Authenticate with NuGet feeds
Expand Down
74 changes: 74 additions & 0 deletions eng/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Build Script for Coverlet
# ------------------------
# This script provides a complete build environment setup and cleanup for Coverlet development.
# It's designed to support fast branch switching by:
# - Cleaning all temporary build artifacts
# - Removing cached NuGet packages
# - Rebuilding all projects and tests
# - Generating new binlogs for debugging
#
# Key features:
# - Cleans TestResults, bin, obj folders for clean builds
# - Removes cached NuGet packages to prevent version conflicts
# - Builds and packs all Coverlet projects
# - Generates binlogs for build diagnostics
# - Supports CI builds with ContinuousIntegrationBuild=true
#
# Usage: ./scripts/build-all.sh
#
# Note: Run this script after switching branches to ensure a clean development environment

# Cleanup temp folders and files
echo "Please cleanup temp folder!"
dotnet build-server shutdown
rm -f coverage.cobertura.xml
rm -f coverage.json
rm -f coverage.net8.0.json
rm -f test/coverlet.integration.determisticbuild/*.binlog
rm -rf artifacts

# Clean nuget packages
rm -rf ~/.nuget/packages/coverlet.msbuild/V1.0.0
rm -rf ~/.nuget/packages/coverlet.collector/V1.0.0
find . -type d \( -name "TestResults" -o -name "bin" -o -name "obj" \) -exec rm -rf {} +
find ~/.nuget/packages -type d \( -name "coverlet.msbuild" -o -name "coverlet.collector" -o -name "coverlet.console" \) -name "8.0.0-preview*" -exec rm -rf {} +

# Build and pack projects
dotnet pack -c Debug src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj /p:ContinuousIntegrationBuild=true
dotnet pack -c Debug src/coverlet.collector/coverlet.collector.csproj /p:ContinuousIntegrationBuild=true
dotnet build -bl:build.binlog /p:ContinuousIntegrationBuild=true

# Create binlog for tests
dotnet build test/coverlet.collector.tests/coverlet.collector.tests.csproj -bl:build.collector.tests.binlog /p:ContinuousIntegrationBuild=true
dotnet build test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj -bl:build.core.coverage.tests.binlog /p:ContinuousIntegrationBuild=true
dotnet build test/coverlet.core.tests/coverlet.core.tests.csproj -bl:build.coverlet.core.tests.binlog /p:ContinuousIntegrationBuild=true

# Create nuget packages
dotnet pack -c Debug src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj /p:ContinuousIntegrationBuild=true
dotnet pack -c Debug src/coverlet.collector/coverlet.collector.csproj /p:ContinuousIntegrationBuild=true
dotnet pack -c Debug src/coverlet.console/coverlet.console.csproj /p:ContinuousIntegrationBuild=true
dotnet pack -c Debug src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj /p:ContinuousIntegrationBuild=true
dotnet pack src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj /p:ContinuousIntegrationBuild=true
dotnet pack src/coverlet.collector/coverlet.collector.csproj /p:ContinuousIntegrationBuild=true
dotnet pack src/coverlet.console/coverlet.console.csproj /p:ContinuousIntegrationBuild=true
dotnet pack src/coverlet.msbuild.tasks/coverlet.msbuild.tasks.csproj /p:ContinuousIntegrationBuild=true

dotnet build-server shutdown

# Commented out sections converted to shell script comments
: <<'END_COMMENT'

dotnet test test/coverlet.collector.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" --results-directory:"./artifacts/Reports" -c debug --no-build -bl:test.collector.binlog --diag:"artifacts/log/debug/coverlet.collector.test.diag.log;tracelevel=verbose"
dotnet test test/coverlet.core.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" -c debug --no-build -bl:test.core.binlog
dotnet test test/coverlet.core.coverage.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" -c debug --no-build -bl:test.core.coverage.binlog
dotnet test test/coverlet.msbuild.tasks.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" -c debug --no-build -bl:test.msbuild.binlog
dotnet test test/coverlet.integration.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" -c debug --no-build -bl:test.integration.binlog

reportgenerator -reports:"**/*.opencover.xml" -targetdir:"artifacts/reports" -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura" -assemblyfilters:"-xunit;-coverlet.testsubject;-Coverlet.Tests.ProjectSample.*;-coverlet.core.tests.samples.netstandard;-coverlet.tests.utils;-coverlet.tests.xunit.extensions;-coverletsamplelib.integration.template;-testgen_*"

dotnet test test/coverlet.core.remote.tests/coverlet.core.remote.tests.csproj -c Debug /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --diag:"artifacts/log/debug/coverlet.core.remote.test.diag.log;tracelevel=verbose"

find . -name *.trx && find . -name *.opencover.xml
END_COMMENT
18 changes: 11 additions & 7 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@
#
# Note: Ensure that the .NET SDK is installed and available in the system PATH.

# Build configuration
BUILD_CONFIG="debug"

# Build the project
dotnet build -c debug -bl:build.binlog
dotnet pack -c debug
dotnet build -c $BUILD_CONFIG -bl:build.binlog
dotnet pack -c $BUILD_CONFIG
dotnet pack -c release
dotnet build-server shutdown

# Run tests with code coverage
dotnet test test/coverlet.core.tests/coverlet.core.tests.csproj -c debug --no-build -bl:test.core.binlog /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.projectsample]*" /p:ExcludeByAttribute="GeneratedCodeAttribute" -- --results-directory "artifacts/Reports" --report-xunit-trx --report-xunit-trx-filename "coverlet.core.tests.trx" --diagnostic --diagnostic-output-directory "artifacts/log/debug" --diagnostic-output-fileprefix "coverlet.core.tests"
dotnet test test/coverlet.collector.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" --results-directory:"./artifacts/reports" --diag:"artifacts/log/${BUILD_CONFIG}/coverlet.collector.test.log;tracelevel=verbose"
dotnet build-server shutdown
dotnet test test/coverlet.core.coverage.tests/coverlet.core.coverage.tests.csproj -c debug --no-build -bl:test.core.coverage.binlog /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.projectsample]*" /p:ExcludeByAttribute="GeneratedCodeAttribute" -- --results-directory "artifacts/Reports" --report-xunit-trx --report-xunit-trx-filename "coverlet.core.coverage.tests.trx" --diagnostic --diagnostic-output-directory "artifacts/log/debug" --diagnostic-output-fileprefix "coverlet.core.coverage.tests"
dotnet test test/coverlet.core.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" --results-directory:"./artifacts/reports" --verbosity detailed --diag ./artifacts/log/${BUILD_CONFIG}/coverlet.core.tests.log
dotnet build-server shutdown
dotnet test test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj -c debug --no-build -bl:test.msbuild.binlog /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.projectsample]*" /p:ExcludeByAttribute="GeneratedCodeAttribute" -- --results-directory:"artifacts/Reports" --report-xunit-trx --report-xunit-trx-filename "coverlet.msbuild.tasks.tests.trx" --diagnostic --diagnostic-output-directory "artifacts/log/debug" --diagnostic-output-fileprefix "coverlet.msbuild.tasks.tests"
dotnet test test/coverlet.core.coverage.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" -- --results-directory "$(pwd)/artifacts/reports" --report-xunit-trx --report-xunit-trx-filename --diagnostic-verbosity ${BUILD_CONFIG} --diagnostic --diagnostic-output-directory "$(pwd)/artifacts/log/${BUILD_CONFIG}"
dotnet build-server shutdown
dotnet test test/coverlet.collector.tests/coverlet.collector.tests.csproj -c debug --no-build -bl:test.collector.binlog /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.projectsample]*" /p:ExcludeByAttribute="GeneratedCodeAttribute" --diag:"artifacts/log/debug/coverlet.collector.test.diag.log;tracelevel=verbose"
dotnet test test/coverlet.msbuild.tasks.tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*" --results-directory:"./artifacts/reports" --verbosity detailed --diag ./artifacts/log/${BUILD_CONFIG}/coverlet.msbuild.tasks.tests.log
dotnet build-server shutdown
dotnet test test/coverlet.integration.tests/coverlet.integration.tests.csproj -c debug --no-build -bl:test.integration.binlog -- --results-directory "artifacts/Reports" --report-xunit-trx --report-xunit-trx-filename "coverlet.integration.tests.trx" --diagnostic --diagnostic-output-directory "artifacts/log/debug" --diagnostic-output-fileprefix "coverlet.integration.tests"
dotnet test test/coverlet.integration.tests -f net8.0 --results-directory:"./artifacts/reports" --verbosity detailed --diag ./artifacts/log/${BUILD_CONFIG}/coverlet.integration.tests.net8.log
dotnet test test/coverlet.integration.tests -f net9.0 --results-directory:"./artifacts/reports" --verbosity detailed --diag ./artifacts/log/${BUILD_CONFIG}/coverlet.integration.tests.net9.log
2 changes: 1 addition & 1 deletion eng/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ steps:
- task: UseDotNet@2
inputs:
useGlobalJson: true
displayName: Install .NET Core SDK 8.0.113
displayName: Install .NET Core SDK 8.0.114

# create artifact/package folder
- pwsh: |
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.407"
"version": "8.0.408"
}
}
6 changes: 6 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
<PropertyGroup>
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);NU1301;IDE0007;IDE0008</NoWarn>
<!-- MTP settings -->
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<!--
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
-->
</PropertyGroup>
</Project>
2 changes: 0 additions & 2 deletions test/coverlet.core.tests/coverlet.core.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CS8002</NoWarn>
Expand Down