From 796df5e6cca7334e3d922d7b149294c0396049e3 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Sun, 14 Jul 2024 18:49:28 -0500 Subject: [PATCH 1/3] Added fsharp analyzers in response to seeing Follow-up from "Minor code optimisation #567" #577 --- .config/dotnet-tools.json | 6 ++++++ Directory.Build.targets | 8 ++++++++ Directory.Solution.targets | 9 +++++++++ src/Directory.Build.props | 17 +++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 Directory.Build.targets create mode 100644 Directory.Solution.targets create mode 100644 src/Directory.Build.props diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index f20af560..716799c8 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "fantomas" ] + }, + "fsharp-analyzers": { + "version": "0.26.0", + "commands": [ + "fsharp-analyzers" + ] } } } \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 00000000..198f1d91 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,8 @@ + + + --analyzers-path "$(PkgG-Research_FSharp_Analyzers)" + $(FSharpAnalyzersOtherFlags) --analyzers-path "$(PkgIonide_Analyzers)" + $(FSharpAnalyzersOtherFlags) --configuration $(Configuration) + $(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer + + \ No newline at end of file diff --git a/Directory.Solution.targets b/Directory.Solution.targets new file mode 100644 index 00000000..33bbc1dd --- /dev/null +++ b/Directory.Solution.targets @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..a90647cc --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,17 @@ + + + + + build + all + + + analyzers + all + + + analyzers + all + + + From a1b20526ec3939efd92db42bc296f0f4d2a17b55 Mon Sep 17 00:00:00 2001 From: 1eyewonder Date: Sun, 14 Jul 2024 18:55:26 -0500 Subject: [PATCH 2/3] Moved packages to proj file instead of props file --- src/Directory.Build.props | 17 ----------------- src/Giraffe/Giraffe.fsproj | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 src/Directory.Build.props diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index a90647cc..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,17 +0,0 @@ - - - - - build - all - - - analyzers - all - - - analyzers - all - - - diff --git a/src/Giraffe/Giraffe.fsproj b/src/Giraffe/Giraffe.fsproj index 85be607d..0e4c00f2 100644 --- a/src/Giraffe/Giraffe.fsproj +++ b/src/Giraffe/Giraffe.fsproj @@ -49,6 +49,20 @@ + + + build + all + + + analyzers + all + + + analyzers + all + + From 64731dfb0000da00b60905db248eb0ded9e970ff Mon Sep 17 00:00:00 2001 From: 64J0 Date: Wed, 24 Jul 2024 22:00:14 -0300 Subject: [PATCH 3/3] add analyzers CI workflow and define the report name at Directory.Build.Targets --- .github/workflows/build-and-test.yml | 28 +++++++++++++++++++++++++++- Directory.Build.targets | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9a991a75..5f489563 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -38,4 +38,30 @@ jobs: - name: Build run: dotnet build -c Release --no-restore - name: Test - run: dotnet test -c Release \ No newline at end of file + run: dotnet test -c Release + + analyzers: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + - name: Restore tools + run: dotnet tool restore + - name: Build solution + run: dotnet build -c Release Giraffe.sln + + - name: Run Analyzers + run: dotnet msbuild /t:AnalyzeFSharpProject src/Giraffe/Giraffe.fsproj + # This is important, you want to continue your Action even if you found problems. + # As you always want the report to upload + continue-on-error: true + # checkout code, build, run analyzers, ... + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v2 + with: + # You can also specify the path to a folder for `sarif_file` + sarif_file: ./src/Giraffe/analysis.sarif \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets index 198f1d91..e2e6bdfa 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -4,5 +4,6 @@ $(FSharpAnalyzersOtherFlags) --analyzers-path "$(PkgIonide_Analyzers)" $(FSharpAnalyzersOtherFlags) --configuration $(Configuration) $(FSharpAnalyzersOtherFlags) --exclude-analyzers PartialAppAnalyzer + $(FSharpAnalyzersOtherFlags) --report "analysis.sarif" \ No newline at end of file