Skip to content

Commit

Permalink
[WIP] Add diagnostics export test
Browse files Browse the repository at this point in the history
  • Loading branch information
angelapwen committed Mar 15, 2023
1 parent 30ddec6 commit b025421
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pr-checks/checks/diagnostics-export.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Diagnostics export"
description: "Tests that diagnostics are exported to SARIF correctly."
versions: ["latest"]
env:
CODEQL_ACTION_EXPORT_DIAGNOSTICS: true
steps:
- uses: ./../action/init
with:
languages: javascript
queries: security-extended
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/analyze
with:
output: "${{ runner.temp }}/results"
upload-database: false
- name: Run `diagnostics add`
shell: bash
env:
run: |
${{steps.init.outputs.codeql-path}} diagnostics add --diagnostics-dir ${{ runner.temp }}/javascript/diagnostic --plaintext-message "Plaintext message" --source-id "lang/diagnostics/example" --source-name "Diagnostic name"
- name: Upload SARIF
uses: actions/upload-artifact@v3
with:
name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
path: "${{ runner.temp }}/results/javascript.sarif"
retention-days: 7
# TODO(angelapwen): fill out below
# https://github.com/github/semmle-code/blob/2f75f366dde13256bdd04f60728d1a2eecc4927d/odasa-buildutils/test/src/com/semmle/cli2/diagnostics/AddCommandTests.java#L133
- name: Check diagnostics appear in SARIF
uses: actions/github-script@v6
env:
SARIF_PATH: "${{ runner.temp }}/results/javascript.sarif"
# TODO
with:
script: |
const fs = require('fs');
const path = require('path');
const sarif = JSON.parse(fs.readFileSync(process.env['SARIF_PATH'], 'utf8'));
const run = sarif.runs[0];
core.info(run);

0 comments on commit b025421

Please sign in to comment.