From b43ce4f6cf50ef9de0e82ebb4845221e1e7a4ce2 Mon Sep 17 00:00:00 2001 From: n0099 Date: Sat, 23 Mar 2024 18:17:11 +0800 Subject: [PATCH] * change the hardcoded input `dotnet-version`of `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 worker-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: latestMinor` $ dotnet new tool-manifest && dotnet tool install JetBrains.ReSharper.GlobalTools @ c# --- .github/actions/c#/action.yml | 9 +++++---- .github/workflows/c#.yml | 6 ++++++ c#/.config/dotnet-tools.json | 12 ++++++++++++ c#/global.json | 6 ++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 c#/.config/dotnet-tools.json create mode 100644 c#/global.json diff --git a/.github/actions/c#/action.yml b/.github/actions/c#/action.yml index 4e6bc2e4..dda8701c 100644 --- a/.github/actions/c#/action.yml +++ b/.github/actions/c#/action.yml @@ -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 @@ -19,13 +19,14 @@ runs: uses: actions/cache/restore@v4 with: path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + key: ${{ runner.os }}-nuget-${{ hashFiles('c#/*/packages.lock.json') }}-${{ hashFiles('c#/.config/dotnet-tools.json') }} restore-keys: ${{ runner.os }}-nuget- - - run: dotnet new globaljson --sdk-version 7.0.405 + - run: dotnet restore --locked-mode working-directory: c# shell: bash - - run: dotnet restore + + - run: dotnet tool restore working-directory: c# shell: bash diff --git a/.github/workflows/c#.yml b/.github/workflows/c#.yml index 82973276..c34d2a3e 100644 --- a/.github/workflows/c#.yml +++ b/.github/workflows/c#.yml @@ -11,7 +11,13 @@ 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 }} + - run: dotnet tool run jb inspectcode --build -f=sarif -o=sarif.json tbm.sln + - uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: sarif.json diff --git a/c#/.config/dotnet-tools.json b/c#/.config/dotnet-tools.json new file mode 100644 index 00000000..c3d2a359 --- /dev/null +++ b/c#/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "jetbrains.resharper.globaltools": { + "version": "2023.3.4", + "commands": [ + "jb" + ] + } + } +} \ No newline at end of file diff --git a/c#/global.json b/c#/global.json new file mode 100644 index 00000000..7900c220 --- /dev/null +++ b/c#/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.0", + "rollForward": "latestMinor" + } +}