Skip to content

Commit 69e3a58

Browse files
authored
Merge pull request #1339 from json-api-dotnet/merge-master-into-openapi
Merge master into openapi
2 parents e9c1e9b + 43f4890 commit 69e3a58

File tree

183 files changed

+3192
-1264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+3192
-1264
lines changed

.config/dotnet-tools.json

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,25 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2023.1.2",
6+
"version": "2023.2.1",
77
"commands": [
88
"jb"
99
]
1010
},
1111
"regitlint": {
12-
"version": "6.3.11",
12+
"version": "6.3.12",
1313
"commands": [
1414
"regitlint"
1515
]
1616
},
17-
"codecov.tool": {
18-
"version": "1.13.0",
19-
"commands": [
20-
"codecov"
21-
]
22-
},
2317
"dotnet-reportgenerator-globaltool": {
24-
"version": "5.1.20",
18+
"version": "5.1.25",
2519
"commands": [
2620
"reportgenerator"
2721
]
2822
},
2923
"docfx": {
30-
"version": "2.67.1",
24+
"version": "2.70.4",
3125
"commands": [
3226
"docfx"
3327
]

.github/dependabot.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
pull-request-branch-name:
8+
separator: "-"
9+
- package-ecosystem: nuget
10+
directory: "/"
11+
schedule:
12+
interval: daily
13+
pull-request-branch-name:
14+
separator: "-"
15+
open-pull-requests-limit: 25
16+
ignore:
17+
# Block updates to all exposed dependencies of the NuGet packages we produce, as updating them would be a breaking change.
18+
- dependency-name: 'Ben.Demystifier'
19+
- dependency-name: 'Humanizer*'
20+
- dependency-name: 'Microsoft.CodeAnalysis*'
21+
- dependency-name: 'Microsoft.EntityFrameworkCore*'
22+
# Block major updates of packages that require a matching .NET version.
23+
- dependency-name: 'Microsoft.AspNetCore*'
24+
update-types: ["version-update:semver-major"]

.github/workflows/build.yml

+279
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
# General links
2+
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
3+
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
4+
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads
5+
# https://docs.github.com/en/actions/learn-github-actions/expressions
6+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
7+
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
8+
9+
name: Build
10+
11+
on:
12+
push:
13+
branches: [ 'master', 'release/**', 'openapi' ]
14+
pull_request:
15+
branches: [ 'master', 'release/**', 'openapi' ]
16+
tags:
17+
- 'v*'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
env:
24+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
25+
DOTNET_CLI_TELEMETRY_OPTOUT: true
26+
# The Windows runner image has PostgreSQL pre-installed and sets the PGPASSWORD environment variable to "root".
27+
# This conflicts with the default password "postgres", which is used by ikalnytskyi/action-setup-postgres.
28+
# Because action-setup-postgres forgets to update the environment variable accordingly, we do so here.
29+
PGPASSWORD: "postgres"
30+
31+
jobs:
32+
build-and-test:
33+
timeout-minutes: 60
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
os: [ubuntu-latest, windows-latest, macos-latest]
38+
runs-on: ${{ matrix.os }}
39+
permissions:
40+
contents: read
41+
steps:
42+
- name: Setup PostgreSQL
43+
uses: ikalnytskyi/action-setup-postgres@v4
44+
with:
45+
username: postgres
46+
password: postgres
47+
- name: Setup .NET
48+
uses: actions/setup-dotnet@v3
49+
with:
50+
dotnet-version: 6.0.x
51+
- name: Setup PowerShell (Ubuntu)
52+
if: matrix.os == 'ubuntu-latest'
53+
run: |
54+
dotnet tool install --global PowerShell
55+
- name: Setup PowerShell (Windows)
56+
if: matrix.os == 'windows-latest'
57+
shell: cmd
58+
run: |
59+
curl --location --output "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/PowerShell-7.3.6-win-x64.msi
60+
msiexec.exe /package "%RUNNER_TEMP%\PowerShell-7.3.6-win-x64.msi" /quiet USE_MU=1 ENABLE_MU=1 ADD_PATH=1 DISABLE_TELEMETRY=1
61+
- name: Setup PowerShell (macOS)
62+
if: matrix.os == 'macos-latest'
63+
run: |
64+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
65+
brew install --cask powershell
66+
- name: Show installed versions
67+
shell: pwsh
68+
run: |
69+
Write-Host "$(pwsh --version) is installed at $PSHOME"
70+
psql --version
71+
Write-Host "Active .NET SDK: $(dotnet --version)"
72+
- name: Git checkout
73+
uses: actions/checkout@v4
74+
- name: Restore tools
75+
run: |
76+
dotnet tool restore
77+
- name: Restore packages
78+
run: |
79+
dotnet restore
80+
- name: Calculate version suffix
81+
shell: pwsh
82+
run: |
83+
if ($env:GITHUB_REF_TYPE -eq 'tag') {
84+
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
85+
$segments = $env:GITHUB_REF_NAME -split "-"
86+
$versionPrefix = $segments[0].TrimStart('v')
87+
$versionSuffix = $segments[1..-1] -join "-"
88+
89+
[xml]$xml = Get-Content Directory.Build.props
90+
$configuredVersionPrefix = $xml.Project.PropertyGroup[0].JsonApiDotNetCoreVersionPrefix
91+
if ($configuredVersionPrefix -ne $versionPrefix) {
92+
Write-Error "Version prefix from git release tag '$versionPrefix' does not match version prefix '$configuredVersionPrefix' stored in Directory.Build.props."
93+
# To recover from this:
94+
# - Delete the GitHub release
95+
# - Run: git push --delete the-invalid-tag-name
96+
# - Adjust JsonApiDotNetCoreVersionPrefix in Directory.Build.props, commit and push
97+
# - Recreate the GitHub release
98+
}
99+
}
100+
else {
101+
# Get the version suffix from the auto-incrementing build number. For example: '123' => 'master-00123'
102+
$revision = "{0:D5}" -f [convert]::ToInt32($env:GITHUB_RUN_NUMBER, 10)
103+
$branchName = ![string]::IsNullOrEmpty($env:GITHUB_HEAD_REF) ? $env:GITHUB_HEAD_REF : $env:GITHUB_REF_NAME
104+
$safeName = $branchName.Replace('/', '-').Replace('_', '-')
105+
$versionSuffix = "$safeName-$revision"
106+
}
107+
Write-Output "Using version suffix: $versionSuffix"
108+
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
109+
- name: Build
110+
shell: pwsh
111+
run: |
112+
dotnet build --no-restore --configuration Release --version-suffix=$env:PACKAGE_VERSION_SUFFIX
113+
- name: Test
114+
run: |
115+
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true" -- RunConfiguration.CollectSourceInformation=true DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DeterministicReport=true
116+
- name: Upload coverage to codecov.io
117+
if: matrix.os == 'ubuntu-latest'
118+
uses: codecov/codecov-action@v3
119+
- name: Generate packages
120+
shell: pwsh
121+
run: |
122+
dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages --version-suffix=$env:PACKAGE_VERSION_SUFFIX
123+
- name: Upload packages to artifacts
124+
if: matrix.os == 'ubuntu-latest'
125+
uses: actions/upload-artifact@v3
126+
with:
127+
name: packages
128+
path: artifacts/packages
129+
- name: Generate documentation
130+
shell: pwsh
131+
env:
132+
# This contains the git tag name on release; in that case we build the docs without publishing them.
133+
DOCFX_SOURCE_BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
134+
run: |
135+
cd docs
136+
& ./generate-examples.ps1
137+
dotnet docfx docfx.json
138+
if ($LastExitCode -ne 0) {
139+
Write-Error "docfx failed with exit code $LastExitCode."
140+
}
141+
Copy-Item CNAME _site/CNAME
142+
Copy-Item home/*.html _site/
143+
Copy-Item home/*.ico _site/
144+
New-Item -Force _site/styles -ItemType Directory | Out-Null
145+
Copy-Item -Recurse home/assets/* _site/styles/
146+
- name: Upload documentation to artifacts
147+
if: matrix.os == 'ubuntu-latest'
148+
uses: actions/upload-artifact@v3
149+
with:
150+
name: documentation
151+
path: docs/_site
152+
153+
inspect-code:
154+
timeout-minutes: 60
155+
strategy:
156+
fail-fast: false
157+
matrix:
158+
os: [ubuntu-latest, windows-latest, macos-latest]
159+
runs-on: ${{ matrix.os }}
160+
permissions:
161+
contents: read
162+
steps:
163+
- name: Git checkout
164+
uses: actions/checkout@v4
165+
- name: Setup .NET
166+
uses: actions/setup-dotnet@v3
167+
with:
168+
dotnet-version: 6.0.x
169+
- name: Restore tools
170+
run: |
171+
dotnet tool restore
172+
- name: InspectCode
173+
shell: pwsh
174+
run: |
175+
$inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml'
176+
Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
177+
dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
178+
- name: Verify outcome
179+
shell: pwsh
180+
run: |
181+
[xml]$xml = Get-Content $env:INSPECT_CODE_OUTPUT_PATH
182+
if ($xml.report.Issues -and $xml.report.Issues.Project) {
183+
foreach ($project in $xml.report.Issues.Project) {
184+
if ($project.Issue.Count -gt 0) {
185+
$project.ForEach({
186+
Write-Output "`nProject $($project.Name)"
187+
$failed = $true
188+
189+
$_.Issue.ForEach({
190+
$issueType = $xml.report.IssueTypes.SelectSingleNode("IssueType[@Id='$($_.TypeId)']")
191+
$severity = $_.Severity ?? $issueType.Severity
192+
193+
Write-Output "[$severity] $($_.File):$($_.Line) $($_.TypeId): $($_.Message)"
194+
})
195+
})
196+
}
197+
}
198+
199+
if ($failed) {
200+
Write-Error "One or more projects failed code inspection."
201+
}
202+
}
203+
204+
cleanup-code:
205+
timeout-minutes: 60
206+
strategy:
207+
fail-fast: false
208+
matrix:
209+
os: [ubuntu-latest, windows-latest, macos-latest]
210+
runs-on: ${{ matrix.os }}
211+
permissions:
212+
contents: read
213+
steps:
214+
- name: Git checkout
215+
uses: actions/checkout@v4
216+
with:
217+
fetch-depth: 2
218+
- name: Setup .NET
219+
uses: actions/setup-dotnet@v3
220+
with:
221+
dotnet-version: 6.0.x
222+
- name: Restore tools
223+
run: |
224+
dotnet tool restore
225+
- name: Restore packages
226+
run: |
227+
dotnet restore
228+
- name: CleanupCode (on PR diff)
229+
if: github.event_name == 'pull_request'
230+
shell: pwsh
231+
run: |
232+
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
233+
# The below works because HEAD is detached (at the merge commit), so HEAD~1 is at the base branch. When a PR contains no commits, this job will not run.
234+
$headCommitHash = git rev-parse HEAD
235+
$baseCommitHash = git rev-parse HEAD~1
236+
237+
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
238+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
239+
- name: CleanupCode (on branch)
240+
if: github.event_name == 'push'
241+
shell: pwsh
242+
run: |
243+
Write-Output "Running code cleanup on all files."
244+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --fail-on-diff --print-diff
245+
246+
publish:
247+
timeout-minutes: 60
248+
runs-on: ubuntu-latest
249+
needs: [ build-and-test, inspect-code, cleanup-code ]
250+
if: ${{ !github.event.pull_request.head.repo.fork }}
251+
permissions:
252+
packages: write
253+
contents: write
254+
steps:
255+
- name: Download artifacts
256+
uses: actions/download-artifact@v3
257+
- name: Publish to GitHub Packages
258+
if: github.event_name == 'push'
259+
env:
260+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
261+
shell: pwsh
262+
run: |
263+
dotnet nuget add source --username 'json-api-dotnet' --password "$env:GITHUB_TOKEN" --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
264+
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:GITHUB_TOKEN" --source 'github'
265+
- name: Publish documentation
266+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
267+
uses: peaceiris/actions-gh-pages@v3
268+
with:
269+
github_token: ${{ secrets.GITHUB_TOKEN }}
270+
publish_branch: gh-pages
271+
publish_dir: ./documentation
272+
commit_message: 'Auto-generated documentation from'
273+
- name: Publish to NuGet
274+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
275+
env:
276+
NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
277+
shell: pwsh
278+
run: |
279+
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org'

.github/workflows/qodana.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# https://www.jetbrains.com/help/qodana/cloud-forward-reports.html#cloud-forward-reports-github-actions
2+
3+
name: Qodana
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
push:
8+
branches:
9+
- master
10+
- 'release/*'
11+
12+
jobs:
13+
qodana:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
checks: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
23+
fetch-depth: 0 # a full history is required for pull request analysis
24+
- name: 'Qodana Scan'
25+
uses: JetBrains/[email protected]
26+
env:
27+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
28+
- name: Upload results to artifacts on failure
29+
if: failure()
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: qodana_results
33+
path: ${{ runner.temp }}/qodana/results

0 commit comments

Comments
 (0)