CodeQL - C# #19
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: "CodeQL - C#" | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] | |
| schedule: | |
| - cron: '0 4 * * 0' # Runs every Sunday at 4AM | |
| jobs: | |
| analyze: | |
| name: CodeQL Security Scan + Tests + Coverage | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| security-events: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 6.x | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '6.x' | |
| - name: Setup .NET 8.x | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.x' | |
| - name: Setup .NET 9.x | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Initialize CodeQL | |
| uses: github/codeql-action/init@v3 | |
| with: | |
| languages: csharp | |
| - name: Build project | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Run tests | |
| run: | | |
| dotnet test \ | |
| --configuration Release \ | |
| --collect:"XPlat Code Coverage" \ | |
| --blame \ | |
| --results-directory ./TestResults | |
| - name: Generate coverage report | |
| uses: danielpalme/ReportGenerator-GitHub-Action@5.3.5 | |
| with: | |
| reports: 'TestResults/**/coverage.cobertura.xml' | |
| targetdir: 'CoverageReport' | |
| reporttypes: 'HtmlInline;Cobertura' | |
| verbosity: 'Info' | |
| - name: Upload coverage report as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: CoverageReport | |
| - name: Run CodeQL Analysis | |
| uses: github/codeql-action/analyze@v3 |