Skip to content

Commit 8c88c35

Browse files
author
Bart Koelman
authored
cibuild improvements (#976)
* Reduce logging output from tests in cibuild * Setup code coverage * Remove travis-ci * Use higher postgres version on cibuild * cibuild matrix (Windows and Linux) * Switched account for pushing documentation updates * Switched to NuGet organization account * Update README.md Updated instructions for development Updated compatibility version table Switched order of sections, based on chronological needs * Fix failing builds during force-pushes * Fixed whitespace * Corrected ctor parameter order in readme * Rename settings file * Added boilerplate comments on Startup classes, updated link to docs * Revert comments on EmptyStartup * Mentioned atomic:operations in documentation This also serves as a test for docs deployment, which only happens when merging into the master branch. * Make RuntimeTypeConverter pubternal
1 parent 47fdaa9 commit 8c88c35

34 files changed

+216
-215
lines changed

.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
"commands": [
1414
"regitlint"
1515
]
16+
},
17+
"codecov.tool": {
18+
"version": "1.13.0",
19+
"commands": [
20+
"codecov"
21+
]
22+
},
23+
"dotnet-reportgenerator-globaltool": {
24+
"version": "4.8.7",
25+
"commands": [
26+
"reportgenerator"
27+
]
1628
}
1729
}
1830
}

.travis.yml

-14
This file was deleted.

Build.ps1

+51-45
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
# Gets the version suffix from the repo tag
2-
# example: v1.0.0-preview1-final => preview1-final
3-
function Get-Version-Suffix-From-Tag {
4-
$tag=$env:APPVEYOR_REPO_TAG_NAME
5-
$split=$tag -split "-"
6-
$suffix=$split[1..2]
7-
$final=$suffix -join "-"
8-
return $final
9-
}
10-
111
function CheckLastExitCode {
122
param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null)
133

144
if ($SuccessCodes -notcontains $LastExitCode) {
15-
$msg = "EXE RETURNED EXIT CODE $LastExitCode"
16-
throw $msg
5+
throw "Executable returned exit code $LastExitCode"
176
}
187
}
198

209
function RunInspectCode {
2110
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
22-
dotnet jb inspectcode JsonApiDotNetCore.sln --output="$outputPath" --profile=JsonApiDotNetCore-WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
11+
dotnet jb inspectcode JsonApiDotNetCore.sln --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
2312
CheckLastExitCode
2413

2514
[xml]$xml = Get-Content "$outputPath"
@@ -50,21 +39,59 @@ function RunCleanupCode {
5039
# When running in cibuild for a pull request, this reformats only the files changed in the PR and fails if the reformat produces changes.
5140

5241
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT) {
53-
Write-Output "Running code cleanup in cibuild for pull request"
42+
Write-Output "Running code cleanup on changed files in pull request"
5443

55-
$sourceCommitHash = $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
44+
# In the past, we used $env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT for the merge commit hash. That is the pinned hash at the time the build is enqueued.
45+
# When a force-push happens after that, while the build hasn't yet started, this hash becomes invalid during the build, resulting in a lookup error.
46+
# To prevent failing the build for unobvious reasons we use HEAD, which is always the latest version.
47+
$mergeCommitHash = git rev-parse "HEAD"
5648
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
5749

58-
Write-Output "Source commit hash = $sourceCommitHash"
59-
Write-Output "Target commit hash = $targetCommitHash"
60-
61-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $sourceCommitHash -b $targetCommitHash --fail-on-diff --print-diff
50+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
6251
CheckLastExitCode
6352
}
6453
}
6554

66-
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
67-
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
55+
function ReportCodeCoverage {
56+
if ($env:APPVEYOR) {
57+
if ($IsWindows) {
58+
dotnet codecov -f "**\coverage.cobertura.xml"
59+
}
60+
}
61+
else {
62+
dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage
63+
}
64+
65+
CheckLastExitCode
66+
}
67+
68+
function CreateNuGetPackage {
69+
if ($env:APPVEYOR_REPO_TAG -eq $true) {
70+
# Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final
71+
$segments = $env:APPVEYOR_REPO_TAG_NAME -split "-"
72+
$suffixSegments = $segments[1..2]
73+
$versionSuffix = $suffixSegments -join "-"
74+
}
75+
else {
76+
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
77+
if ($env:APPVEYOR_BUILD_NUMBER) {
78+
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
79+
$versionSuffix = "pre-$revision"
80+
}
81+
else {
82+
$versionSuffix = "pre-0001"
83+
}
84+
}
85+
86+
if ([string]::IsNullOrWhitespace($versionSuffix)) {
87+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
88+
}
89+
else {
90+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$versionSuffix
91+
}
92+
93+
CheckLastExitCode
94+
}
6895

6996
dotnet tool restore
7097
CheckLastExitCode
@@ -75,30 +102,9 @@ CheckLastExitCode
75102
RunInspectCode
76103
RunCleanupCode
77104

78-
dotnet test -c Release --no-build
105+
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
79106
CheckLastExitCode
80107

81-
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
82-
83-
if ($env:APPVEYOR_REPO_TAG -eq $true) {
84-
$revision = Get-Version-Suffix-From-Tag
85-
Write-Output "VERSION-SUFFIX: $revision"
108+
ReportCodeCoverage
86109

87-
if ([string]::IsNullOrWhitespace($revision)) {
88-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
89-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
90-
CheckLastExitCode
91-
}
92-
else {
93-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
94-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
95-
CheckLastExitCode
96-
}
97-
}
98-
else {
99-
$packageVersionSuffix="pre-$revision"
100-
Write-Output "VERSION-SUFFIX: $packageVersionSuffix"
101-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix"
102-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix
103-
CheckLastExitCode
104-
}
110+
CreateNuGetPackage

Directory.Build.props

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
<!-- Test Project Dependencies -->
2323
<PropertyGroup>
24-
<XUnitVersion>2.4.1</XUnitVersion>
25-
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
2624
<BogusVersion>33.0.2</BogusVersion>
25+
<CoverletVersion>3.0.3</CoverletVersion>
26+
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
2727
<MoqVersion>4.16.1</MoqVersion>
28+
<XUnitVersion>2.4.1</XUnitVersion>
2829
</PropertyGroup>
2930
</Project>

README.md

+43-38
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
</p>
44

55
# JsonApiDotNetCore
6-
A framework for building [JSON:API](http://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core.
6+
A framework for building [JSON:API](http://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/).
77

8-
[![Build status](https://ci.appveyor.com/api/projects/status/5go47hrm0iik0ls3/branch/master?svg=true)](https://ci.appveyor.com/project/jaredcnance/jsonapidotnetcore/branch/master)
9-
[![Travis](https://travis-ci.org/json-api-dotnet/JsonApiDotNetCore.svg?branch=master)](https://travis-ci.org/json-api-dotnet/JsonApiDotNetCore)
8+
[![Build](https://ci.appveyor.com/api/projects/status/t8noo6rjtst51kga/branch/master?svg=true)](https://ci.appveyor.com/project/json-api-dotnet/jsonapidotnetcore/branch/master)
9+
[![Coverage](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore/branch/master/graph/badge.svg?token=pn036tWV8T)](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore)
1010
[![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/)
11-
[![Join the chat at https://gitter.im/json-api-dotnet-core/Lobby](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
11+
[![Chat](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1212
[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
1313

1414
The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection, making extensibility incredibly easy.
@@ -34,7 +34,7 @@ These are some steps you can take to help you understand what this project is an
3434

3535
## Examples
3636

37-
See the [examples](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/src/Examples) directory for up-to-date sample applications. There is also a [Todo List App](https://github.com/json-api-dotnet/TodoListExample) that includes a JADNC API and an EmberJs client.
37+
See the [examples](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/src/Examples) directory for up-to-date sample applications. There is also a [Todo List App](https://github.com/json-api-dotnet/TodoListExample) that includes a JsonApiDotNetCore API and an EmberJs client.
3838

3939
## Installation and Usage
4040

@@ -55,9 +55,9 @@ public class Article : Identifiable
5555
```c#
5656
public class ArticlesController : JsonApiController<Article>
5757
{
58-
public ArticlesController(IJsonApiOptions options, IResourceService<Article> resourceService,
59-
ILoggerFactory loggerFactory)
60-
: base(options, resourceService, loggerFactory)
58+
public ArticlesController(IJsonApiOptions options, ILoggerFactory loggerFactory,
59+
IResourceService<Article> resourceService,)
60+
: base(options, loggerFactory, resourceService)
6161
{
6262
}
6363
}
@@ -82,45 +82,24 @@ public class Startup
8282
}
8383
```
8484

85-
## Development
86-
87-
Restore all NuGet packages with:
88-
89-
```bash
90-
dotnet restore
91-
```
85+
## Compatibility
9286

93-
### Testing
87+
A lot of changes were introduced in v4. The following chart should help you pick the best version, based on your environment.
9488

95-
Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:
89+
| .NET Version | EF Core Version | JsonApiDotNetCore Version |
90+
| ----------------- | --------------- | ------------------------- |
91+
| .NET Core 2.x | 2.x | v3.x |
92+
| .NET Core 3.1 | 3.1, 5 | v4 |
93+
| .NET 5 | 5 | v4 |
9694

97-
```bash
98-
docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:12.0
99-
```
100-
101-
And then to run the tests:
102-
103-
```bash
104-
dotnet test
105-
```
10695

10796
## Contributing
10897

10998
Have a question, found a bug or want to submit code changes? See our [contributing guidelines](./.github/CONTRIBUTING.md).
11099

111-
## Compatibility
100+
## Trying out the latest build
112101

113-
A lot of changes were introduced in v4, the following chart should help you with compatibility issues between .NET Core versions.
114-
115-
| .NET Core Version | EF Core Version | JADNC Version |
116-
| ----------------- | --------------- | ------------- |
117-
| 2.x | 2.x | v3.x |
118-
| 3.x | 3.x, 5.x | v4.x |
119-
| 5.x | 5.x | v4.x |
120-
121-
### Trying out the latest build
122-
123-
After each commit, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/nuget/jsonapidotnetcore. To try it out, follow the next steps:
102+
After each commit to the master branch, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/nuget/jsonapidotnetcore. To try it out, follow the next steps:
124103

125104
* In Visual Studio: **Tools**, **NuGet Package Manager**, **Package Manager Settings**, **Package Sources**
126105
* Click **+**
@@ -129,3 +108,29 @@ After each commit, a new prerelease NuGet package is automatically published to
129108
* Open the NuGet package manager console (**Tools**, **NuGet Package Manager**, **Package Manager Console**)
130109
* Select **AppVeyor JADNC** as package source
131110
* Run command: `Install-Package JonApiDotNetCore -pre`
111+
112+
## Development
113+
114+
To build the code from this repository locally, run:
115+
116+
```bash
117+
dotnet build
118+
```
119+
120+
Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:
121+
122+
```bash
123+
run-docker-postgres.ps1
124+
```
125+
126+
And then to run the tests:
127+
128+
```bash
129+
dotnet test
130+
```
131+
132+
Alternatively, to build and validate the code, run all tests, generate code coverage and produce the NuGet package:
133+
134+
```bash
135+
Build.ps1
136+
```

0 commit comments

Comments
 (0)