action.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: Run PVS-Studio Analysis
  2. inputs:
  3. pvsUsername:
  4. description: PVS-Studio License Username
  5. required: true
  6. pvsKey:
  7. description: PVS-Studio License Key
  8. required: true
  9. target:
  10. description: Build Target
  11. required: true
  12. config:
  13. description: Build Configuration
  14. required: true
  15. runs:
  16. using: composite
  17. steps:
  18. - name: Setup PVS-Studio
  19. shell: pwsh
  20. run: |
  21. choco install pvs-studio --version=7.30.81185.980 -y --no-progress
  22. - name: Activate PVS-Studio
  23. shell: pwsh
  24. run: |
  25. . ${env:GITHUB_ACTION_PATH}\Invoke-External.ps1
  26. Invoke-External "C:\Program Files (x86)\PVS-Studio\PVS-Studio_Cmd.exe" credentials -u ${{ inputs.pvsUsername }} -n ${{ inputs.pvsKey }}
  27. - name: Run PVS-Studio Analysis
  28. shell: pwsh
  29. run: |
  30. [flags()] Enum PVSErrorCodes {
  31. Success = 0
  32. AnalyzerCrash = 1
  33. GenericError = 2
  34. InvalidCommandLine = 4
  35. FileNotFound = 8
  36. ConfigurationNotFound = 16
  37. InvalidProject = 32
  38. InvalidExtension = 64
  39. LicenseInvalid = 128
  40. CodeErrorsFound = 256
  41. SuppressionFailed = 512
  42. LicenseExpiringSoon = 1024
  43. }
  44. $pvsParams = @(
  45. "--progress"
  46. "--disableLicenseExpirationCheck"
  47. "-p", "${{ inputs.target }}"
  48. "-c", "${{ inputs.config }}"
  49. "-t", "${{ github.workspace }}\build_x64\obs-studio.sln"
  50. "-o", "${{ github.workspace }}\analysis.plog"
  51. "-C", "${env:GITHUB_ACTION_PATH}\obs.pvsconfig"
  52. )
  53. & "C:\Program Files (x86)\PVS-Studio\PVS-Studio_Cmd.exe" @pvsParams
  54. # Success, LicenseExpiringSoon, and CodeErrorsFound are fine as error codes, we only care if it is anything but those
  55. $pvs_result = $LASTEXITCODE -band (-bnot ([PVSErrorCodes]::CodeErrorsFound -bor [PVSErrorCodes]::LicenseExpiringSoon))
  56. if ($pvs_result -ne 0) {
  57. Write-Output "PVS-Studio Errors: $([PVSErrorCodes]$pvs_result)"
  58. }
  59. exit $pvs_result
  60. - name: Convert Analysis to SARIF
  61. shell: pwsh
  62. run: |
  63. . ${env:GITHUB_ACTION_PATH}\Invoke-External.ps1
  64. $conversionParams = @(
  65. "-a", "GA:1,2",
  66. "-d", "V1042,Renew"
  67. "-t", "Sarif"
  68. "${{ github.workspace }}\analysis.plog"
  69. )
  70. Invoke-External "C:\Program Files (x86)\PVS-Studio\PlogConverter.exe" @conversionParams
  71. - name: Upload PVS-Studio Logs
  72. uses: actions/upload-artifact@v4
  73. with:
  74. name: 'pvs-analysis-log'
  75. path: |
  76. ${{ github.workspace }}/analysis.plog
  77. ${{ github.workspace }}/analysis.plog.sarif
  78. - name: Upload PVS-Studio Report
  79. uses: github/codeql-action/upload-sarif@v3
  80. with:
  81. sarif_file: "${{ github.workspace }}/analysis.plog.sarif"
  82. category: 'PVS-Studio (Windows)'