Skip to content

Add Cake as build system #46

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

Merged
merged 18 commits into from
Nov 27, 2018
Merged
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
68 changes: 32 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
version: 2
jobs:
build:
build-and-test:
docker:
- image: aparker/circleci-dotnet-mono:latest
steps:
- checkout
- run: msbuild /t:Restore
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
test:
docker:
- image: aparker/circleci-dotnet-mono:latest
steps:
- checkout
- run: msbuild /t:Restore
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
- run: msbuild test/LightStep.Tests/LightStep.Tests.csproj /t:Build
- run: msbuild test/LightStep.Tests/LightStep.Tests.csproj /t:Test
pack:
docker:
- image: aparker/circleci-dotnet-mono:latest
steps:
- checkout
- run: msbuild /t:Restore
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
- run: sn -R src/LightStep/bin/Debug/net45/LightStep.dll src/LightStep/tracerSign.snk && sn -vf src/LightStep/bin/Debug/net45/LightStep.dll
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Pack /p:PackageOutputPath="/pkg"
- store_artifacts:
path: /pkg
- run: dotnet tool install -g dotnet-xunit-to-junit
- run: dotnet tool install -g Cake.Tool
- run: export PATH="$PATH:/root/.dotnet/tools"
- run:
name: Update PATH and Define Environment Variable at Runtime
command: |
echo 'export PATH="$PATH:/root/.dotnet/tools"' >> $BASH_ENV
source $BASH_ENV
- run: dotnet cake build.cake -t=Test
- run: dotnet xunit-to-junit ./build/test_results.xml ./build/LightStep.Tests.dll.junit.xml
- store_test_results:
path: build/LightStep.Tests.dll.junit.xml

publish:
docker:
- image: aparker/circleci-dotnet-mono:latest
steps:
- checkout
- run: msbuild /t:Restore
- run: msbuild /t:Build
- run: msbuild src/LightStep/LightStep.csproj /t:Pack
- run: dotnet nuget push src/LightStep/bin/Debug/*.nupkg -k $NuGet
- run: dotnet tool install -g dotnet-xunit-to-junit
- run: dotnet tool install -g Cake.Tool
- run:
name: Update PATH and Define Environment Variable at Runtime
command: |
echo 'export PATH="$PATH:/root/.dotnet/tools"' >> $BASH_ENV
source $BASH_ENV
- run: dotnet cake build.cake -t=Publish
- run: dotnet xunit-to-junit ./build/test_results.xml ./build/LightStep.Tests.dll.junit.xml
- store_test_results:
path: build/LightStep.Tests.dll.junit.xml

workflows:
version: 2
build-test-and-pack:
untagged-build:
jobs:
- build-and-test
tagged-build:
jobs:
- build
- test:
requires:
- build
- pack:
requires:
- test
- publish:
filters:
branches:
only: master
ignore: /.*/
tags:
only: /^v.*/
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,14 @@ ASALocalRun/
*.nvuser

# MFractors (Xamarin productivity tool) working folder
.mfractor/
.mfractor/

# cakebuild tools
tools/

dist/
build/

# this is generated at build, ignoring it here
src/LightStep/Properties/AssemblyInfo.cs

32 changes: 17 additions & 15 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
"type": "cake",
"script": "Default",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "cake",
"script": "Test",
"problemMatcher": [],
"group": "test"
},
{
"type": "cake",
"script": "Clean",
"problemMatcher": []
}
]
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

_vNext_
- We now build using [Cake](https://cakebuild.net).
- All value types are now properly handled in span serialization.
- The platform version detection code has been improved and should be resilient to dynamic injection scenarios.
- Logging now exists for many operations via the LibLog library. See the README for more details.
Expand Down
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Contributing Guide

First, thanks for your contribution! 🎉

We gladly accept issues and pull requests to this repository. If this is a security-related issue, please email us directly at [email protected].

Please note the following general guidelines and advice -

## Issues
When submitting an issue, please include the following in addition to an explanation of the issue:
- Version of the library you're using.
- The runtime and platform version you're using (e.g., .NET 4.6.1 or .NET Core 2.1).
- Any stack trace or diagnostic logs you may have that demonstrate the issue.

## Pull Requests
Before making a pull request for a feature, please open an issue in order to gain consensus on the work you're doing.

All pull requests should be rebased against `master`, and all tests should pass before a PR will be merged.

In addition, ensure that:
- Test coverage has been added, where appropriate.
- The CHANGELOG and README have been updated.
- If you are making a breaking change, indicate it in the CHANGELOG.

## Releases
To make a release, commit a tag to master of the format `vmajor.minor.patch` or `vmajor.minor.patch-alpha/beta`. CircleCI should automatically build and publish the resulting artifact.

## Developing

This library is intended for cross-platform usage, as well as cross-platform development. Please ensure that any dependencies added or changed fully support cross-platform .NET via Mono and .NET Core.

_Development Dependencies_
- .NET Framework 4.5+ (On MacOS/Linux, you need Mono 5.16, stable channel). **If on MacOS, install Mono via its installer and not Homebrew**
- .NET Core 2.1+
- Cake (see _Local Builds_)
- PostSharp (Windows only, for `LightStep.CSharpAspectTestApp`)

_Local Builds_

We use [Cake](https://cakebuild.net/) as a build tool. Run `dotnet tool install -g Cake.Tool` to make Cake globally available, then run `dotnet cake build.cake` to run tests. This requires .NET Core 2.1+.

You should be able to use any C# development environment, such as [Visual Studio Code](https://code.visualstudio.com/) with the C# extension, [Visual Studio 2017](https://visualstudio.microsoft.com/), or [JetBrains Rider](https://www.jetbrains.com/rider/).
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@ The LightStep distributed tracing library for C#

[![NuGet](https://img.shields.io/nuget/v/LightStep.svg)](https://www.nuget.org/packages/LightStep) [![CircleCI](https://circleci.com/gh/lightstep/lightstep-tracer-csharp.svg?style=svg)](https://circleci.com/gh/lightstep/lightstep-tracer-csharp)

# Development Requirements
- C# 7
- .NET Core 2+
- .NET 4.5

This translates to requiring at least Visual Studio 2017 (15.0).
You may need [PostSharp](https://www.postsharp.net/) to work on the `LightStep.CSharpAspectTestApp`.

# Installation
Install the package via NuGet into your solution, or use `Install-Package LightStep`.
Install the package via NuGet into your solution, or use `Install-Package LightStep` / `dotnet add package LightStep`.

# Basic Usage
It's recommended to initialize the tracer once at the beginning of your application and assign it as the global tracer, as follows:
Expand Down
85 changes: 85 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#tool "xunit.runner.console"

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var debugConfiguration = Argument("configuration", "Debug");
var buildDir = Directory("./build");
var distDir = Directory("./dist");
var solution = "./LightStep.sln";
var library = "./src/LightStep/LightStep.csproj";
var lightStepAssemblyInfoFile = "./src/LightStep/Properties/AssemblyInfo.cs";
var version = EnvironmentVariable("CIRCLE_TAG") ?? "v0.0.0";
version = version.TrimStart('v');
var buildNo = String.IsNullOrWhiteSpace(EnvironmentVariable("CIRCLE_BUILD_NUM")) ? "local" : EnvironmentVariable("CIRCLE_BUILD_NUM");
var semVersion = string.Concat(version + "-" + buildNo);
var nuGetApiKey = EnvironmentVariable("NuGet");

Task("Clean")
.Does( ()=>
{
CleanDirectory(buildDir);
CleanDirectory(distDir);
CleanDirectories("./**/obj/*.*");
CleanDirectories($"./**/bin/{configuration}/*.*");
CleanDirectories($"./**/bin/{debugConfiguration}/*.*");
});

Task("Restore")
.IsDependentOn("Clean")
.Does( ()=>
{
DotNetCoreRestore(solution);
});

Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
CreateAssemblyInfo(lightStepAssemblyInfoFile, new AssemblyInfoSettings {
Product = "LightStep",
Version = version,
FileVersion = version,
InformationalVersion = semVersion,
Copyright = string.Format("Copyright (c) LightStep 2018 - {0}", DateTime.Now.Year)
});
var assemblyInfo = ParseAssemblyInfo(lightStepAssemblyInfoFile);
Information("Version: {0}", assemblyInfo.AssemblyVersion);
Information("File version: {0}", assemblyInfo.AssemblyFileVersion);
Information("Informational version: {0}", assemblyInfo.AssemblyInformationalVersion);
MSBuild(library, settings => settings
.SetConfiguration(configuration)
.WithTarget("Rebuild")
.WithProperty("Version", assemblyInfo.AssemblyInformationalVersion)
.SetVerbosity(Verbosity.Minimal));
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var projects = GetFiles("./test/**/*.csproj");

foreach(var project in projects)
{
DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings {
Logger = "xunit;LogFilePath=../../build/test_results.xml"
});
}

});

Task("Publish")
.IsDependentOn("Test")
.WithCriteria(() => EnvironmentVariable("CI") == "true")
.Does(() =>
{
var nupkg = GetFiles("./src/LightStep/bin/Release/*.nupkg").First();
DotNetCoreNuGetPush(nupkg.FullPath, new DotNetCoreNuGetPushSettings {
ApiKey = nuGetApiKey
});
});

Task("Default")
.IsDependentOn("Test");

RunTarget(target);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -31,6 +31,8 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("0.1.29.0")]
[assembly: AssemblyVersion("0.1.29.0")]
[assembly: AssemblyFileVersion("0.1.29.0")]

[assembly: AssemblyInformationalVersion("0.1.29-enhancement-addCake.1-2018-11-12")]
6 changes: 2 additions & 4 deletions src/LightStep/LightStep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@

<PropertyGroup>
<Authors>Austin Parker</Authors>
<PackageVersion>0.0.8-alpha-$(CIRCLE_BUILD_NUM)</PackageVersion>
<Company>LightStep</Company>
<NeutralLanguage>en-US</NeutralLanguage>
<AssemblyTitle>LightStep</AssemblyTitle>
<Description>OpenTracing compliant tracer for LightStep.</Description>
<Copyright>LightStep 2018</Copyright>
</PropertyGroup>

<PropertyGroup>
<PackageTags>tracing</PackageTags>
<PackageReleaseNotes>https://github.com/lightstep/lightstep-tracer-csharp/blob/master/CHANGELOG.md</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/lightstep/lightstep-tracer-csharp/master/ls128x128.png</PackageIconUrl>
Expand All @@ -63,5 +59,7 @@
<AssemblyOriginatorKeyFile>tracerSign.snk</AssemblyOriginatorKeyFile>
<_UseRoslynPublicSignHack>false</_UseRoslynPublicSignHack>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
7 changes: 6 additions & 1 deletion src/LightStep/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ private IDictionary<string, object> InitializeDefaultTags()
{
[LightStepConstants.TracerPlatformKey] = LightStepConstants.TracerPlatformValue,
[LightStepConstants.TracerPlatformVersionKey] = GetPlatformVersion(),
[LightStepConstants.TracerVersionKey] = "0.0.7-alpha",
[LightStepConstants.TracerVersionKey] = GetTracerVersion(),
[LightStepConstants.ComponentNameKey] = GetComponentName(),
[LightStepConstants.HostnameKey] = GetHostName(),
[LightStepConstants.CommandLineKey] = GetCommandLine()
};
return attributes;
}

private static string GetTracerVersion()
{
return typeof(LightStep.Tracer).Assembly.GetName().Version.ToString();
}

private static string GetComponentName()
{
var entryAssembly = "";
Expand Down
13 changes: 13 additions & 0 deletions src/LightStep/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;

[assembly: AssemblyProduct("LightStep")]
[assembly: AssemblyVersion("0.0.0")]
[assembly: AssemblyFileVersion("0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-local")]
[assembly: AssemblyCopyright("Copyright (c) LightStep 2018 - 2018")]

Loading