Skip to content

Commit

Permalink
Check SARIF in test for expected properties
Browse files Browse the repository at this point in the history
  • Loading branch information
angelapwen committed Mar 17, 2023
1 parent 7bda3d2 commit 18c0c1a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/__diagnostics-export.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions pr-checks/checks/diagnostics-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,23 @@ steps:
uses: actions/github-script@v6
env:
SARIF_PATH: "${{ runner.temp }}/results/javascript.sarif"
# TODO
with:
script: |
const fs = require('fs');
const sarif = JSON.parse(fs.readFileSync(process.env['SARIF_PATH'], 'utf8'));
const run = sarif.runs[0];
core.info(JSON.stringify(run));
const toolExecutionNotifications = run.invocations[0].toolExecutionNotifications;
const diagnosticToolExecutionNotification = toolExecutionNotifications[toolExecutionNotifications.length - 1];
if (diagnosticToolExecutionNotification.descriptor.id !== 'lang/diagnostics/example' || diagnosticToolExecutionNotification.message.text !== 'Plaintext message') {
core.setFailed('`toolExecutionNotification` related to this diagnostic was not found in SARIF');
}
const notifications = run.tool.driver.notifications;
const diagnosticNotification = notifications[notifications.length - 1];
if (diagnosticNotification.id !== 'lang/diagnostics/example' || diagnosticNotification.name !== 'lang/diagnostics/example' || diagnosticNotification.fullDescription.text !== 'Diagnostic name') {
core.setFailed('`runs.tools.driver.notification` related to this diagnostic was not found in SARIF');
}
core.info('Finished diagnostic export test');

0 comments on commit 18c0c1a

Please sign in to comment.