- 1 year ago
AppVeyor + Coverity on Windows with C++
Integrating AppVeyor and Coverity for C++ projects on Windows involves setting up continuous integration and static code analysis. Here are the general steps you can follow:
Set Up AppVeyor:
- Sign up for an AppVeyor account if you don't have one.
- Connect your GitHub, Bitbucket, or GitLab repository to AppVeyor.
- Create an
appveyor.yml
configuration file in the root of your repository. This file will define your build settings.
Configure AppVeyor for C++:
- Specify the
image
to use for your build environment. You can choose a Visual Studio image that matches your project's requirements. - Define the build script and test script.
- Include any necessary installation steps for your project's dependencies.
- Specify the
Set Up Coverity:
- Sign up for a Coverity account if you don't have one.
- Configure a project in Coverity that corresponds to your C++ project.
- Obtain your Coverity token and project token.
Integrate Coverity with AppVeyor:
- In your
appveyor.yml
file, add the Coverity integration settings. This includes setting the environment variables for your Coverity token and project token.
- In your
Here's an example appveyor.yml
configuration that demonstrates how to set up AppVeyor with Coverity for a C++ project:
yamlimage: Visual Studio 2019
before_build:
- nuget restore MySolution.sln
build_script:
- msbuild MySolution.sln /p:Configuration=Release
test_script:
- MyTests.exe
after_build:
- 'if ( "$APPVEYOR_PULL_REQUEST_NUMBER" -eq "" ) { c:\path\to\coverity\bin\cov-build --dir cov-int msbuild MySolution.sln /p:Configuration=Release }'
artifacts:
- path: cov-int
name: CoverityScan
environment:
global:
COVERITY_SCAN_PROJECT_NAME: "YourProjectName"
COVERITY_SCAN_NOTIFICATION_EMAIL: "you@example.com"
COVERITY_SCAN_BRANCH_PATTERN: ".*"
secure: "your_secure_coverity_token_here"
In the above example:
before_build
restores NuGet packages.build_script
builds your solution in Release mode.test_script
runs your tests.after_build
triggers Coverity to analyze your project if it's not a pull request build.artifacts
specifies that the CoverityScan results will be uploaded as artifacts.
Remember to replace placeholders with your actual project and account details.
Keep in mind that setting up continuous integration and static code analysis can be a complex process, and you may need to adjust the steps based on your specific project and requirements. Refer to the documentation of both AppVeyor and Coverity for more detailed instructions and troubleshooting.