Skip to content

Commit 238b807

Browse files
committed
Add workflow for running Coverity scan. (#256)
1 parent 2349120 commit 238b807

3 files changed

Lines changed: 137 additions & 11 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
name: CMake
2222

2323
on:
24-
push:
25-
branches: [ "master" ]
24+
#push:
25+
# branches: [ "master" ]
2626
pull_request:
2727
branches: [ "master" ]
2828
types: [ opened, synchronize, reopened, ready_for_review ]

.github/workflows/coverity.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Copyright (c) 2026 Lukasz Stalmirski
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all
11+
# copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
# SOFTWARE.
20+
21+
name: Coverity Scan
22+
23+
on:
24+
workflow_dispatch:
25+
# schedule:
26+
# - cron: '00 09 * * 6'
27+
28+
jobs:
29+
build:
30+
runs-on: windows-latest
31+
permissions:
32+
contents: read
33+
actions: read
34+
security-events: write
35+
36+
steps:
37+
- uses: actions/checkout@v6
38+
with:
39+
submodules: recursive
40+
fetch-depth: 0
41+
42+
- uses: actions/setup-python@v6
43+
with:
44+
python-version: '3.12'
45+
cache: 'pip'
46+
- run: |
47+
python3 -m pip install `
48+
-r '${{ github.workspace }}/VkLayer_profiler_layer/scripts/requirements.txt'
49+
50+
- name: Get Coverity Build Tools
51+
id: get-coverity
52+
run: |
53+
$request = @{
54+
Uri = 'https://scan.coverity.com/download/cxx/win64'
55+
Method = 'POST'
56+
Body = @{
57+
token = '${{ secrets.COVERITY_PASSPHRASE }}'
58+
project = '${{ github.repository }}'
59+
}
60+
}
61+
62+
Invoke-WebRequest @request -OutFile cov_build_tools.zip
63+
Expand-Archive cov_build_tools.zip
64+
65+
$cov_build_exe = (Get-ChildItem -Recurse "cov_build_tools/*/cov-build.exe").FullName
66+
if (-Not $cov_build_exe) {
67+
Write-Error "Coverity build tool not found."
68+
exit 1
69+
}
70+
71+
echo "cov_build_exe=$cov_build_exe" >> $env:GITHUB_OUTPUT
72+
73+
- name: Configure CMake
74+
id: configure
75+
run: |
76+
$source_dir = '${{ github.workspace }}'
77+
$build_dir = '${{ github.workspace }}/build'
78+
79+
cmake -S $source_dir -B $build_dir
80+
81+
echo "source_dir=$source_dir" >> $env:GITHUB_OUTPUT
82+
echo "build_dir=$build_dir" >> $env:GITHUB_OUTPUT
83+
84+
- name: Build
85+
run: |
86+
${{ steps.get-coverity.outputs.cov_build_exe }} `
87+
--dir cov-int `
88+
cmake --build ${{ steps.configure.outputs.build_dir }} `
89+
--config Release -j
90+
91+
- name: Package
92+
id: package
93+
run: |
94+
$profiler_version = (python3 '${{ github.workspace }}/VkLayer_profiler_layer/scripts/gen_version.py')
95+
if (-Not $profiler_version) {
96+
Write-Error "Profiler version not found."
97+
exit 1
98+
}
99+
100+
$profiler_build_zip = "$($profiler_version).zip"
101+
Compress-Archive cov-int -DestinationPath $profiler_build_zip
102+
103+
echo "profiler_version=$profiler_version" >> $env:GITHUB_OUTPUT
104+
echo "profiler_build_zip=$profiler_build_zip" >> $env:GITHUB_OUTPUT
105+
106+
- uses: actions/upload-artifact@v7
107+
with:
108+
path: ${{ steps.package.outputs.profiler_build_zip }}
109+
archive: false
110+
111+
- name: Submit
112+
run: |
113+
$project_name = [uri]::EscapeDataString("${{ github.repository }}")
114+
$project_uri = "https://scan.coverity.com/builds?project=$project_name"
115+
$form = @{
116+
token = '${{ secrets.COVERITY_PASSPHRASE }}'
117+
email = '${{ secrets.COVERITY_USER }}'
118+
file = Get-Item -Path '${{ steps.package.outputs.profiler_build_zip }}'
119+
version = '${{ steps.package.outputs.profiler_version }}'
120+
}
121+
122+
#Invoke-WebRequest -Uri $project_uri -Method Post -Form $form

VkLayer_profiler_layer/scripts/gen_version.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 Lukasz Stalmirski
1+
# Copyright (c) 2023-2026 Lukasz Stalmirski
22
#
33
# Permission is hereby granted, free of charge, to any person obtaining a copy
44
# of this software and associated documentation files (the "Software"), to deal
@@ -44,11 +44,15 @@ def git(*args):
4444
ver_build = rev_base_count
4545
ver_patch = rev_count - rev_base_count
4646

47-
# Write cmake file with the version info
48-
with open(sys.argv[1], "w") as output:
49-
profiler_version_cmake = \
50-
"set (PROFILER_LAYER_VER_MAJOR {})\n".format(ver_major) + \
51-
"set (PROFILER_LAYER_VER_MINOR {})\n".format(ver_minor) + \
52-
"set (PROFILER_LAYER_VER_BUILD {})\n".format(ver_build) + \
53-
"set (PROFILER_LAYER_VER_PATCH {})\n".format(ver_patch)
54-
output.write(profiler_version_cmake)
47+
if len(sys.argv) > 1:
48+
# Write cmake file with the version info
49+
with open(sys.argv[1], "w") as output:
50+
profiler_version_cmake = \
51+
f"set (PROFILER_LAYER_VER_MAJOR {ver_major})\n" + \
52+
f"set (PROFILER_LAYER_VER_MINOR {ver_minor})\n" + \
53+
f"set (PROFILER_LAYER_VER_BUILD {ver_build})\n" + \
54+
f"set (PROFILER_LAYER_VER_PATCH {ver_patch})\n"
55+
output.write(profiler_version_cmake)
56+
else:
57+
# Write version to the standard output
58+
print(f"vulkan-profiler-{ver_major}.{ver_minor}.{ver_build}.{ver_patch}")

0 commit comments

Comments
 (0)