Skip to content

Commit a84d8f0

Browse files
committed
* change the hardcoded input dotnet-versionof actions/setup-dotnet@v4 to global-json-file
* add hash for file `c#/.config/dotnet-tools.json` in the input `key` of `actions/cache/restore@v4` * replace the run `dotnet new globaljson` with `dotnet tool restore` * add `--locked-mode` param for run `dotnet restore` @ actions/c#/action.yml + env `NUGET_PACKAGES` to use runner-level preinstalled NuGet packages + run `jb inspectcode` over the whole solution and upload its output file to `github/codeql-action/upload-sarif@v3` @ workflows/c#.yml @ .github $ dotnet new globaljson --sdk-version 8.0.0 # then set `rollForward: latestFeature` $ dotnet new tool-manifest && dotnet tool install JetBrains.ReSharper.GlobalTools @ c#
1 parent fcd4971 commit a84d8f0

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

.github/actions/c#/action.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
submodules: true
99
- uses: actions/setup-dotnet@v4
1010
with: # https://github.com/actions/setup-dotnet/tree/v4
11-
dotnet-version: 7
11+
global-json-file: c#/global.json
1212
# cache: true
1313
# # https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
1414
# cache-dependency-path: ${{ github.workspace }}/c#/*/packages.lock.json
@@ -18,14 +18,15 @@ runs:
1818
- id: cache-restore
1919
uses: actions/cache/restore@v4
2020
with:
21-
path: ~/.nuget/packages
22-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
21+
path: ${{ github.workspace }}/.nuget/packages
22+
key: ${{ runner.os }}-nuget-${{ hashFiles('c#/*/packages.lock.json') }}-${{ hashFiles('c#/.config/dotnet-tools.json') }}
2323
restore-keys: ${{ runner.os }}-nuget-
2424

25-
- run: dotnet new globaljson --sdk-version 7.0.405
25+
- run: dotnet restore --locked-mode
2626
working-directory: c#
2727
shell: bash
28-
- run: dotnet restore
28+
29+
- run: dotnet tool restore
2930
working-directory: c#
3031
shell: bash
3132

@@ -34,5 +35,5 @@ runs:
3435
- uses: actions/cache/save@v4
3536
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
3637
with:
37-
path: ~/.nuget/packages
38+
path: ${{ github.workspace }}/.nuget/packages
3839
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

.github/workflows/c#.yml

+14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,21 @@ jobs:
1111
strategy:
1212
matrix:
1313
project: [crawler, imagePipeline, shared, tbClient]
14+
env:
15+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
1416
steps:
1517
- uses: actions/checkout@v4
1618
- uses: ./.github/actions/c#
1719
- run: dotnet build --no-restore -c Debug ${{ matrix.project }}
20+
21+
ReSharper:
22+
runs-on: ubuntu-latest
23+
env:
24+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: ./.github/actions/c#
28+
- run: dotnet tool run jb inspectcode --build -f=sarif -o=ReSharper.sarif.json tbm.sln
29+
- uses: github/codeql-action/upload-sarif@v3
30+
with:
31+
sarif_file: c#/ReSharper.sarif.json

c#/.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"jetbrains.resharper.globaltools": {
6+
"version": "2023.3.4",
7+
"commands": [
8+
"jb"
9+
]
10+
}
11+
}
12+
}

c#/global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.0",
4+
"rollForward": "latestFeature" // https://github.com/actions/setup-dotnet/pull/481
5+
}
6+
}

0 commit comments

Comments
 (0)