Skip to content

Commit

Permalink
[POC] Add native tests (#201)
Browse files Browse the repository at this point in the history
* Add native tests

* Add nuke for windows

* Nuke publish linux profiler

* fix scripts and add ci

* fix file permissions

* Add nuke MacOS steps

* Add missing script for linux

* Fix Linux native lib name

* Add dotnet tool manifest

* Fix macos native profiler lib name

* update nuke schema

* Update docs about build

* Update docs

* fix gitignore

* refactor targets

* remove overleft sln

* Remove GitLab helpers

* Cleanup unused methods

* Move developer notes to docs

* remove incorrect duplicated directory

* fix scripts and gitignore

* Update vcxproj tools version

* fix example doc for LazyPathExecutableAttribute

* Cleanup & formatting

* fix log path script
  • Loading branch information
RassK authored Jul 20, 2021
1 parent f5c13fb commit 6965788
Show file tree
Hide file tree
Showing 57 changed files with 2,931 additions and 111 deletions.
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 @@
# ------------------------------------------------------------------------------
# <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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,9 @@ src/Datadog.Trace.ClrProfiler.Native/build/

# ignore blog folder from upstream
blog/

# ignore nuke config
.nuke/*

# exception to the ignore rule
!/**/.gitkeep
Empty file added .nuke/.gitkeep
Empty file.
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
86 changes: 84 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 All @@ -18,14 +19,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
build.cmd = build.cmd
build.ps1 = build.ps1
build.sh = build.sh
build_poc.sh = build_poc.sh
Datadog.Trace.proj = Datadog.Trace.proj
Directory.Build.props = Directory.Build.props
GlobalSuppressions.cs = GlobalSuppressions.cs
integrations.json = integrations.json
LICENSE = LICENSE
LICENSE-3rdparty.csv = LICENSE-3rdparty.csv
OpenTelemetry.AutoInstrumentation.snk = OpenTelemetry.AutoInstrumentation.snk
poc.sh = poc.sh
docs\README.md = docs\README.md
stylecop.json = stylecop.json
EndProjectSection
Expand Down Expand Up @@ -57,9 +62,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 +239,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 +302,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
:; 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

0 comments on commit 6965788

Please sign in to comment.