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

[POC] Add native tests #201

Merged
merged 25 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 19 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
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"nuke.globaltool": {
"version": "5.2.1",
"commands": [
"nuke"
]
}
}
}
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ------------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to add a target with executes git diff --exit-code to ensure that someone has not forgotten to commit the autogenerated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great idea, I think it can be a task of it's own. Will add to todo.

# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_ci --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: ci

on:
push:
branches:
- main
- 'refs/tags/*'
paths:
- '!docs/*'
pull_request:
branches:
- '*'

jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
- name: Run './build.cmd Workflow'
run: ./build.cmd Workflow
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
env:
buildConfiguration: Release
shell: bash
run: ./build.sh
run: ./build_poc.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,6 @@ src/Datadog.Trace.ClrProfiler.Native/build/

# ignore blog folder from upstream
blog/

# ignore nuke config
.nuke/
7 changes: 7 additions & 0 deletions Datadog.Trace.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<CsharpProject Include="src\**\*.csproj" />
<CppProject Include="src\**\*.vcxproj"/>
<CppTestProject Include="test\**\*.vcxproj"/>
<SampleProject Include="test\test-applications\**\*.csproj" />
</ItemGroup>

Expand Down Expand Up @@ -52,6 +53,12 @@
</MSBuild>
</Target>

<Target Name="BuildCppTests">
<MSBuild Targets="Build" Projects="@(CppTestProject)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput"/>
</MSBuild>
</Target>

<Target Name="RestoreAndBuildSamplesForPackageVersions" Condition="'$(TestAllPackageVersions)'=='true'">

<!-- Build the core C# projects first, so that the sample project builds do not need to build them and can be run
Expand Down
82 changes: 80 additions & 2 deletions Datadog.Trace.sln
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
Expand Down Expand Up @@ -57,9 +58,32 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTracingLibrary", "sampl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.Core", "src\OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.Core\OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.Core.csproj", "{8BA1CCCC-B07C-46DD-9D54-0B98B3001100}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BindingRedirect", "samples\BindingRedirect\BindingRedirect.csproj", "{94089CFF-FD2A-45EF-A496-874569882E81}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BindingRedirect", "samples\BindingRedirect\BindingRedirect.csproj", "{94089CFF-FD2A-45EF-A496-874569882E81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OldReference", "samples\OldReference\OldReference.csproj", "{4C10E5C1-E212-4744-B92E-49A3AFC314FC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OldReference", "samples\OldReference\OldReference.csproj", "{4C10E5C1-E212-4744-B92E-49A3AFC314FC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{67941CB3-DC46-4E26-B7BF-8B27A298A2E8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Datadog.Trace.ClrProfiler.Native.Tests", "test\Datadog.Trace.ClrProfiler.Native.Tests\Datadog.Trace.ClrProfiler.Native.Tests.vcxproj", "{5728056A-51AA-4FF5-AD0C-E86E44E36102}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test-applications", "test-applications", "{7A9D19CA-E5FF-4FB1-A89A-B1C92BEC8982}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrations", "integrations", "{A96E5223-FECF-4FEB-BB8E-B529D0D8B293}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependency-libs", "dependency-libs", "{82A3CE96-0935-45E5-A9AA-A93A5B63500B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ExampleLibrary", "test\test-applications\integrations\dependency-libs\Samples.ExampleLibrary\Samples.ExampleLibrary.csproj", "{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ExampleLibraryTracer", "test\test-applications\integrations\dependency-libs\Samples.ExampleLibraryTracer\Samples.ExampleLibraryTracer.csproj", "{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{36004B32-55EB-4591-B6D2-B99DE373D0B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\nuke\_build.csproj", "{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "artifacts", "artifacts", "{7A95C636-A6E9-4156-B18E-28C1BE065A1A}"
ProjectSection(SolutionItems) = preProject
build\artifacts\createLogPath.sh = build\artifacts\createLogPath.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -211,6 +235,52 @@ Global
{4C10E5C1-E212-4744-B92E-49A3AFC314FC}.Release|x64.Build.0 = Release|Any CPU
{4C10E5C1-E212-4744-B92E-49A3AFC314FC}.Release|x86.ActiveCfg = Release|Any CPU
{4C10E5C1-E212-4744-B92E-49A3AFC314FC}.Release|x86.Build.0 = Release|Any CPU
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|Any CPU.ActiveCfg = Debug|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x64.ActiveCfg = Debug|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x64.Build.0 = Debug|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x86.ActiveCfg = Debug|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Debug|x86.Build.0 = Debug|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|Any CPU.ActiveCfg = Release|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x64.ActiveCfg = Release|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x64.Build.0 = Release|x64
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x86.ActiveCfg = Release|Win32
{5728056A-51AA-4FF5-AD0C-E86E44E36102}.Release|x86.Build.0 = Release|Win32
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|x64.Build.0 = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Debug|x86.Build.0 = Debug|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|Any CPU.Build.0 = Release|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|x64.ActiveCfg = Release|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|x64.Build.0 = Release|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|x86.ActiveCfg = Release|Any CPU
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0}.Release|x86.Build.0 = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|x64.ActiveCfg = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|x64.Build.0 = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|x86.ActiveCfg = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Debug|x86.Build.0 = Debug|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|Any CPU.Build.0 = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|x64.ActiveCfg = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|x64.Build.0 = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|x86.ActiveCfg = Release|Any CPU
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24}.Release|x86.Build.0 = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|x64.ActiveCfg = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|x64.Build.0 = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|x86.ActiveCfg = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Debug|x86.Build.0 = Debug|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|Any CPU.Build.0 = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|x64.ActiveCfg = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|x64.Build.0 = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|x86.ActiveCfg = Release|Any CPU
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -228,6 +298,14 @@ Global
{8BA1CCCC-B07C-46DD-9D54-0B98B3001100} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{94089CFF-FD2A-45EF-A496-874569882E81} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{4C10E5C1-E212-4744-B92E-49A3AFC314FC} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{5728056A-51AA-4FF5-AD0C-E86E44E36102} = {67941CB3-DC46-4E26-B7BF-8B27A298A2E8}
{7A9D19CA-E5FF-4FB1-A89A-B1C92BEC8982} = {67941CB3-DC46-4E26-B7BF-8B27A298A2E8}
{A96E5223-FECF-4FEB-BB8E-B529D0D8B293} = {7A9D19CA-E5FF-4FB1-A89A-B1C92BEC8982}
{82A3CE96-0935-45E5-A9AA-A93A5B63500B} = {A96E5223-FECF-4FEB-BB8E-B529D0D8B293}
{EFAE6960-9425-462E-BFFB-4C9A038DD8C0} = {82A3CE96-0935-45E5-A9AA-A93A5B63500B}
{6615B3D8-87C7-40D4-A7EA-19A7BFC7FD24} = {82A3CE96-0935-45E5-A9AA-A93A5B63500B}
{4DDEEB10-A6B5-4A46-96C1-1B7276B61E08} = {36004B32-55EB-4591-B6D2-B99DE373D0B8}
{7A95C636-A6E9-4156-B18E-28C1BE065A1A} = {36004B32-55EB-4591-B6D2-B99DE373D0B8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
7 changes: 7 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:; set -eo pipefail
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines seem like a left-over.

Copy link
Member

Choose a reason for hiding this comment

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

It is some kind of hack to make .cmd work on Linux and MacOS. I do not know how it works... But I think it does 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Magic 😮 - I needed to chmod it to try it.

Copy link
Contributor

Choose a reason for hiding this comment

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

On MacOS it also builds a bunch of files that are not ignored. @RassK could check if the .gitignore needs some updates?

:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
:; ${SCRIPT_DIR}/build.sh "$@"
:; exit $?

@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
69 changes: 69 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)

Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"

Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

###########################################################################
# CONFIGURATION
###########################################################################

$BuildProjectFile = "$PSScriptRoot\build\nuke\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.nuke\temp"

$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "Current"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0

###########################################################################
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}

# If dotnet CLI is installed globally and it matches requested version, use for execution
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)

# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}

# Install by channel or version
$DotNetDirectory = "$TempDirectory\dotnet-win"
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
Loading