Skip to content

Commit 8160e67

Browse files
committed
fix: forsøker å fikse SARIF filen hvis code analyzer returnerer tomt (dersom alle violations er fikset)
1 parent 9ff62d6 commit 8160e67

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/ciStaticCodeValidation.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,40 @@ jobs:
9999
run-arguments: --workspace ${{ steps.paths.outputs.sfCodeAnalyzerPathToValidate }} --view detail --output-file sfca_results.html --output-file sfca_results.json --output-file code-analyzer-report.sarif
100100
results-artifact-name: salesforce-code-analyzer-results
101101

102+
# Code Analyser generates an empty SARIF file if no violations are found.
103+
# In that case this step ensures that the SARIF file is valid and contains a default structure.
104+
# This is required for the SARIF file to be uploaded to GitHub.
105+
- name: Check SARIF file
106+
if: ${{ !cancelled() && steps.paths.outcome == 'success' }}
107+
run: |
108+
echo "::group::Check SARIF file"
109+
jq --arg wd "$GITHUB_WORKSPACE" '
110+
if .runs == [] then
111+
.runs = [
112+
{
113+
"tool": {
114+
"driver": {
115+
"name": "pmd",
116+
"rules": []
117+
}
118+
},
119+
"results": [],
120+
"invocations": [
121+
{
122+
"executionSuccessful": true,
123+
"workingDirectory": {
124+
"uri": $wd
125+
}
126+
}
127+
]
128+
}
129+
]
130+
else
131+
.
132+
end
133+
' code-analyzer-report.sarif > code-analyzer-report.sarif
134+
echo "::endgroup::"
135+
102136
- name: Upload SARIF file
103137
uses: github/codeql-action/upload-sarif@7e3036b9cd87fc26dd06747b7aa4b96c27aaef3a
104138
if: ${{ !cancelled() && steps.paths.outcome == 'success' && github.ref_name == 'main' }}

0 commit comments

Comments
 (0)