Skip to content

Commit

Permalink
Report analyzer problem in GitHub (#2962)
Browse files Browse the repository at this point in the history
* Initial github script interaction.

* Only run on Linux?

* Only do ubuntu for now.

* Get pwd from cwd.

* Read messages

* Define existsSync before using it.

* Create annotations from messages.

* Touch target file

* Touch file again on reported lines.

* Add code and options

* Revert FantomasToolLocator.fs

* Upload sarif file in action.

* Update analyzer SDK

* Restore OS matrix

* Don't additionally build the client.
  • Loading branch information
nojaf authored Oct 17, 2023
1 parent c7b3918 commit 3026758
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
"fsharp-analyzers": {
"version": "0.15.0",
"version": "0.16.0",
"commands": [
"fsharp-analyzers"
]
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
- name: "trigger fantomas-tools action"
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/main'
run: "curl -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token ${{secrets.FANTOMAS_TOOLS_TOKEN}}' --request POST --data '{\"event_type\": \"fantomas-commit-on-main\"}' https://api.github.com/repos/fsprojects/fantomas-tools/dispatches"
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
if: matrix.os == 'ubuntu-latest'
with:
sarif_file: analysis.sarif
- name: "Documentation"
if: matrix.os == 'windows-latest' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,5 @@ tests/.repositories/**
!tests/.repositories/Directory.Build.props

# Analyzer files
.analyzerpackages
.analyzerpackages
analysis.sarif
2 changes: 1 addition & 1 deletion analyzers/analyzers.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageDownload Include="G-Research.FSharp.Analyzers" Version="[0.1.3]" />
<PackageDownload Include="G-Research.FSharp.Analyzers" Version="[0.1.4]" />
</ItemGroup>

</Project>
Expand Down
11 changes: 9 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ let analyzersVersion =
matches.Groups[1].Value

let analyzeProjects (projectPaths: string seq) =
$"""dotnet fsharp-analyzers --project {String.concat " " projectPaths} --analyzers-path ./.analyzerpackages/g-research.fsharp.analyzers/{analyzersVersion} --verbose --fail-on-warnings GRA-STRING-001 GRA-STRING-002 GRA-STRING-003 GRA-UNIONCASE-001"""
let projects = String.concat " " projectPaths
let analyzerPath =
$"./.analyzerpackages/g-research.fsharp.analyzers/{analyzersVersion}"
let failOnWarnings =
"GRA-STRING-001 GRA-STRING-002 GRA-STRING-003 GRA-UNIONCASE-001"
let excludeAnalyzers = "PartialAppAnalyzer"
let report = "./analysis.sarif"
$"dotnet fsharp-analyzers --project %s{projects} --analyzers-path \"%s{analyzerPath}\" --verbose --fail-on-warnings %s{failOnWarnings} --report %s{report} --exclude-analyzer %s{excludeAnalyzers}"

pipeline "Build" {
workingDir __SOURCE_DIRECTORY__
Expand All @@ -87,7 +94,7 @@ pipeline "Build" {
)
}
stage "CheckFormat" { run "dotnet fantomas src docs build.fsx --check" }
stage "RestoreAnalyzers" { run $"dotnet restore {analyzersProjectPath}" }
stage "RestoreAnalyzers" { run $"dotnet restore %s{analyzersProjectPath}" }
stage "Build" { run "dotnet build -c Release" }
stage "Analyze" {
envVars
Expand Down

0 comments on commit 3026758

Please sign in to comment.