Skip to content

Commit

Permalink
Add MSVC analysis to project (#685)
Browse files Browse the repository at this point in the history
* Added MSVC analysis to project

Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>

* Ignoring autogenerated files

Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>

* Disabled build testing and examples for msvc code analysis

Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>

* Added new step in code analysis for MSVC

Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>
  • Loading branch information
achristoforides committed Jun 19, 2022
1 parent c4a8d62 commit e7d0edb
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 69 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# This workflow is based on the examples from the default CodeQL and MSVC Code Analysis
# workflow templates.
#
name: "CodeQL/MSVC Code Analysis"

on:
push:
branches: [ development ]
pull_request:
branches: [ development ]
schedule:
- cron: '28 10 * * 0'

jobs:
analyze_codeql:
name: Analyze (CodeQL)
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

analyze_msvc:
name: Analyze (MSVC Code Analysis)
runs-on: windows-latest
env:
build: '${{ github.workspace }}/build'
config: 'Debug'

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

# We won't do the analysis on any test-related code (test bundles, unittest files, etc.)
- name: Configure with CMake
run: cmake -B ${{ env.build }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DUS_ENABLE_THREADING_SUPPORT=ON

# Because certain files are auto-generated during the build, we need to build
- name: Build with CMake
run: cmake --build ${{ env.build }} --config ${{ env.config }}

- name: Run MSVC Code Analysis
uses: microsoft/msvc-code-analysis-action@v0.1.0
# Provide a unique ID to access the sarif output path
id: run-msvc-analysis
with:
cmakeBuildDirectory: ${{ env.build }}
buildConfiguration: ${{ env.config }}
# Ruleset file that will determine what checks will be run
ruleset: NativeRecommendedRules.ruleset
# Paths to ignore analysis of CMake targets and includes
#ignoredPaths: ${{ github.workspace }}/build/framework/test/bundles;${{ github.workspace }}/build/compendium/test_bundles

# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.run-msvc-analysis.outputs.sarif }}

# Upload SARIF file as an Artifact to download and view
- name: Upload SARIF as an Artifact
uses: actions/upload-artifact@v2
with:
name: sarif-file
path: ${{ steps.run-msvc-analysis.outputs.sarif }}
69 changes: 0 additions & 69 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

0 comments on commit e7d0edb

Please sign in to comment.