Skip to content

Commit f112eb3

Browse files
committed
Update Qodana workflow, cleanup
1 parent e10a078 commit f112eb3

File tree

3 files changed

+61
-63
lines changed

3 files changed

+61
-63
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
name: Build
1010

1111
on:
12-
push:
13-
branches: [ 'master', 'release/**' ]
12+
workflow_dispatch:
1413
pull_request:
14+
push:
1515
branches: [ 'master', 'release/**' ]
1616
release:
1717
types: [published]
@@ -57,17 +57,15 @@ jobs:
5757
- name: Git checkout
5858
uses: actions/checkout@v4
5959
- name: Restore tools
60-
run: |
61-
dotnet tool restore
60+
run: dotnet tool restore
6261
- name: Restore packages
63-
run: |
64-
dotnet restore
62+
run: dotnet restore
6563
- name: Calculate version suffix
6664
shell: pwsh
6765
run: |
6866
if ($env:GITHUB_REF_TYPE -eq 'tag') {
6967
# Get the version prefix/suffix from the git tag. For example: 'v1.0.0-preview1-final' => '1.0.0' and 'preview1-final'
70-
$segments = $env:GITHUB_REF_NAME -split "-"
68+
$segments = $env:GITHUB_REF_NAME -split '-'
7169
$versionPrefix = $segments[0].TrimStart('v')
7270
$versionSuffix = $segments.Length -eq 1 ? '' : $segments[1..$($segments.Length - 1)] -join '-'
7371
@@ -93,9 +91,7 @@ jobs:
9391
Write-Output "Using version suffix: $versionSuffix"
9492
Write-Output "PACKAGE_VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
9593
- name: Build
96-
shell: pwsh
97-
run: |
98-
dotnet build --no-restore --configuration Release /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
94+
run: dotnet build --no-restore --configuration Release /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
9995
- name: Test
10096
env:
10197
# Override log levels, to reduce logging output when running tests in ci-build.
@@ -104,30 +100,27 @@ jobs:
104100
Logging__LogLevel__Microsoft.Extensions.Hosting.Internal.Host: 'None'
105101
Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command: 'None'
106102
Logging__LogLevel__JsonApiDotNetCore: 'None'
107-
run: |
108-
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
103+
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
109104
- name: Upload coverage to codecov.io
110-
if: matrix.os == 'ubuntu-latest'
105+
if: ${{ matrix.os == 'ubuntu-latest' }}
111106
env:
112107
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
113108
uses: codecov/codecov-action@v5
114109
with:
115110
fail_ci_if_error: true
116111
verbose: true
117112
- name: Generate packages
118-
shell: pwsh
119-
run: |
120-
dotnet pack --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages /p:VersionSuffix=$env:PACKAGE_VERSION_SUFFIX
113+
run: dotnet pack --no-build --configuration Release --output ${{ env.GITHUB_WORKSPACE }}/artifacts/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}
121114
- name: Upload packages to artifacts
122-
if: matrix.os == 'ubuntu-latest'
115+
if: ${{ matrix.os == 'ubuntu-latest' }}
123116
uses: actions/upload-artifact@v4
124117
with:
125118
name: packages
126119
path: artifacts/packages
127120
- name: Generate documentation
128121
shell: pwsh
129122
env:
130-
# This contains the git tag name on release; in that case we build the docs without publishing them.
123+
# This contains the git tag name on release; in that case, we build the docs without publishing them.
131124
DOCFX_SOURCE_BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
132125
run: |
133126
cd docs
@@ -142,7 +135,7 @@ jobs:
142135
New-Item -Force _site/styles -ItemType Directory | Out-Null
143136
Copy-Item -Recurse home/assets/* _site/styles/
144137
- name: Upload documentation to artifacts
145-
if: matrix.os == 'ubuntu-latest'
138+
if: ${{ matrix.os == 'ubuntu-latest' }}
146139
uses: actions/upload-artifact@v4
147140
with:
148141
name: documentation
@@ -169,8 +162,7 @@ jobs:
169162
- name: Git checkout
170163
uses: actions/checkout@v4
171164
- name: Restore tools
172-
run: |
173-
dotnet tool restore
165+
run: dotnet tool restore
174166
- name: InspectCode
175167
shell: pwsh
176168
run: |
@@ -199,7 +191,7 @@ jobs:
199191
}
200192
201193
if ($failed) {
202-
Write-Error "One or more projects failed code inspection."
194+
Write-Error 'One or more projects failed code inspection.'
203195
}
204196
}
205197
@@ -226,13 +218,11 @@ jobs:
226218
with:
227219
fetch-depth: 2
228220
- name: Restore tools
229-
run: |
230-
dotnet tool restore
221+
run: dotnet tool restore
231222
- name: Restore packages
232-
run: |
233-
dotnet restore
223+
run: dotnet restore
234224
- name: CleanupCode (on PR diff)
235-
if: github.event_name == 'pull_request'
225+
if: ${{ github.event_name == 'pull_request' }}
236226
shell: pwsh
237227
run: |
238228
# 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.
@@ -243,10 +233,10 @@ jobs:
243233
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
244234
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
245235
- name: CleanupCode (on branch)
246-
if: github.event_name == 'push' || github.event_name == 'release'
236+
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
247237
shell: pwsh
248238
run: |
249-
Write-Output "Running code cleanup on all files."
239+
Write-Output 'Running code cleanup on all files.'
250240
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN --fail-on-diff --print-diff
251241
252242
publish:
@@ -263,33 +253,23 @@ jobs:
263253
- name: Download artifacts
264254
uses: actions/download-artifact@v4
265255
- name: Publish to GitHub Packages
266-
if: github.event_name == 'push' || github.event_name == 'release'
267-
env:
268-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
269-
shell: pwsh
256+
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
270257
run: |
271-
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'
272-
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:GITHUB_TOKEN" --source 'github'
258+
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'
259+
dotnet nuget push '${{ env.GITHUB_WORKSPACE }}/packages/*.nupkg' --api-key '${{ secrets.GITHUB_TOKEN }}' --source 'github'
273260
- name: Publish to feedz.io
274-
if: github.event_name == 'push' || github.event_name == 'release'
275-
env:
276-
FEEDZ_IO_API_KEY: ${{ secrets.FEEDZ_IO_API_KEY }}
277-
shell: pwsh
261+
if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
278262
run: |
279263
dotnet nuget add source --name 'feedz-io' 'https://f.feedz.io/json-api-dotnet/jsonapidotnetcore/nuget/index.json'
280-
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:FEEDZ_IO_API_KEY" --source 'feedz-io'
264+
dotnet nuget push '${{ env.GITHUB_WORKSPACE }}/packages/*.nupkg' --api-key '${{ secrets.FEEDZ_IO_API_KEY }}' --source 'feedz-io'
281265
- name: Publish documentation
282-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
266+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
283267
uses: peaceiris/actions-gh-pages@v4
284268
with:
285269
github_token: ${{ secrets.GITHUB_TOKEN }}
286270
publish_branch: gh-pages
287271
publish_dir: ./documentation
288272
commit_message: 'Auto-generated documentation from'
289273
- name: Publish to NuGet
290-
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
291-
env:
292-
NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
293-
shell: pwsh
294-
run: |
295-
dotnet nuget push "$env:GITHUB_WORKSPACE/packages/*.nupkg" --api-key "$env:NUGET_ORG_API_KEY" --source 'nuget.org' --skip-duplicate
274+
if: ${{ github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') }}
275+
run: dotnet nuget push '${{ env.GITHUB_WORKSPACE }}/packages/*.nupkg' --api-key '${{ secrets.NUGET_ORG_API_KEY }}' --source 'nuget.org' --skip-duplicate

.github/workflows/codeql.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: "CodeQL"
22

33
on:
4-
push:
5-
branches: [ 'master', 'release/**' ]
4+
workflow_dispatch:
65
pull_request:
7-
# The branches below must be a subset of the branches above
6+
push:
87
branches: [ 'master', 'release/**' ]
98
schedule:
109
- cron: '0 0 * * 5'

.github/workflows/qodana.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# https://www.jetbrains.com/help/qodana/cloud-forward-reports.html#cloud-forward-reports-github-actions
2-
31
name: Qodana
42
on:
53
workflow_dispatch:
64
pull_request:
75
push:
8-
branches:
9-
- master
10-
- 'release/*'
6+
branches: [ 'master', 'release/**' ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
DOTNET_NOLOGO: true
14+
DOTNET_CLI_TELEMETRY_OPTOUT: true
1115

1216
jobs:
1317
qodana:
@@ -17,17 +21,32 @@ jobs:
1721
pull-requests: write
1822
checks: write
1923
steps:
20-
- uses: actions/checkout@v4
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: |
28+
8.0.*
29+
9.0.*
30+
- name: Git checkout
31+
uses: actions/checkout@v4
2132
with:
2233
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
2334
fetch-depth: 0 # a full history is required for pull request analysis
24-
- name: 'Qodana Scan'
25-
uses: JetBrains/[email protected]
35+
- name: Restore tools
36+
run: dotnet tool restore
37+
- name: Restore packages
38+
run: dotnet restore
39+
- name: Build
40+
run: dotnet build --no-restore --configuration Release
41+
- name: Qodana scan
42+
uses: JetBrains/[email protected]
43+
with:
44+
args: --ide,QDNET,--profile-name,qodana.recommended,--configuration,Release,--apply-fixes
45+
push-fixes: pull-request
46+
upload-result: true
2647
env:
2748
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
28-
- name: Upload results to artifacts on failure
29-
if: failure()
30-
uses: actions/upload-artifact@v4
49+
- name: Upload SARIF report
50+
uses: github/codeql-action/upload-sarif@v3
3151
with:
32-
name: qodana_results
33-
path: ${{ runner.temp }}/qodana/results
52+
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json

0 commit comments

Comments
 (0)