Skip to content

Commit

Permalink
.github/workflows/codeql.yml: Add emacs output
Browse files Browse the repository at this point in the history
Updates the workflow to also output files that can be loaded in emacs
to show CodeQL issues (in addition to the existing SARIF output for
standard SARIF viewers).

The emacs files are in the SARIF zip file attached to each "CodeQL"
run (https://github.com/tianocore/edk2/actions/workflows/codeql.yml).

The file name ends with "-emacs.txt". An MdePkg example:
  "codeql-db-mdepkg-debug-0-emacs.txt".

Cc: Joey Vagedes <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Michael D Kinney <[email protected]>
Cc: Sean Brogan <[email protected]>
Signed-off-by: Michael Kubacki <[email protected]>
Acked-by: Michael D Kinney <[email protected]>
Reviewed-by: Joey Vagedes <[email protected]>
  • Loading branch information
makubacki authored and mergify[bot] committed Nov 30, 2023
1 parent b4f8c75 commit 26d484d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
git config --system core.longpaths true
- name: Install/Upgrade pip Modules
run: pip install -r pip-requirements.txt --upgrade requests
run: pip install -r pip-requirements.txt --upgrade requests sarif-tools

- name: Determine CI Settings File Supported Operations
id: get_ci_file_operations
Expand Down Expand Up @@ -304,16 +304,26 @@ jobs:
PACKAGE_NAME: ${{ matrix.Package }}
shell: python
run: |
import logging
import os
from edk2toollib.utility_functions import RunCmd
from io import StringIO
from pathlib import Path
package = os.environ['PACKAGE_NAME'].strip().lower()
directory_name = 'codeql-analysis-' + package + '-debug'
file_name = 'codeql-db-' + package + '-debug-0.sarif'
sarif_path = os.path.join('Build', directory_name, file_name)
sarif_path = Path('Build', directory_name, file_name)
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
if os.path.isfile(sarif_path):
if sarif_path.is_file():
emacs_file_path = sarif_path.with_name(sarif_path.stem + "-emacs.txt")
out_stream_buffer = StringIO()
exit_code = RunCmd("sarif", f"emacs {sarif_path} --output {emacs_file_path} --no-autotrim",
outstream=out_stream_buffer,
logging_level=logging.NOTSET)
print(f'upload_sarif_file=true', file=fh)
print(f'emacs_file_path={emacs_file_path}', file=fh)
print(f'sarif_file_path={sarif_path}', file=fh)
else:
print(f'upload_sarif_file=false', file=fh)
Expand All @@ -323,7 +333,9 @@ jobs:
if: steps.env_data.outputs.upload_sarif_file == 'true'
with:
name: ${{ matrix.Package }}-CodeQL-SARIF
path: ${{ steps.env_data.outputs.sarif_file_path }}
path: |
${{ steps.env_data.outputs.emacs_file_path }}
${{ steps.env_data.outputs.sarif_file_path }}
retention-days: 14
if-no-files-found: warn

Expand Down

0 comments on commit 26d484d

Please sign in to comment.