|
| 1 | +name: CodeQL Analysis (Reusable) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runner_os: |
| 7 | + description: 'Runner OS for CodeQL analysis' |
| 8 | + type: string |
| 9 | + required: false |
| 10 | + default: ubuntu-latest |
| 11 | + |
| 12 | +permissions: |
| 13 | + actions: read # for github/codeql-action/init to get workflow details |
| 14 | + contents: read # for actions/checkout to fetch code |
| 15 | + security-events: write # for github/codeql-action/analyze to upload SARIF results |
| 16 | + |
| 17 | +env: |
| 18 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 19 | + DOTNET_NOLOGO: 1 |
| 20 | + POWERSHELL_TELEMETRY_OPTOUT: 1 |
| 21 | + __SuppressAnsiEscapeSequences: 1 |
| 22 | + nugetMultiFeedWarnLevel: none |
| 23 | + |
| 24 | +jobs: |
| 25 | + analyze: |
| 26 | + name: Analyze |
| 27 | + runs-on: ${{ inputs.runner_os }} |
| 28 | + |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + # Override automatic language detection by changing the below list |
| 33 | + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] |
| 34 | + language: ['csharp'] |
| 35 | + # Learn more... |
| 36 | + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 41 | + with: |
| 42 | + fetch-depth: '0' |
| 43 | + |
| 44 | + - uses: actions/setup-dotnet@v5 |
| 45 | + with: |
| 46 | + global-json-file: ./global.json |
| 47 | + |
| 48 | + # Initializes the CodeQL tools for scanning. |
| 49 | + - name: Initialize CodeQL |
| 50 | + uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5 |
| 51 | + with: |
| 52 | + languages: ${{ matrix.language }} |
| 53 | + # If you wish to specify custom queries, you can do so here or in a config file. |
| 54 | + # By default, queries listed here will override any specified in a config file. |
| 55 | + # Prefix the list here with "+" to use these queries and those in the config file. |
| 56 | + # queries: ./path/to/local/query, your-org/your-repo/queries@main |
| 57 | + |
| 58 | + - run: | |
| 59 | + Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose |
| 60 | + name: Capture Environment |
| 61 | + shell: pwsh |
| 62 | +
|
| 63 | + - run: | |
| 64 | + Import-Module .\tools\ci.psm1 |
| 65 | + Invoke-CIInstall -SkipUser |
| 66 | + name: Bootstrap |
| 67 | + shell: pwsh |
| 68 | +
|
| 69 | + - run: | |
| 70 | + Import-Module .\tools\ci.psm1 |
| 71 | + Invoke-CIBuild -Configuration 'StaticAnalysis' |
| 72 | + name: Build |
| 73 | + shell: pwsh |
| 74 | +
|
| 75 | + - name: Perform CodeQL Analysis |
| 76 | + uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5 |
0 commit comments