Skip to content

Commit c2ffab6

Browse files
committed
build: add coverity workflow
Let's add coverity to do some code analysis. Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent a57edc3 commit c2ffab6

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/coverity.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: coverity
3+
4+
on:
5+
schedule:
6+
# Run weekly on Mondays at 00:00 UTC
7+
- cron: '0 0 * * 1'
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: 'Branch, tag, or ref to check out (leave empty for default branch)'
12+
required: false
13+
default: ''
14+
15+
jobs:
16+
coverity-scan:
17+
if: github.repository == 'linux-nvme/nvme-cli'
18+
name: coverity scan
19+
runs-on: ubuntu-latest
20+
container:
21+
image: ghcr.io/linux-nvme/debian:latest
22+
steps:
23+
- uses: actions/checkout@v5
24+
with:
25+
ref: ${{ github.event.inputs.ref || github.ref }}
26+
fetch-depth: 0
27+
28+
- name: Mark repo as safe for git
29+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
30+
31+
- name: Get version info
32+
id: version
33+
run: |
34+
VERSION="$(git describe --always --abbrev=12 --dirty)"
35+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
36+
echo "Building version: ${VERSION}"
37+
echo "Current SHA: $(git rev-parse HEAD)"
38+
39+
- name: Download Coverity Build Tool
40+
run: |
41+
wget -q https://scan.coverity.com/download/linux64 \
42+
--post-data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=linux-nvme%2Fnvme-cli" \
43+
-O coverity_tool.tgz
44+
mkdir coverity-tools
45+
tar xzf coverity_tool.tgz --strip 1 -C coverity-tools
46+
47+
- name: Configure build
48+
run: |
49+
meson setup .build
50+
51+
- name: Build with Coverity
52+
run: |
53+
export PATH="$PWD/coverity-tools/bin:$PATH"
54+
cov-build --dir cov-int ninja -C .build
55+
56+
- name: Create Coverity tarball
57+
run: |
58+
tar czvf nvme-cli-coverity.tgz cov-int
59+
60+
- name: Upload to Coverity Scan
61+
run: |
62+
curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \
63+
--form email=${{ secrets.COVERITY_SCAN_EMAIL }} \
64+
--form file=@nvme-cli-coverity.tgz \
65+
--form version="${{ steps.version.outputs.version }}" \
66+
--form description="Automated Coverity Scan from ${{ github.event_name }}" \
67+
https://scan.coverity.com/builds?project=linux-nvme%2Fnvme-cli
68+
69+
- uses: actions/upload-artifact@v5
70+
name: upload coverity artifacts
71+
if: failure()
72+
with:
73+
name: coverity-results
74+
path: |
75+
cov-int/
76+
nvme-cli-coverity.tgz

0 commit comments

Comments
 (0)