Skip to content

Commit 4fd0487

Browse files
Add Cake as build system (#46)
fixes #32 by having git tags create versions
1 parent 365e011 commit 4fd0487

File tree

12 files changed

+220
-80
lines changed

12 files changed

+220
-80
lines changed

.circleci/config.yml

+32-36
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
version: 2
22
jobs:
3-
build:
3+
build-and-test:
44
docker:
55
- image: aparker/circleci-dotnet-mono:latest
66
steps:
77
- checkout
8-
- run: msbuild /t:Restore
9-
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
10-
test:
11-
docker:
12-
- image: aparker/circleci-dotnet-mono:latest
13-
steps:
14-
- checkout
15-
- run: msbuild /t:Restore
16-
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
17-
- run: msbuild test/LightStep.Tests/LightStep.Tests.csproj /t:Build
18-
- run: msbuild test/LightStep.Tests/LightStep.Tests.csproj /t:Test
19-
pack:
20-
docker:
21-
- image: aparker/circleci-dotnet-mono:latest
22-
steps:
23-
- checkout
24-
- run: msbuild /t:Restore
25-
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Build
26-
- run: sn -R src/LightStep/bin/Debug/net45/LightStep.dll src/LightStep/tracerSign.snk && sn -vf src/LightStep/bin/Debug/net45/LightStep.dll
27-
- run: msbuild src/LightStep/LightStep.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=tracerSign.snk /t:Pack /p:PackageOutputPath="/pkg"
28-
- store_artifacts:
29-
path: /pkg
8+
- run: dotnet tool install -g dotnet-xunit-to-junit
9+
- run: dotnet tool install -g Cake.Tool
10+
- run: export PATH="$PATH:/root/.dotnet/tools"
11+
- run:
12+
name: Update PATH and Define Environment Variable at Runtime
13+
command: |
14+
echo 'export PATH="$PATH:/root/.dotnet/tools"' >> $BASH_ENV
15+
source $BASH_ENV
16+
- run: dotnet cake build.cake -t=Test
17+
- run: dotnet xunit-to-junit ./build/test_results.xml ./build/LightStep.Tests.dll.junit.xml
18+
- store_test_results:
19+
path: build/LightStep.Tests.dll.junit.xml
3020

3121
publish:
3222
docker:
3323
- image: aparker/circleci-dotnet-mono:latest
3424
steps:
3525
- checkout
36-
- run: msbuild /t:Restore
37-
- run: msbuild /t:Build
38-
- run: msbuild src/LightStep/LightStep.csproj /t:Pack
39-
- run: dotnet nuget push src/LightStep/bin/Debug/*.nupkg -k $NuGet
26+
- run: dotnet tool install -g dotnet-xunit-to-junit
27+
- run: dotnet tool install -g Cake.Tool
28+
- run:
29+
name: Update PATH and Define Environment Variable at Runtime
30+
command: |
31+
echo 'export PATH="$PATH:/root/.dotnet/tools"' >> $BASH_ENV
32+
source $BASH_ENV
33+
- run: dotnet cake build.cake -t=Publish
34+
- run: dotnet xunit-to-junit ./build/test_results.xml ./build/LightStep.Tests.dll.junit.xml
35+
- store_test_results:
36+
path: build/LightStep.Tests.dll.junit.xml
4037

4138
workflows:
4239
version: 2
43-
build-test-and-pack:
40+
untagged-build:
41+
jobs:
42+
- build-and-test
43+
tagged-build:
4444
jobs:
45-
- build
46-
- test:
47-
requires:
48-
- build
49-
- pack:
50-
requires:
51-
- test
45+
- publish:
5246
filters:
5347
branches:
54-
only: master
48+
ignore: /.*/
49+
tags:
50+
only: /^v.*/

.gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,14 @@ ASALocalRun/
327327
*.nvuser
328328

329329
# MFractors (Xamarin productivity tool) working folder
330-
.mfractor/
330+
.mfractor/
331+
332+
# cakebuild tools
333+
tools/
334+
335+
dist/
336+
build/
337+
338+
# this is generated at build, ignoring it here
339+
src/LightStep/Properties/AssemblyInfo.cs
340+

.vscode/tasks.json

+17-15
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "build",
8-
"type": "shell",
9-
"command": "msbuild",
10-
"args": [
11-
// Ask msbuild to generate full paths for file names.
12-
"/property:GenerateFullPaths=true",
13-
"/t:build"
14-
],
15-
"group": "build",
16-
"presentation": {
17-
// Reveal the output only if unrecognized errors occur.
18-
"reveal": "silent"
19-
},
20-
// Use the standard MS compiler pattern to detect errors, warnings and infos
21-
"problemMatcher": "$msCompile"
7+
"type": "cake",
8+
"script": "Default",
9+
"group": {
10+
"kind": "build",
11+
"isDefault": true
12+
}
13+
},
14+
{
15+
"type": "cake",
16+
"script": "Test",
17+
"problemMatcher": [],
18+
"group": "test"
19+
},
20+
{
21+
"type": "cake",
22+
"script": "Clean",
23+
"problemMatcher": []
2224
}
2325
]
2426
}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
_vNext_
4+
- We now build using [Cake](https://cakebuild.net).
45
- All value types are now properly handled in span serialization.
56
- The platform version detection code has been improved and should be resilient to dynamic injection scenarios.
67
- Logging now exists for many operations via the LibLog library. See the README for more details.

CONTRIBUTING.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Contributing Guide
2+
3+
First, thanks for your contribution! 🎉
4+
5+
We gladly accept issues and pull requests to this repository. If this is a security-related issue, please email us directly at [email protected].
6+
7+
Please note the following general guidelines and advice -
8+
9+
## Issues
10+
When submitting an issue, please include the following in addition to an explanation of the issue:
11+
- Version of the library you're using.
12+
- The runtime and platform version you're using (e.g., .NET 4.6.1 or .NET Core 2.1).
13+
- Any stack trace or diagnostic logs you may have that demonstrate the issue.
14+
15+
## Pull Requests
16+
Before making a pull request for a feature, please open an issue in order to gain consensus on the work you're doing.
17+
18+
All pull requests should be rebased against `master`, and all tests should pass before a PR will be merged.
19+
20+
In addition, ensure that:
21+
- Test coverage has been added, where appropriate.
22+
- The CHANGELOG and README have been updated.
23+
- If you are making a breaking change, indicate it in the CHANGELOG.
24+
25+
## Releases
26+
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.
27+
28+
## Developing
29+
30+
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.
31+
32+
_Development Dependencies_
33+
- .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**
34+
- .NET Core 2.1+
35+
- Cake (see _Local Builds_)
36+
- PostSharp (Windows only, for `LightStep.CSharpAspectTestApp`)
37+
38+
_Local Builds_
39+
40+
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+.
41+
42+
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/).

README.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@ The LightStep distributed tracing library for C#
33

44
[![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)
55

6-
# Development Requirements
7-
- C# 7
8-
- .NET Core 2+
9-
- .NET 4.5
10-
11-
This translates to requiring at least Visual Studio 2017 (15.0).
12-
You may need [PostSharp](https://www.postsharp.net/) to work on the `LightStep.CSharpAspectTestApp`.
13-
146
# Installation
15-
Install the package via NuGet into your solution, or use `Install-Package LightStep`.
7+
Install the package via NuGet into your solution, or use `Install-Package LightStep` / `dotnet add package LightStep`.
168

179
# Basic Usage
1810
It's recommended to initialize the tracer once at the beginning of your application and assign it as the global tracer, as follows:

build.cake

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#tool "xunit.runner.console"
2+
3+
var target = Argument("target", "Default");
4+
var configuration = Argument("configuration", "Release");
5+
var debugConfiguration = Argument("configuration", "Debug");
6+
var buildDir = Directory("./build");
7+
var distDir = Directory("./dist");
8+
var solution = "./LightStep.sln";
9+
var library = "./src/LightStep/LightStep.csproj";
10+
var lightStepAssemblyInfoFile = "./src/LightStep/Properties/AssemblyInfo.cs";
11+
var version = EnvironmentVariable("CIRCLE_TAG") ?? "v0.0.0";
12+
version = version.TrimStart('v');
13+
var buildNo = String.IsNullOrWhiteSpace(EnvironmentVariable("CIRCLE_BUILD_NUM")) ? "local" : EnvironmentVariable("CIRCLE_BUILD_NUM");
14+
var semVersion = string.Concat(version + "-" + buildNo);
15+
var nuGetApiKey = EnvironmentVariable("NuGet");
16+
17+
Task("Clean")
18+
.Does( ()=>
19+
{
20+
CleanDirectory(buildDir);
21+
CleanDirectory(distDir);
22+
CleanDirectories("./**/obj/*.*");
23+
CleanDirectories($"./**/bin/{configuration}/*.*");
24+
CleanDirectories($"./**/bin/{debugConfiguration}/*.*");
25+
});
26+
27+
Task("Restore")
28+
.IsDependentOn("Clean")
29+
.Does( ()=>
30+
{
31+
DotNetCoreRestore(solution);
32+
});
33+
34+
Task("Build")
35+
.IsDependentOn("Restore")
36+
.Does(() =>
37+
{
38+
CreateAssemblyInfo(lightStepAssemblyInfoFile, new AssemblyInfoSettings {
39+
Product = "LightStep",
40+
Version = version,
41+
FileVersion = version,
42+
InformationalVersion = semVersion,
43+
Copyright = string.Format("Copyright (c) LightStep 2018 - {0}", DateTime.Now.Year)
44+
});
45+
var assemblyInfo = ParseAssemblyInfo(lightStepAssemblyInfoFile);
46+
Information("Version: {0}", assemblyInfo.AssemblyVersion);
47+
Information("File version: {0}", assemblyInfo.AssemblyFileVersion);
48+
Information("Informational version: {0}", assemblyInfo.AssemblyInformationalVersion);
49+
MSBuild(library, settings => settings
50+
.SetConfiguration(configuration)
51+
.WithTarget("Rebuild")
52+
.WithProperty("Version", assemblyInfo.AssemblyInformationalVersion)
53+
.SetVerbosity(Verbosity.Minimal));
54+
});
55+
56+
Task("Test")
57+
.IsDependentOn("Build")
58+
.Does(() =>
59+
{
60+
var projects = GetFiles("./test/**/*.csproj");
61+
62+
foreach(var project in projects)
63+
{
64+
DotNetCoreTest(project.FullPath, new DotNetCoreTestSettings {
65+
Logger = "xunit;LogFilePath=../../build/test_results.xml"
66+
});
67+
}
68+
69+
});
70+
71+
Task("Publish")
72+
.IsDependentOn("Test")
73+
.WithCriteria(() => EnvironmentVariable("CI") == "true")
74+
.Does(() =>
75+
{
76+
var nupkg = GetFiles("./src/LightStep/bin/Release/*.nupkg").First();
77+
DotNetCoreNuGetPush(nupkg.FullPath, new DotNetCoreNuGetPushSettings {
78+
ApiKey = nuGetApiKey
79+
});
80+
});
81+
82+
Task("Default")
83+
.IsDependentOn("Test");
84+
85+
RunTarget(target);

examples/LightStep.CSharpAspectTestApp/Properties/AssemblyInfo.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Reflection;
1+
using System.Reflection;
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

@@ -31,6 +31,8 @@
3131
//
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
// [assembly: AssemblyVersion("0.1.29.0")]
35+
[assembly: AssemblyVersion("0.1.29.0")]
36+
[assembly: AssemblyFileVersion("0.1.29.0")]
37+
38+
[assembly: AssemblyInformationalVersion("0.1.29-enhancement-addCake.1-2018-11-12")]

src/LightStep/LightStep.csproj

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@
3838

3939
<PropertyGroup>
4040
<Authors>Austin Parker</Authors>
41-
<PackageVersion>0.0.8-alpha-$(CIRCLE_BUILD_NUM)</PackageVersion>
4241
<Company>LightStep</Company>
4342
<NeutralLanguage>en-US</NeutralLanguage>
4443
<AssemblyTitle>LightStep</AssemblyTitle>
4544
<Description>OpenTracing compliant tracer for LightStep.</Description>
4645
<Copyright>LightStep 2018</Copyright>
47-
</PropertyGroup>
48-
49-
<PropertyGroup>
5046
<PackageTags>tracing</PackageTags>
5147
<PackageReleaseNotes>https://github.com/lightstep/lightstep-tracer-csharp/blob/master/CHANGELOG.md</PackageReleaseNotes>
5248
<PackageIconUrl>https://raw.githubusercontent.com/lightstep/lightstep-tracer-csharp/master/ls128x128.png</PackageIconUrl>
@@ -63,5 +59,7 @@
6359
<AssemblyOriginatorKeyFile>tracerSign.snk</AssemblyOriginatorKeyFile>
6460
<_UseRoslynPublicSignHack>false</_UseRoslynPublicSignHack>
6561
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
62+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
63+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6664
</PropertyGroup>
6765
</Project>

src/LightStep/Options.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,19 @@ private IDictionary<string, object> InitializeDefaultTags()
156156
{
157157
[LightStepConstants.TracerPlatformKey] = LightStepConstants.TracerPlatformValue,
158158
[LightStepConstants.TracerPlatformVersionKey] = GetPlatformVersion(),
159-
[LightStepConstants.TracerVersionKey] = "0.0.7-alpha",
159+
[LightStepConstants.TracerVersionKey] = GetTracerVersion(),
160160
[LightStepConstants.ComponentNameKey] = GetComponentName(),
161161
[LightStepConstants.HostnameKey] = GetHostName(),
162162
[LightStepConstants.CommandLineKey] = GetCommandLine()
163163
};
164164
return attributes;
165165
}
166166

167+
private static string GetTracerVersion()
168+
{
169+
return typeof(LightStep.Tracer).Assembly.GetName().Version.ToString();
170+
}
171+
167172
private static string GetComponentName()
168173
{
169174
var entryAssembly = "";
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by Cake.
4+
// </auto-generated>
5+
//------------------------------------------------------------------------------
6+
using System.Reflection;
7+
8+
[assembly: AssemblyProduct("LightStep")]
9+
[assembly: AssemblyVersion("0.0.0")]
10+
[assembly: AssemblyFileVersion("0.0.0")]
11+
[assembly: AssemblyInformationalVersion("0.0.0-local")]
12+
[assembly: AssemblyCopyright("Copyright (c) LightStep 2018 - 2018")]
13+

0 commit comments

Comments
 (0)