-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add NuGet packages * Fix link to nuget.config * Apply dotnet-format fixes * Consistent emphasis-style on README.md * Update docs/README.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/README.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Update docs/internal/using-the-nuget-packages.md Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> * Reduce the default timeout for tests going to the web * Add instructions on how to setup bin/ci-artifacts * Fix doc formatting * PR review suggestion * Use same as style as PR 2287 --------- Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> Co-authored-by: Rajkumar Rangaraj <[email protected]>
- Loading branch information
1 parent
161574c
commit 888e2cd
Showing
37 changed files
with
1,121 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,44 +129,71 @@ jobs: | |
if: (${{ job.status }} != 'cancelled') | ||
continue-on-error: true | ||
|
||
pack: | ||
needs: build | ||
build-nuget-packages: | ||
needs: [ build, build-container ] | ||
|
||
runs-on: ubuntu-20.04 | ||
runs-on: windows-2022 | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: nuget/[email protected] | ||
|
||
- name: Download Windows Artifacts from build job | ||
uses: actions/[email protected] | ||
with: | ||
name: bin-windows-2022 | ||
path: nuget/bin-windows | ||
path: bin/ci-artifacts/bin-windows-2022 | ||
|
||
- name: Download CentOS Artifacts from build job | ||
uses: actions/[email protected] | ||
with: | ||
name: bin-centos | ||
path: nuget/bin-linux-glibc | ||
path: bin/ci-artifacts/bin-centos | ||
|
||
- name: Download Alpine Artifacts from build job | ||
uses: actions/[email protected] | ||
with: | ||
name: bin-alpine | ||
path: nuget/bin-linux-musl | ||
path: bin/ci-artifacts/bin-alpine | ||
|
||
- name: Download Mac-OS Artifacts from build job | ||
uses: actions/[email protected] | ||
with: | ||
name: bin-macos-11 | ||
path: nuget/bin-macos | ||
path: bin/ci-artifacts/bin-macos-11 | ||
|
||
- name: Build NuGet Runtime Packages | ||
run: ./build.cmd BuildNuGetPackages | ||
|
||
- name: Build NuGet package | ||
run: nuget pack OpenTelemetry.AutoInstrumentation.nuspec -Properties NoWarn=NU5100,NU5123,NU5128 | ||
working-directory: nuget | ||
- name: Test NuGet Packages | ||
run: ./build.cmd TestNuGetPackages | ||
|
||
- name: Upload Nuget | ||
- name: Upload Nuget Artifacts | ||
uses: actions/[email protected] | ||
with: | ||
name: OpenTelemetry.AutoInstrumentation.Nuget | ||
path: nuget/*.nupkg | ||
name: OpenTelemetry.AutoInstrumentation.NuGet.Packages | ||
path: bin/nuget-artifacts/ | ||
|
||
test-nuget-packages: | ||
needs: build-nuget-packages | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- machine: ubuntu-20.04 | ||
- machine: macos-11 | ||
runs-on: ${{ matrix.machine }} | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/[email protected] | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
7.0.x | ||
- name: Download NuGet Artifacts from build-nuget-packages job | ||
uses: actions/[email protected] | ||
with: | ||
name: OpenTelemetry.AutoInstrumentation.NuGet.Packages | ||
path: bin/nuget-artifacts/ | ||
|
||
- name: Test NuGet Packages | ||
run: ./build.cmd TestNuGetPackages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
using System.Runtime.InteropServices; | ||
using Extensions; | ||
using Nuke.Common; | ||
using Nuke.Common.IO; | ||
using Nuke.Common.Tools.DotNet; | ||
using Nuke.Common.Tools.NuGet; | ||
using static Nuke.Common.IO.FileSystemTasks; | ||
using static Nuke.Common.Tools.DotNet.DotNetTasks; | ||
|
||
partial class Build | ||
{ | ||
AbsolutePath NuGetArtifactsDirectory => NuGetArtifacts ?? (OutputDirectory / "nuget-artifacts"); | ||
|
||
Target BuildNuGetPackages => _ => _ | ||
.Description( | ||
"Builds the NuGet packages of the project assuming that any necessary build artifacts were already downloaded.") | ||
.DependsOn(BuildManagedSrcNuGetPackages) | ||
.DependsOn(CopyIntegrationsJsonForNuGetPackage) | ||
.DependsOn(SetupRuntimeNativeFolderForNuGetPackage) | ||
.DependsOn(BuildNuSpecNuGetPackages); | ||
|
||
Target TestNuGetPackages => _ => _ | ||
.Description( | ||
"Test the NuGet packages of the project assuming that the packages are available at bin/nuget-artifacts.") | ||
.DependsOn(BuildNuGetPackagesTests) | ||
.DependsOn(BuildNuGetPackagesTestApplications) | ||
.DependsOn(RunNuGetPackagesTests); | ||
|
||
Target BuildManagedSrcNuGetPackages => _ => _ | ||
.Description("Build the NuGet packages that are generated directly from src/**/*.csproj files") | ||
.Executes(() => | ||
{ | ||
foreach (var project in Solution.GetManagedSrcProjects().Where(p => !p.Name.EndsWith("AdditionalDeps"))) | ||
{ | ||
DotNetPack(x => x | ||
.SetProject(project) | ||
.SetConfiguration(BuildConfiguration) | ||
.SetVersionSuffix(NuGetVersionSuffix) | ||
.SetOutputDirectory(NuGetArtifactsDirectory)); | ||
} | ||
}); | ||
|
||
Target CopyIntegrationsJsonForNuGetPackage => _ => _ | ||
.Unlisted() | ||
.Executes(() => | ||
{ | ||
var source = RootDirectory / "integrations.json"; | ||
var dest = RootDirectory / "nuget" / "OpenTelemetry.AutoInstrumentation" / | ||
"contentFiles" / "any" / "any"; | ||
CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite); | ||
}); | ||
|
||
Target SetupRuntimeNativeFolderForNuGetPackage => _ => _ | ||
.Unlisted() | ||
.Description("Setup the \"runtimes/{platform}-{architecture}/native\" folders under \"nuget/OpenTelemetry.AutoInstrumentation.Runtime.Native\".") | ||
.Executes(() => | ||
{ | ||
const string ciArtifactsDirectory = "bin/ci-artifacts"; | ||
const string baseRuntimeNativePath = "./nuget/OpenTelemetry.AutoInstrumentation.Runtime.Native/"; | ||
var requiredArtifacts = new string[] | ||
{ | ||
"bin-alpine/linux-musl-x64", | ||
"bin-centos/linux-x64", | ||
"bin-macos-11/osx-x64", | ||
"bin-windows-2022/win-x64", | ||
"bin-windows-2022/win-x86" | ||
}; | ||
foreach (var artifactFolder in requiredArtifacts) | ||
{ | ||
var sourcePath = Path.Combine(ciArtifactsDirectory, artifactFolder); | ||
var platformAndArchitecture = Path.GetFileName(artifactFolder); | ||
var destinationPath = | ||
Path.Combine(baseRuntimeNativePath, "runtimes", platformAndArchitecture, "native"); | ||
DeleteDirectory(destinationPath); | ||
CopyDirectoryRecursively(sourcePath, destinationPath); | ||
} | ||
}); | ||
|
||
Target BuildNuSpecNuGetPackages => _ => _ | ||
.Description("Build the NuGet packages specified by nuget/**/*.nuspec projects.") | ||
.After(CopyIntegrationsJsonForNuGetPackage) | ||
.After(SetupRuntimeNativeFolderForNuGetPackage) | ||
.Executes(() => | ||
{ | ||
// .nuspec files don't support .props or another way to share properties. | ||
// To avoid repeating these values on all .nuspec files they are going to | ||
// be passed as properties. | ||
// Keeping common values here and using them as properties | ||
var nuspecCommonProperties = new Dictionary<string, object> | ||
{ | ||
{ "NoWarn", "NU5128" }, | ||
{ "NuGetLicense", "Apache-2.0" }, | ||
{ "NuGetPackageVersion", $"{NuGetBaseVersionNumber}{NuGetVersionSuffix}" }, | ||
{ "NuGetRequiredLicenseAcceptance", "true" }, | ||
{ "OpenTelemetryAuthors", "OpenTelemetry Authors" } | ||
}; | ||
var nuspecSolutionFolder = Solution.GetSolutionFolder("nuget") | ||
?? throw new InvalidOperationException("Couldn't find the expected \"nuget\" solution folder."); | ||
var nuspecProjects = nuspecSolutionFolder.Items.Keys.ToArray(); | ||
foreach (var nuspecProject in nuspecProjects) | ||
{ | ||
NuGetTasks.NuGetPack(s => s | ||
.SetTargetPath(nuspecProject) | ||
.SetConfiguration(BuildConfiguration) | ||
.SetProperties(nuspecCommonProperties) | ||
.SetOutputDirectory(NuGetArtifactsDirectory)); | ||
} | ||
}); | ||
|
||
Target BuildNuGetPackagesTests => _ => _ | ||
.Description("Builds the NuGetPackagesTests project") | ||
.Executes(() => | ||
{ | ||
var nugetPackagesTestProject = Solution.GetProject("NuGetPackagesTests"); | ||
DotNetBuild(s => s | ||
.SetProjectFile(nugetPackagesTestProject) | ||
.SetConfiguration(BuildConfiguration)); | ||
}); | ||
|
||
Target BuildNuGetPackagesTestApplications => _ => _ | ||
.Description("Builds the TestApplications.* used by the NuGetPackagesTests") | ||
.Executes(() => | ||
{ | ||
foreach (var packagesTestApplicationProject in Solution.GetNuGetPackagesTestApplications()) | ||
{ | ||
// Unlike the integration apps these require a restore step. | ||
DotNetBuild(s => s | ||
.SetProjectFile(packagesTestApplicationProject) | ||
.SetProperty("NuGetPackageVersion", $"{NuGetBaseVersionNumber}{NuGetVersionSuffix}") | ||
.SetRuntime(RuntimeInformation.RuntimeIdentifier) | ||
.SetConfiguration(BuildConfiguration) | ||
.SetPlatform(Platform)); | ||
} | ||
}); | ||
|
||
Target RunNuGetPackagesTests => _ => _ | ||
.Description("Run the NuGetPackagesTests.") | ||
.After(BuildNuGetPackagesTests) | ||
.After(BuildNuGetPackagesTestApplications) | ||
.Executes(() => | ||
{ | ||
var nugetPackagesTestProject = Solution.GetProject("NuGetPackagesTests"); | ||
for (var i = 0; i < TestCount; i++) | ||
{ | ||
DotNetMSBuild(config => config | ||
.SetConfiguration(BuildConfiguration) | ||
.SetFilter(AndFilter(TestNameFilter(), ContainersFilter())) | ||
.SetBlameHangTimeout("5m") | ||
.EnableTrxLogOutput(GetResultsDirectory(nugetPackagesTestProject)) | ||
.SetTargetPath(nugetPackagesTestProject) | ||
.DisableRestore() | ||
.RunTests() | ||
); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.