| 1 |
# SPDX-FileCopyrightText: 2024 Emil Velikov <[email protected]> |
| 2 |
# SPDX-FileCopyrightText: 2024 Lucas De Marchi <[email protected]> |
| 3 |
# |
| 4 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
|
| 6 |
name: CodeQL |
| 7 |
|
| 8 |
on: |
| 9 |
push: |
| 10 |
branches: [master, ci-test] |
| 11 |
pull_request: |
| 12 |
branches: [master] |
| 13 |
schedule: |
| 14 |
- cron: "30 2 * * 0" |
| 15 |
|
| 16 |
permissions: |
| 17 |
contents: read |
| 18 |
|
| 19 |
jobs: |
| 20 |
analyze: |
| 21 |
name: Analyze |
| 22 |
runs-on: ubuntu-latest |
| 23 |
permissions: |
| 24 |
actions: read |
| 25 |
security-events: write |
| 26 |
|
| 27 |
strategy: |
| 28 |
fail-fast: false |
| 29 |
matrix: |
| 30 |
include: |
| 31 |
- container: 'ubuntu:24.04' |
| 32 |
|
| 33 |
container: |
| 34 |
image: ${{ matrix.container }} |
| 35 |
|
| 36 |
steps: |
| 37 |
- name: Sparse checkout the local actions |
| 38 |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 39 |
with: |
| 40 |
sparse-checkout: .github |
| 41 |
|
| 42 |
- uses: ./.github/actions/setup-ubuntu |
| 43 |
if: ${{ startsWith(matrix.container, 'ubuntu') }} |
| 44 |
|
| 45 |
- name: Checkout the whole project |
| 46 |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 47 |
|
| 48 |
- name: Set the environment |
| 49 |
run: | |
| 50 |
# The second checkout above claims to set safe.directory, yet it |
| 51 |
# doesn't quite work. Perhaps our double/sparse checkout is to blame? |
| 52 |
git config --global --add safe.directory '*' |
| 53 |
|
| 54 |
- name: Initialize CodeQL |
| 55 |
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5 |
| 56 |
with: |
| 57 |
languages: cpp |
| 58 |
queries: +security-and-quality |
| 59 |
|
| 60 |
- name: Build |
| 61 |
run: | |
| 62 |
meson setup --native-file build-dev.ini build |
| 63 |
meson compile -C build |
| 64 |
|
| 65 |
- name: Perform CodeQL Analysis |
| 66 |
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5 |
| 67 |
with: |
| 68 |
category: "/language:cpp" |
| 69 |
upload: false |
| 70 |
output: sarif-results |
| 71 |
|
| 72 |
- name: Filter out meson-internal test files |
| 73 |
uses: advanced-security/filter-sarif@f3b8118a9349d88f7b1c0c488476411145b6270d # v1.0.1 |
| 74 |
with: |
| 75 |
patterns: | |
| 76 |
-build/meson-private/**/testfile.c |
| 77 |
input: sarif-results/cpp.sarif |
| 78 |
output: sarif-results/cpp.sarif |
| 79 |
|
| 80 |
- name: Upload CodeQL results to code scanning |
| 81 |
uses: github/codeql-action/upload-sarif@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5 |
| 82 |
with: |
| 83 |
sarif_file: sarif-results/cpp.sarif |
| 84 |
category: "/language:cpp" |