Skip to content

Add coverity support to workflow #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/build.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this deserves a separate workflow.

Also do we even want to automatically run Coverity on every PR/push? (I don't know the deal that we have or how much it costs)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let you choose on this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this into a separate workflow then? This will make it easy to tweak the run condition without affecting the regular build.

Also we will be able to use jobs.<job_id>.if instead of jobs.<job_id>.steps[*].if.

Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,39 @@ jobs:
-D AUTH_LEGACY=OFF \
-G Ninja
ninja -C build-auth wsbrd
- name: Download Coverity
if: github.ref == 'refs/heads/main'
env:
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
run: |
wget -qO- "https://scan.coverity.com/download/cxx/linux64" \
--post-data "token=${COVERITY_SCAN_TOKEN}&project=wisun-br-linux" \
| tar -xz --one-top-level=/opt/coverity/ --strip-components=1
ln -sfn /opt/coverity/bin/cov* /usr/local/bin
coverity --version
- name: Compile with Coverity
if: github.ref == 'refs/heads/main'
run: |
cmake -S . \
-B build-cov \
-D COMPILE_WSRD=ON \
-D COMPILE_DEVTOOLS=ON \
-D COMPILE_DEMOS=ON \
-D CMAKE_C_FLAGS=-Werror \
-G Ninja
cov-build --dir cov-int ninja -C build-cov
- name: Upload Coverity Scan Results
if: github.ref == 'refs/heads/main'
env:
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }}
COVERITY_SCAN_VERSION: ${{ github.sha }}
Comment on lines +86 to +89
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to use env vars?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I now understand the need for secrets, but is it necessary for the SHA?

Copy link
Author

@yasslbk yasslbk Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, there is plenty of other ways to do it, the aim here was reusability by other teams working on open sources projects.
But let me point smt: It's common practice to use env variables in CI/CD tools.
Environment variables are ephemeral and exist only during pipeline execution. No persistence.
Most importantly, defining parameters as environment variables enhances reusability and flexibility, allowing different users or projects to run workflows with custom values without modifying the core script or commands or stages.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want something generic and reusable, the good way is to write an action. Maybe in the future we could have a Silabs action for Coverity if we have common steps.

btw, there seems to be an official Coverity GitHub action, I don't know how usable it is:
https://documentation.blackduck.com/bundle/bridge/page/documentation/c_github-coverity.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer relying on simple commands directly over using GitHub Actions.

GA abstract too much, making it feel like "magic" or "black box".
Reproducing workflows locally isn’t straightforward for developers—unless you use nektos/act, which isn’t easy to setup nor to use.

For me, it's the same logic as with Jenkins plugin: the less you rely on it, the happier you are.

Copy link
Collaborator

@MathisMARION MathisMARION Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, it is nice to view the Workflow as a list of commands that one can execute locally by copy-pasting.

I don't know much about Coverity, but it looks quite similar to SonarQube in being "magic / black box".
Sure you download tools, but you have no idea what they do besides produce data in a proprietary format that you then upload to a web platform for processing. Maybe I am wrong, as I have not looked in the details. Anyway, I'm diverging.

run: |
tar czf cov-int.tgz cov-int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "int" mean here?

curl --fail \
--form token="$COVERITY_SCAN_TOKEN" \
--form email="$COVERITY_SCAN_EMAIL" \
--form [email protected] \
--form version="$COVERITY_SCAN_VERSION" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use something more human friendly than a SHA? The output of wsbrd --version uses git describe.

--form description="Coverity scan results for commit $COVERITY_SCAN_VERSION" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this description necessary? It currently does not provide much information since the version is already provided. I could not even find where this description can be read on the frontend 😅

"https://scan.coverity.com/builds?project=wisun-br-linux"