Skip to content

Commit fcc9370

Browse files
committed
Code quality and release prep
1 parent a4da0d8 commit fcc9370

33 files changed

Lines changed: 627 additions & 161 deletions

.editorconfig

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# EditorConfig is awesome:http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
11+
# Code files
12+
[*.{cs,csx,vb,vbx}]
13+
indent_size = 4
14+
15+
# Xml project files
16+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
17+
indent_size = 2
18+
19+
# Xml config files
20+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
21+
indent_size = 2
22+
23+
# JSON files
24+
[*.json]
25+
indent_size = 2
26+
27+
# Dotnet code style settings:
28+
[*.{cs,vb}]
29+
# Sort using and Import directives with System.* appearing first
30+
dotnet_sort_system_directives_first = true
31+
# Avoid "this." and "Me." if not necessary
32+
dotnet_style_qualification_for_field = false:suggestion
33+
dotnet_style_qualification_for_property = false:suggestion
34+
dotnet_style_qualification_for_method = false:suggestion
35+
dotnet_style_qualification_for_event = false:suggestion
36+
37+
# Use language keywords instead of framework type names for type references
38+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
39+
dotnet_style_predefined_type_for_member_access = true:suggestion
40+
41+
# Suggest more modern language features when available
42+
dotnet_style_object_initializer = true:suggestion
43+
dotnet_style_collection_initializer = true:suggestion
44+
dotnet_style_coalesce_expression = true:suggestion
45+
dotnet_style_null_propagation = true:suggestion
46+
dotnet_style_explicit_tuple_names = true:suggestion
47+
48+
# CSharp code style settings:
49+
[*.cs]
50+
csharp_style_var_for_built_in_types = false:suggestion
51+
csharp_style_var_when_type_is_apparent = false:suggestion
52+
csharp_style_var_elsewhere = false:suggestion
53+
54+
# Prefer method-like constructs to have a block body
55+
csharp_style_expression_bodied_methods = false:none
56+
csharp_style_expression_bodied_constructors = false:none
57+
csharp_style_expression_bodied_operators = false:none
58+
59+
# Prefer property-like constructs to have an expression-body
60+
csharp_style_expression_bodied_properties = true:none
61+
csharp_style_expression_bodied_indexers = true:none
62+
csharp_style_expression_bodied_accessors = true:none
63+
64+
# Suggest more modern language features when available
65+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
66+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
67+
csharp_style_inlined_variable_declaration = true:suggestion
68+
csharp_style_throw_expression = true:suggestion
69+
csharp_style_conditional_delegate_call = true:suggestion
70+
71+
# Newline settings
72+
csharp_new_line_before_open_brace = all
73+
csharp_new_line_before_else = true
74+
csharp_new_line_before_catch = true
75+
csharp_new_line_before_finally = true
76+
csharp_new_line_before_members_in_object_initializers = true
77+
csharp_new_line_before_members_in_anonymous_types = true

Directory.Build.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<PropertyGroup>
3+
<CodeAnalysisRuleSet>../../daveaglick.ruleset</CodeAnalysisRuleSet>
4+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
5+
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
6+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
10+
<PrivateAssets>all</PrivateAssets>
11+
</PackageReference>
12+
<PackageReference Include="Roslynator.Analyzers" Version="2.0.0">
13+
<PrivateAssets>all</PrivateAssets>
14+
</PackageReference>
15+
</ItemGroup>
16+
</Project>

README.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,63 @@
11
# AzurePipelines.TestLogger
2+
23
Azure Pipelines logger extension for the [Visual Studio Test Platform](https://gtihub.com/microsoft/vstest).
34

5+
## Why Do I Need This?
6+
7+
This logger extensions allows you to send test results from a `dotnet test` session directly to Azure Pipelines in real-time as the tests are executed. It also talks directly to the Azure DevOps REST API and as a result can better represent your tests using Azure Pipelines conventions over other post-processing methods such as logging to a TRX file and processing with the `PublishTestResults` Azure Pipelines task.
8+
49
## Usage
5-
AzurePipelines.TestLogger can report test results automatically to the CI build.
610

7-
1. Add a reference to the [AzurePipelines.TestLogger NuGet package](https://www.nuget.org/packages/AzurePipelines.TestLogger) in your test project
8-
2. Use the following command when running tests
11+
In order for the logger to authenticate against the Azure DevOps API you'll need to [expose the access token via an environment variable](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=vsts&tabs=yaml%2Cbatch#systemaccesstoken) in your Azure Pipelines `.yml` file:
12+
13+
```
14+
env:
15+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
16+
```
17+
18+
### Installing Into Your Project
19+
20+
* Add a reference to the [AzurePipelines.TestLogger NuGet package](https://www.nuget.org/packages/AzurePipelines.TestLogger) in your test project
21+
* Use the following command when running tests
922
```
1023
> dotnet test --test-adapter-path:. --logger:AzurePipelines
1124
```
12-
3. Test results are automatically reported to the Azure Pipelines CI results
25+
* Test results are automatically reported to the Azure Pipelines CI results
26+
27+
### Using Cake
28+
29+
An alternative to installing the logger directly into your test project is installing it as a tool in Cake:
30+
31+
```
32+
#tool "AzurePipelines.TestLogger&version=1.0.0"
33+
```
34+
35+
Then you can specify the logger during test runs when running on your CI server (the following is example code, your Cake build script may look or behave a little differently):
36+
37+
```
38+
Task("Test")
39+
.Description("Runs all tests.")
40+
.IsDependentOn("Build")
41+
.DoesForEach(GetFiles("./tests/*Tests/*.csproj"), project =>
42+
{
43+
DotNetCoreTestSettings testSettings = new DotNetCoreTestSettings()
44+
{
45+
NoBuild = true,
46+
NoRestore = true,
47+
Configuration = configuration
48+
};
49+
if (isRunningOnBuildServer)
50+
{
51+
testSettings.Filter = "TestCategory!=ExcludeFromBuildServer";
52+
testSettings.Logger = "AzurePipelines";
53+
testSettings.TestAdapterPath = GetDirectories($"./tools/AzurePipelines.TestLogger.*/contentFiles/any/any").First();
54+
}
55+
56+
Information($"Running tests in {project}");
57+
DotNetCoreTest(MakeAbsolute(project).ToString(), testSettings);
58+
})
59+
.DeferOnError();
60+
```
1361

1462
## Credit
1563

ReleaseNotes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.0.0
2+
3+
- [Refactoring] Code quality improvements
4+
15
# 0.4.7
26

37
- [Fix] Sends start dates when marking as completed so they don't get reset

azure-pipelines.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
jobs:
2+
- job: Windows
3+
pool:
4+
vmImage: 'vs2017-win2016'
5+
steps:
6+
- script: build -target BuildServer
7+
env:
8+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
9+
- job: Linux
10+
pool:
11+
vmImage: 'ubuntu 16.04'
12+
steps:
13+
- script: pwsh ./build.ps1 -target BuildServer
14+
env:
15+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
16+
- job: Mac
17+
pool:
18+
vmImage: 'macOS-10.13'
19+
steps:
20+
- script: pwsh ./build.ps1 -target BuildServer
21+
env:
22+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

build.cake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// NUGET_KEY
33
// GITHUB_TOKEN
44

5+
#tool "AzurePipelines.TestLogger&version=1.0.0"
56
#addin "Octokit"
67

78
using Octokit;
@@ -106,7 +107,8 @@ Task("Test")
106107
if (isRunningOnBuildServer)
107108
{
108109
testSettings.Filter = "TestCategory!=ExcludeFromBuildServer";
109-
testSettings.Logger = "trx";
110+
testSettings.Logger = "AzurePipelines";
111+
testSettings.TestAdapterPath = GetDirectories($"./tools/AzurePipelines.TestLogger.*/contentFiles/any/any").First();
110112
}
111113

112114
Information($"Running tests in {project}");
@@ -218,6 +220,11 @@ Task("Release")
218220
.Description("Generates a GitHub release and pushes the NuGet package.")
219221
.IsDependentOn("GitHub")
220222
.IsDependentOn("NuGet");
223+
224+
Task("BuildServer")
225+
.Description("Runs a build from the build server and updates build server data.")
226+
.IsDependentOn("Test")
227+
.WithCriteria(() => isRunningOnBuildServer);
221228

222229
//////////////////////////////////////////////////////////////////////
223230
// EXECUTION

0 commit comments

Comments
 (0)