CI: build before analysis to support C++ Modules (#325) #294
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Analysis | |
| on: | |
| push: | |
| paths-ignore: | |
| - 'doc/**' | |
| branches: [ main ] | |
| pull_request: | |
| paths-ignore: | |
| - 'doc/**' | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| name: Microsoft C++ Code Analysis | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: [Release] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install MSVC Build Tools Preview | |
| shell: pwsh | |
| run: | | |
| $url = "https://aka.ms/vs/18/insiders/vs_buildtools.exe" | |
| Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\vs_buildtools.exe" -UseBasicParsing | |
| $process = Start-Process -Wait -PassThru -FilePath "$env:TEMP\vs_buildtools.exe" ` | |
| -ArgumentList "--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.26100 --add Microsoft.VisualStudio.Component.VC.CMake.Project --includeRecommended" | |
| $exitCode = $process.ExitCode | |
| Write-Output "VS installer exit code: $exitCode" | |
| if ($exitCode -notin 0,3010,3015) { throw "VS Installer failed: $exitCode" } | |
| - name: Set up MSVC environment | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| vsversion: '18' | |
| - name: Configure | |
| shell: pwsh | |
| run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.config }} | |
| - name: Build | |
| shell: pwsh | |
| run: cmake --build build | |
| - name: Run Microsoft Visual C++ Analysis | |
| id: run-analysis | |
| uses: gdr-at-ms/msvc-code-analysis-action@support-cxx-modules | |
| with: | |
| cmakeBuildDirectory: build | |
| buildConfiguration: ${{ matrix.config }} | |
| ignoredTargetPaths: ${{ github.workspace }}/tests | |
| ruleset: '${{ github.workspace }}/infra/Analysis.ruleset' | |
| - name: Upload SARIF as an Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sarif-file | |
| path: ${{ steps.run-analysis.outputs.sarif }} | |
| if-no-files-found: error | |
| - name: Upload SARIF to GitHub | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: ${{ steps.run-analysis.outputs.sarif }} |