forked from cpp-best-practices/cmake_template
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (99 loc) · 3.93 KB
/
codeql-analysis.yml
File metadata and controls
114 lines (99 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# NOTE
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master, main, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, main, develop ]
schedule:
- cron: '38 0 * * 5'
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
ci-image: ${{ steps.images.outputs.ci }}
steps:
- id: images
run: |
# Use the template repo's pre-built CI images so that repos derived
# from the template work on their very first push — before their own
# build-ci-image workflow has had a chance to run.
# If a project later needs a custom CI image, uncomment the lines
# below and re-enable the per-repo build-ci-image workflow.
#
# REPO="${{ github.repository }}"
# REPO_LC="${REPO,,}"
# echo "ci=ghcr.io/${REPO_LC}/ci:latest" >> $GITHUB_OUTPUT
echo "ci=ghcr.io/versatushpc/cmake_template/ci:latest" >> $GITHUB_OUTPUT
analyze:
name: Analyze
needs: setup
runs-on: ubuntu-latest
container:
image: ${{ needs.setup.outputs.ci-image }}
permissions:
actions: read
contents: read
packages: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
compiler:
- gcc-14
generator:
- "Ninja Multi-Config"
build_type:
- Debug
packaging_maintainer_mode:
- ON
steps:
- uses: actions/checkout@v6
- name: Setup Cache
uses: ./.github/actions/setup_cache
with:
compiler: ${{ matrix.compiler }}
build_type: ${{ matrix.build_type }}
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }}
generator: ${{ matrix.generator }}
- name: Project Name
uses: cardinalby/export-env-action@v2
with:
envFile: '.github/constants.env'
- name: Pre-install Conan deps
run: |
conan profile detect --force
sed -i "s/compiler.libcxx=.*/compiler.libcxx=libstdc++11/" ~/.conan2/profiles/default
sed -i "s/compiler.cppstd=.*/compiler.cppstd=23/" ~/.conan2/profiles/default
conan install . --output-folder=build --build=missing -s build_type=Debug
- name: Configure CMake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_SKIP_CONAN_PROVIDER=ON -DCMAKE_PREFIX_PATH=$PWD/build -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -D${{ env.PROJECT_NAME }}_ENABLE_BLOATY:BOOL=OFF -D${{ env.PROJECT_NAME }}_ENABLE_INCLUDE_WHAT_YOU_USE:BOOL=OFF
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build ./build --config ${{matrix.build_type}}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4