This repository is an example C++ project that demonstrates how the Parasoft C/C++test AI agent skills can be used to automatically fix static analysis violations inside a GitHub CI/CD pipeline.
The key idea is that when a pull request is created, the pipeline runs C/C++test, detects violations, and then invokes an AI coding agent (OpenAI Codex, or others) equipped with C/C++test skills and MCP tools to automatically fix the violations, commit the fixes to a new branch, and open a new pull request.
The C/C++test AI Agent skills used in this project are taken from the parasoft/cpptest-ai-agent-skills repository.
The CI/CD pipeline requires a GitHub self-hosted runner configured and connected to the repository. The runner must have the following components available:
- Parasoft C/C++test Standard — installed, configured, and licensed
- Expected installation path:
/opt/parasoft/cpptest - The following directories should be on
$PATHso thatcpptestcliandcpptesttraceare accessible to the pipeline:/opt/parasoft/cpptest/opt/parasoft/cpptest/bin
- Expected installation path:
- GitHub CLI - installed
- AI coding agent — OpenAI Codex CLI, authorized and ready to use
- C/C++ toolchain — GNU GCC compiler and
makebuild tool
Note: If your C/C++test installation path or AI agent setup differs from the defaults, update the configuration in .github/workflows/cpptest-autofix-github.yml, .github/workflows/cpptest-agent-run.sh, and cpptest-analyze.sh accordingly.
Tip: Consider using a Docker container as your GitHub self-hosted runner with C/C++test and the AI agent pre-installed. An example Dockerfile is available in parasoft/cpptest-ai-agent-skills/devcontainer.
- Fork or copy this repository.
- Set up and connect a GitHub self-hosted runner: Settings > Actions > Runners. See also Prerequisites above.
- Enable the following option in your repository: Settings > Actions > General > Allow GitHub Actions to create and approve pull requests.
- Clone the repository to your local machine.
- Create a
featurebranch in the local repository. - Introduce a change to the source code.
- Push the branch to the remote GitHub repository.
- Open a pull request on GitHub to merge your
featurebranch into your default branch (masterormain).
Opening a pull request triggers the workflow defined in .github/workflows/cpptest-autofix-github.yml:
- The project is built.
- C/C++test runs static analysis and archives the reports as build artifacts.
- If violations are found, the AI Autofix step is triggered:
- A new
autofix/pr-<number>/<timestamp>branch is created. - The AI agent processes violations rule by rule.
- Each fix is verified by running cpptest-analyze.sh.
- Verified fixes are committed to the
autofixbranch (one commit per rule). - The
autofixbranch is pushed to the remote repository. - A pull request from
autofixinto yourfeaturebranch is opened, and a comment with links is posted on the original PR.
- A new
- Review the changes proposed in the
autofixbranch. - Merge the
autofixbranch into yourfeaturebranch. - Verify that the pipeline passes on the updated
featurebranch. - Merge the
featurebranch into your default branch (masterormain).
The repository is structured as follows, highlighting the key files related to C/C++test AI agent skills configuration:
<PROJECT_DIR>
.agents/skills/
cpptest-fix-all-violations/
SKILL.md # AI agent skill: fix all violations in the project
cpptest-fix-one-violation/
SKILL.md # AI agent skill: fix a single known violation
.github/workflows/
cpptest-agent-prompt.md # Prompt passed to the AI agent
cpptest-agent-run.sh # Script that invokes the AI agent
cpptest-autofix-github.yml # GitHub build pipeline
include/
*.hxx
*.cxx
AGENTS.md # Agent instructions for this repository
cpptest-analyze.sh # Script for running C/C++test analysis
Makefile
This project is configured for C/C++test Standard. To use it with C/C++test Professional, review and update both the local analysis command (cpptest-analyze.sh) and the GitHub workflow configuration (.github/workflows/cpptest-autofix-github.yml) so they match your installation and project layout.
Update cpptest-analyze.sh so its cpptestcli command invocation matches your C/C++test Professional setup. In particular, verify the workspace location, test configuration, report directory, and analysis input file. For example:
cpptestcli -data ../workspace -config "builtin://Recommended Rules" -report "reports" -bdf "cpptestscan.bdf"Review the Run C/C++test step in .github/workflows/cpptest-autofix-github.yml and adjust the run-cpptest-action inputs for C/C++test Professional. This typically includes settings such as the analysis input, workspace location, and any additional parameters required by your environment. See Customizing the Action to Run C/C++test Professional for details.