3131 strategy :
3232 fail-fast : false
3333 matrix :
34- os : [ ubuntu-latest ]
34+ os : [ ubuntu-latest, windows-latest, macos-latest ]
3535 runs-on : ${{ matrix.os }}
3636 permissions :
3737 contents : read
9696 Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9797 - name : Build
9898 run : dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
99+ - name : Test
100+ env :
101+ # Override log levels, to reduce logging output when running tests in ci-build.
102+ Logging__LogLevel__Microsoft.Hosting.Lifetime : ' None'
103+ Logging__LogLevel__Microsoft.AspNetCore.Hosting.Diagnostics : ' None'
104+ Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host : ' None'
105+ Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command : ' None'
106+ Logging__LogLevel__JsonApiDotNetCore : ' None'
107+ run : dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;annotations-title=@test (@framework);annotations-message=@error\n@trace;summary-include-passed=false"
108+ - name : Upload coverage to codecov.io
109+ if : ${{ matrix.os == 'ubuntu-latest' }}
110+ env :
111+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
112+ uses : codecov/codecov-action@v6
113+ with :
114+ fail_ci_if_error : true
115+ verbose : true
99116 - name : Generate packages
100117 run : dotnet pack --no-build --configuration Release --output ${{ github.workspace }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
101118 - name : Upload packages to artifacts
@@ -130,10 +147,123 @@ jobs:
130147 name : documentation
131148 path : docs/_site
132149
150+ inspect-code :
151+ timeout-minutes : 60
152+ strategy :
153+ fail-fast : false
154+ matrix :
155+ os : [ ubuntu-latest, windows-latest, macos-latest ]
156+ runs-on : ${{ matrix.os }}
157+ permissions :
158+ contents : read
159+ steps :
160+ - name : Tune GitHub-hosted runner network
161+ uses : smorimoto/tune-github-hosted-runner-network@v1
162+ - name : Setup .NET
163+ uses : actions/setup-dotnet@v5
164+ with :
165+ dotnet-version : |
166+ 8.0.*
167+ 9.0.*
168+ 10.0.*
169+ - name : Git checkout
170+ uses : actions/checkout@v6
171+ with :
172+ persist-credentials : false
173+ - name : Restore tools
174+ run : dotnet tool restore
175+ - name : InspectCode
176+ shell : pwsh
177+ run : |
178+ $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml'
179+ Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
180+ dotnet jb inspectcode --version
181+ dotnet jb inspectcode $env:SOLUTION_FILE --build --no-updates --dotnetcoresdk=$(dotnet --version) --output="$inspectCodeOutputPath" --format="xml" --settings=WarningSeverities.DotSettings --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false;ContinuousIntegrationBuild=false" --severity=WARNING --verbosity=WARN --disable-settings-layers="GlobalAll;GlobalPerProduct;SolutionPersonal;ProjectPersonal"
182+ - name : Upload output to artifacts
183+ uses : actions/upload-artifact@v7
184+ with :
185+ name : InspectCode-${{ matrix.os }}
186+ path : ${{ env.INSPECT_CODE_OUTPUT_PATH }}
187+ - name : Verify outcome
188+ shell : pwsh
189+ run : |
190+ [xml]$xml = Get-Content $env:INSPECT_CODE_OUTPUT_PATH
191+ if ($xml.report.Issues -and $xml.report.Issues.Project) {
192+ foreach ($project in $xml.report.Issues.Project) {
193+ if ($project.Issue.Count -gt 0) {
194+ $project.ForEach({
195+ Write-Output "`nProject $($project.Name)"
196+ $failed = $true
197+
198+ $_.Issue.ForEach({
199+ $issueType = $xml.report.IssueTypes.SelectSingleNode("IssueType[@Id='$($_.TypeId)']")
200+ $severity = $_.Severity ?? $issueType.Severity
201+
202+ Write-Output "[$severity] ($($_.TargetFramework)) $($_.File):$($_.Line) $($_.TypeId): $($_.Message)"
203+ })
204+ })
205+ }
206+ }
207+
208+ if ($failed) {
209+ Write-Error 'One or more projects failed code inspection.'
210+ }
211+ }
212+
213+ cleanup-code :
214+ timeout-minutes : 90
215+ strategy :
216+ fail-fast : false
217+ matrix :
218+ os : [ ubuntu-latest, windows-latest, macos-latest ]
219+ runs-on : ${{ matrix.os }}
220+ permissions :
221+ contents : read
222+ steps :
223+ - name : Tune GitHub-hosted runner network
224+ uses : smorimoto/tune-github-hosted-runner-network@v1
225+ - name : Setup .NET
226+ uses : actions/setup-dotnet@v5
227+ with :
228+ dotnet-version : |
229+ 8.0.*
230+ 9.0.*
231+ 10.0.*
232+ - name : Git checkout
233+ uses : actions/checkout@v6
234+ with :
235+ persist-credentials : false
236+ fetch-depth : 2
237+ - name : Restore tools
238+ run : dotnet tool restore
239+ - name : Restore packages
240+ run : dotnet restore /p:NuGetAudit=false
241+ - name : Build
242+ run : dotnet build --no-restore --configuration Release /p:RunAnalyzers=false
243+ - name : CleanupCode (on PR diff)
244+ if : ${{ github.event_name == 'pull_request' }}
245+ shell : pwsh
246+ run : |
247+ # 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.
248+ # 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.
249+ $headCommitHash = git rev-parse HEAD
250+ $baseCommitHash = git rev-parse HEAD~1
251+
252+ Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
253+ dotnet jb cleanupcode --version
254+ dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --no-updates --jb --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false" --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
255+ - name : CleanupCode (on branch)
256+ if : ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
257+ shell : pwsh
258+ run : |
259+ Write-Output 'Running code cleanup on all files.'
260+ dotnet jb cleanupcode --version
261+ dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --no-updates --jb --properties:"Configuration=Release;RunAnalyzers=false;NuGetAudit=false" --jb --verbosity=WARN --fail-on-diff --print-diff
262+
133263 publish :
134264 timeout-minutes : 60
135265 runs-on : ubuntu-latest
136- needs : [ build-and-test ]
266+ needs : [ build-and-test, inspect-code, cleanup-code ]
137267 if : ${{ !github.event.pull_request.head.repo.fork }}
138268 permissions :
139269 packages : write
@@ -157,7 +287,7 @@ jobs:
157287 dotnet nuget add source --username 'json-api-dotnet' --password '${{ secrets.GITHUB_TOKEN }}' --store-password-in-clear-text --name 'github' 'https://nuget.pkg.github.com/json-api-dotnet/index.json'
158288 dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'github' --skip-duplicate
159289 - name : Publish to feedz.io
160- # if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
290+ if : ${{ github.event_name == 'push' || github.event_name == 'release' }}
161291 run : |
162292 dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json'
163293 dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key '${{ secrets.FEEDZ_IO_API_KEY }}' --source 'feedz-io' --skip-duplicate
0 commit comments