Skip to content

Commit

Permalink
* remove run: dotnet new globaljson in favor of changing the hardco…
Browse files Browse the repository at this point in the history
…ded 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`
@ workflows/c#.yml
@ .github

$ dotnet new globaljson --sdk-version 8.0.0 # then set `rollForward: latestFeature`
@ c#
  • Loading branch information
n0099 committed Mar 23, 2024
1 parent fcd4971 commit 4fd17dc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/actions/c#/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
submodules: true
- uses: actions/setup-dotnet@v4
with: # https://github.com/actions/setup-dotnet/tree/v4
dotnet-version: 7
global-json-file: c#/global.json
# cache: true
# # https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
# cache-dependency-path: ${{ github.workspace }}/c#/*/packages.lock.json
Expand All @@ -18,14 +18,15 @@ runs:
- id: cache-restore
uses: actions/cache/restore@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
path: |
${{ github.workspace }}/.nuget/packages
${{ github.workspace }}/.resharper
key: |
${{ runner.os }}-nuget-
${{ hashFiles('c#/*/packages.lock.json') }}-
restore-keys: ${{ runner.os }}-nuget-

- run: dotnet new globaljson --sdk-version 7.0.405
working-directory: c#
shell: bash
- run: dotnet restore
- run: dotnet restore --locked-mode
working-directory: c#
shell: bash

Expand All @@ -34,5 +35,7 @@ runs:
- uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ~/.nuget/packages
path: |
${{ github.workspace }}/.nuget/packages
${{ github.workspace }}/.resharper
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
15 changes: 15 additions & 0 deletions .github/workflows/c#.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@ jobs:
strategy:
matrix:
project: [crawler, imagePipeline, shared, tbClient]
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/c#
- run: dotnet build --no-restore -c Debug ${{ matrix.project }}

ReSharper:
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/c#
- uses: muno92/resharper_inspectcode@v1
with:
solutionPath: c#/tbm.sln
workingDirectory: c#
cachesHome: ${{ github.workspace }}/.resharper
6 changes: 6 additions & 0 deletions c#/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestFeature" // https://github.com/actions/setup-dotnet/pull/481
}
}

0 comments on commit 4fd17dc

Please sign in to comment.