Skip to content

Commit 1e92879

Browse files
committed
* remove run: dotnet new globaljson in favor of changing the hardcoded input dotnet-version of actions/setup-dotnet@v4 to global-json-file
* add `--locked-mode` param for run `dotnet restore` @ actions/c#/action.yml + env `NUGET_PACKAGES` to use runner-level preinstalled NuGet packages + run ReSharper cli over the whole solution via `muno92/resharper_inspectcode@v1`, also restore/save cache around it @ workflows/c#.yml @ .github $ dotnet new globaljson --sdk-version 8.0.0 # then set `rollForward: latestFeature` @ c#
1 parent fcd4971 commit 1e92879

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

.github/actions/c#/action.yml

+6-9
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,21 +18,18 @@ 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') }}
2323
restore-keys: ${{ runner.os }}-nuget-
2424

25-
- run: dotnet new globaljson --sdk-version 7.0.405
26-
working-directory: c#
27-
shell: bash
28-
- run: dotnet restore
25+
- run: dotnet restore --locked-mode
2926
working-directory: c#
3027
shell: bash
3128

3229
# https://github.com/actions/runner/issues/1478
3330
# https://github.com/actions/setup-node/issues/410#issuecomment-1939482965
3431
- uses: actions/cache/save@v4
35-
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
32+
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
3633
with:
37-
path: ~/.nuget/packages
34+
path: ${{ github.workspace }}/.nuget/packages
3835
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

.github/workflows/c#.yml

+33
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,40 @@ 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+
29+
- id: cache-restore
30+
uses: actions/cache/restore@v4
31+
with:
32+
path: |
33+
${{ github.workspace }}/.resharper
34+
~/.dotnet/tools
35+
key: ${{ runner.os }}-resharper-${{ hashFiles('c#/**/*') }}
36+
restore-keys: ${{ runner.os }}-nuget-
37+
38+
- uses: muno92/resharper_inspectcode@v1
39+
with:
40+
solutionPath: c#/tbm.sln
41+
cachesHome: ${{ github.workspace }}/.resharper
42+
43+
# https://github.com/actions/runner/issues/1478
44+
- uses: actions/cache/save@v4
45+
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
46+
with:
47+
path: |
48+
${{ github.workspace }}/.resharper
49+
~/.dotnet/tools
50+
key: ${{ steps.cache-restore.outputs.cache-primary-key }}

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)