1
1
name : Checks
2
2
run-name : Code checks for ${{ github.ref_name }}
3
3
4
- on :
4
+ # General comment:
5
+ # Coverity doesn't support merging or including reports from multible machine/platforms (at least not officially).
6
+ # But otherwise there is no good way to keep the issues from all platforms at Coverity Scans at once.
7
+ # This script uses undocumented (but appears to be working) hack:
8
+ # The build logs from one machine/platform gets moved to a next once,
9
+ # and "fixed" so that cov-build can append logs from the next platform.
10
+ # The "fix" is based on the fact, that Coverity perfectly allows appending logs from multiple builds
11
+ # that are done *on the same host* machine.
12
+
13
+ on :
5
14
workflow_dispatch :
6
15
7
16
jobs :
17
+ coverity-windows :
18
+ runs-on : windows-latest
19
+
20
+ steps :
21
+ - uses : actions/checkout@v3
22
+ with :
23
+ path : src
24
+ - name : Setup MSVC
25
+ uses : TheMrMilchmann/setup-msvc-dev@v2.0.0
26
+ with :
27
+ arch : x64
28
+ - name : Configure
29
+ run : |
30
+ cmake -B build -S src -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_HIDTEST=ON
31
+ - name : Lookup Coverity Build Tool hash
32
+ id : coverity-cache-lookup
33
+ run : |
34
+ $coverity_hash=Invoke-RestMethod -Uri https://scan.coverity.com/download/cxx/win64 -Method Post -Body @{token='${{ secrets.COVERITY_SCAN_TOKEN }}';project='hidapi';md5=1}
35
+ echo "coverity_hash=$coverity_hash" >> $Env:GITHUB_OUTPUT
36
+ - name : Get cached Coverity Build Tool
37
+ id : cov-build-cache
38
+ uses : actions/cache@v3
39
+ with :
40
+ path : cov-root
41
+ key : cov-root-cxx-win64-${{ steps.coverity-cache-lookup.outputs.coverity_hash }}
42
+ - name : Get and configure Coverity
43
+ if : steps.cov-build-cache.outputs.cache-hit != 'true'
44
+ run : |
45
+ Invoke-WebRequest -Uri https://scan.coverity.com/download/cxx/win64 -OutFile coverity.zip -Method Post -Body @{token='${{ secrets.COVERITY_SCAN_TOKEN }}';project='hidapi'}
46
+ Remove-Item 'cov-root' -Recurse -Force -ErrorAction SilentlyContinue
47
+ Expand-Archive coverity.zip -DestinationPath cov-root
48
+
49
+ $cov_root=Get-ChildItem -Path 'cov-root'
50
+ $Env:PATH += ";$($cov_root.FullName)\bin"
51
+ cov-configure -msvc
52
+ - name : Make Coverity available in PATH
53
+ run : |
54
+ $cov_root=Get-ChildItem -Path 'cov-root'
55
+ echo "$($cov_root.FullName)\bin" >> $Env:GITHUB_PATH
56
+ - name : Build with Coverity
57
+ working-directory : build
58
+ run : |
59
+ cov-build --dir cov-int nmake
60
+ Rename-Item ".\cov-int\emit\$(hostname)" hostname
61
+ - name : Backup Coverity logs
62
+ uses : actions/upload-artifact@v3
63
+ with :
64
+ name : coverity-logs-windows
65
+ path : build/cov-int
66
+ retention-days : 7
67
+
68
+
8
69
coverity-macos :
9
70
runs-on : macos-latest
71
+ needs : [coverity-windows]
10
72
11
73
steps :
12
74
- uses : actions/checkout@v3
@@ -17,40 +79,56 @@ jobs:
17
79
- name : Configure
18
80
run : |
19
81
cmake -B build -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_HIDTEST=ON -DCMAKE_C_COMPILER=clang
82
+ - uses : actions/download-artifact@v3
83
+ with :
84
+ name : coverity-logs-windows
85
+ path : build/cov-int
86
+ - name : Fixup cov-int
87
+ run : |
88
+ rm -f build/cov-int/emit/hostname/emit-db.lock build/cov-int/emit/hostname/emit-db.write-lock
89
+ mv build/cov-int/emit/hostname build/cov-int/emit/$(hostname)
90
+ - name : Lookup Coverity Build Tool hash
91
+ id : coverity-cache-lookup
92
+ shell : bash
93
+ run : |
94
+ hash=$(curl https://scan.coverity.com/download/cxx/Darwin --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=hidapi&md5=1")
95
+ echo "coverity_hash=${hash}" >> $GITHUB_OUTPUT
96
+ - name : Get cached Coverity Build Tool
97
+ id : cov-build-cache
98
+ uses : actions/cache@v3
99
+ with :
100
+ path : cov-root
101
+ key : cov-root-cxx-Darwin-${{ steps.coverity-cache-lookup.outputs.coverity_hash }}
20
102
- name : Get and configure Coverity
103
+ if : steps.cov-build-cache.outputs.cache-hit != 'true'
21
104
run : |
22
105
curl https://scan.coverity.com/download/cxx/Darwin --output coverity.dmg --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=hidapi"
23
106
hdiutil attach coverity.dmg -mountroot coverity
24
107
export COV_DIR_NAME=$(ls -1 --color=never coverity)
108
+ rm -rf cov-root
25
109
mkdir cov-root
26
110
cp ./coverity/${COV_DIR_NAME}/${COV_DIR_NAME}.sh cov-root/
27
111
cd cov-root/
28
112
./${COV_DIR_NAME}.sh
29
113
./bin/cov-configure --clang
30
- echo "$(pwd)/bin" >> $GITHUB_PATH
114
+ - name : Make Coverity available in PATH
115
+ run : echo "$(pwd)/cov-root/bin" >> $GITHUB_PATH
31
116
- name : Build with Coverity
32
117
working-directory : build
33
- run : cov-build --dir cov-int ninja
118
+ run : |
119
+ cov-build --dir cov-int --append-log ninja
120
+ mv cov-int/emit/$(hostname) cov-int/emit/hostname
34
121
- name : Backup Coverity logs
35
122
uses : actions/upload-artifact@v3
36
123
with :
37
- name : coverity-logs-macos
124
+ name : coverity-logs-windows- macos
38
125
path : build/cov-int
39
126
retention-days : 7
40
- - name : Submit results to Coverity Scan
41
- working-directory : build
42
- run : |
43
- tar -czf cov-int.tar.gz cov-int
44
- curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \
45
- --form email=${{ secrets.COVERITY_SCAN_EMAIL }} \
46
- --form file=@cov-int.tar.gz \
47
- --form version="$GITHUB_SHA" \
48
- --form description="Automatic macOS build" \
49
- https://scan.coverity.com/builds?project=hidapi
50
127
51
128
52
129
coverity-ubuntu :
53
130
runs-on : ubuntu-latest
131
+ needs : [coverity-macos]
54
132
55
133
steps :
56
134
- uses : actions/checkout@v3
@@ -61,64 +139,54 @@ jobs:
61
139
- name : Configure
62
140
run : |
63
141
cmake -B build -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_HIDTEST=ON -DCMAKE_C_COMPILER=gcc
64
- - uses : vapier/coverity-scan-action@v1
142
+ - uses : actions/download-artifact@v3
65
143
with :
66
- email : ${{ secrets.COVERITY_SCAN_EMAIL }}
67
- token : ${{ secrets.COVERITY_SCAN_TOKEN }}
68
- project : hidapi
69
- command : ninja
70
- working-directory : build
71
- description : ' Automatic Linux build'
72
- - name : Backup Coverity logs
73
- uses : actions/upload-artifact@v3
74
- with :
75
- name : coverity-logs-linux
144
+ name : coverity-logs-windows-macos
76
145
path : build/cov-int
77
- retention-days : 7
78
-
79
-
80
- coverity-windows :
81
- runs-on : windows-latest
82
-
83
- steps :
84
- - uses : actions/checkout@v3
85
- with :
86
- path : src
87
- - name : Setup MSVC
88
- uses : TheMrMilchmann/setup-msvc-dev@v2.0.0
89
- with :
90
- arch : x64
91
- - name : Configure
146
+ - name : Fixup cov-int
92
147
run : |
93
- cmake -B build -S src -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_HIDTEST=ON
148
+ rm -f build/cov-int/emit/hostname/emit-db.lock build/cov-int/emit/hostname/emit-db.write-lock
149
+ mv build/cov-int/emit/hostname build/cov-int/emit/$(hostname)
150
+ - name : Lookup Coverity Build Tool hash
151
+ id : coverity-cache-lookup
152
+ shell : bash
153
+ run : |
154
+ hash=$(curl https://scan.coverity.com/download/cxx/linux64 --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=hidapi&md5=1")
155
+ echo "coverity_hash=${hash}" >> $GITHUB_OUTPUT
156
+ - name : Get cached Coverity Build Tool
157
+ id : cov-build-cache
158
+ uses : actions/cache@v3
159
+ with :
160
+ path : cov-root
161
+ key : cov-root-cxx-linux64-${{ steps.coverity-cache-lookup.outputs.coverity_hash }}
94
162
- name : Get and configure Coverity
163
+ if : steps.cov-build-cache.outputs.cache-hit != 'true'
95
164
run : |
96
- Invoke-WebRequest -Uri https://scan.coverity.com/download/cxx/win64 -OutFile coverity.zip -Method Post -Body @{token='${{ secrets.COVERITY_SCAN_TOKEN }}';project='hidapi'}
97
- Expand-Archive coverity.zip -DestinationPath cov-root
98
-
99
- $cov_root=Get-ChildItem -Path 'cov-root'
100
- $Env:PATH += ";$($cov_root.FullName)\bin"
101
- cov-configure -msvc
102
-
103
- echo "$($cov_root.FullName)\bin" >> $Env:GITHUB_PATH
165
+ curl https://scan.coverity.com/download/cxx/linux64 --output coverity.tar.gz --data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=hidapi"
166
+ rm -rf cov-root
167
+ mkdir cov-root
168
+ tar -xzf coverity.tar.gz --strip 1 -C cov-root
169
+ ./cov-root/bin/cov-configure --gcc
170
+ - name : Make Coverity available in PATH
171
+ run : echo "$(pwd)/cov-root/bin" >> $GITHUB_PATH
104
172
- name : Build with Coverity
105
173
working-directory : build
106
- run : cov-build --dir cov-int nmake
174
+ run : |
175
+ cov-build --dir cov-int --append-log ninja
176
+ - name : Submit results to Coverity Scan
177
+ working-directory : build
178
+ run : |
179
+ tar -czf cov-int.tar.gz cov-int
180
+ curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \
181
+ --form email=${{ secrets.COVERITY_SCAN_EMAIL }} \
182
+ --form file=@cov-int.tar.gz \
183
+ --form version="$GITHUB_SHA" \
184
+ --form description="Automatic HIDAPI build" \
185
+ https://scan.coverity.com/builds?project=hidapi
186
+ mv cov-int/emit/$(hostname) cov-int/emit/hostname
107
187
- name : Backup Coverity logs
108
188
uses : actions/upload-artifact@v3
109
189
with :
110
- name : coverity-logs-windows
190
+ name : coverity-logs-windows-macos-linux
111
191
path : build/cov-int
112
192
retention-days : 7
113
- - name : Submit results to Coverity Scan
114
- working-directory : build
115
- run : |
116
- tar -czf cov-int.tar.gz cov-int
117
- Invoke-RestMethod -Uri 'https://scan.coverity.com/builds?project=hidapi' `
118
- -Method Post -Form @{ `
119
- email='${{ secrets.COVERITY_SCAN_EMAIL }}'; `
120
- token='${{ secrets.COVERITY_SCAN_TOKEN }}'; `
121
- file=Get-Item 'cov-int.tar.gz'; `
122
- version=$Env:GITHUB_SHA; `
123
- description='Automatic Windows build' `
124
- }
0 commit comments