All jobs

Add GitHub Actions CI to a CMake Project

Yes. An agent replaces a dead Travis file with a GitHub Actions workflow that builds and tests every CMake example on current Ubuntu and the minimum CMake, in a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent starts from what used to run. In a repository laid out like ttroy50/cmake-examples, .travis.yml is language: cpp with the Docker service, pulls matrim/cmake-examples:3.5.1 and :3.10.3, and runs test.sh inside each with the checkout mounted at /data/code and DEV_UID and DEV_GID passed through so dockerfiles/setup.sh can create a matching user. test.sh prints cmake --version, then walks a list of twenty-seven example directories: for each it deletes build/, runs pre_test.sh if present, then run_test.sh if present or else mkdir -p build && cd build && cmake .. && make, then post_test.sh, and exits on the first failure. The README's badge still points at travis-ci.org, which no longer runs anything, so pull requests get no check at all. The dockerfiles/ are Ubuntu 14.04 and 16.04 images that build CMake from source and install cppcheck 1.79, clang-3.6, Boost, protobuf, ninja and conan from pip3.

Next it reads what each example needs, because the apt list is the workflow. 01-basic/H-third-party-library and 05-unit-testing/boost call find_package(Boost ... COMPONENTS filesystem system) and unit_test_framework; 03-code-generation/protobuf needs protoc and the protobuf library for PROTOBUF_GENERATE_CPP; 04-static-analysis/cppcheck runs make analysis through a FindCppCheck module, clang-format expects make format-check to fail on purpose, and clang-analyzer/run_test.sh hard-codes scan-build-3.6; 01-basic/I picks clang or a versioned clang-N from dpkg, J skips itself when CMake has no Ninja generator, and K skips below CMake 3.5; 05-unit-testing/boost and catch2-vendored run make test in post_test.sh, while google-test-download is already disabled in its own run_test.sh; 06-installer/deb runs make package for a CPack .deb; the two 07-package-management/D-conan examples exit early unless conan is on PATH, and use conan 1 commands and a fmt/5.3.0@bincrafters/stable reference that conan 2 and today's ConanCenter do not serve.

It writes .github/workflows/ci.yml with two jobs. examples is a matrix over ubuntu-22.04 and ubuntu-24.04 that installs build-essential cmake libboost-all-dev libprotobuf-dev protobuf-compiler cppcheck clang clang-format clang-tools ninja-build with apt and runs ./test.sh from the checkout, with permissions: contents: read, a concurrency group that cancels superseded runs of a pull request, and timeout-minutes. For that to pass, clang-analyzer/run_test.sh changes from scan-build-3.6 to scan-build from PATH, since no current Ubuntu ships the 3.6 name, and the change is the only edit to an example. Conan stays off PATH so the two conan examples skip exactly as run_test.sh already allows, and the pull request records that moving them to conan 2 is a separate change. minimum-cmake keeps the Travis idea alive on a GitHub runner: it runs docker run --rm -v "$PWD:/data/code" -e DEV_UID=$(id -u) -e DEV_GID=$(id -g) matrim/cmake-examples:3.5.1 /data/code/test.sh from the host job rather than as a container: job, because that Ubuntu 16.04 image cannot run the Node-based actions/checkout, and it is the version the cmake_minimum_required(VERSION 3.5) lines claim to support.

Then it proves the matrix in its own sandbox: it installs that apt list on Ubuntu, runs ./test.sh end to end, and reads every failure. Whatever a current toolchain breaks, for example a Boost or protobuf CMake module that moved, is fixed in that example when the fix is one line and otherwise listed in the pull request with the error and the reason it is left for a follow-up, rather than being skipped silently. The sandbox ships without Docker, so it installs it (sudo apt-get install -y docker.io, then starts dockerd) and runs the docker run line to confirm the pre-built 3.5.1 image still pulls and completes. The pull request deletes .travis.yml, points the README badge at the new workflow, and shows the tail of each test.sh run with its All Tests Completed line.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add GitHub Actions CI to this CMake repository and retire Travis. Read .travis.yml, test.sh, README.adoc, dockerfiles/ and every pre_test.sh, run_test.sh and post_test.sh first, and list what each example needs: Boost, protobuf, cppcheck, clang-format, scan-build, clang, ninja, conan, CPack. Write .github/workflows/ci.yml with an examples job that runs ./test.sh on a matrix of ubuntu-22.04 and ubuntu-24.04 after installing the apt packages those examples need, with permissions contents: read, a concurrency group that cancels superseded pull request runs and a timeout; and a minimum-cmake job that runs test.sh inside the matrim/cmake-examples:3.5.1 image with docker run from the host, mounting the checkout at /data/code and passing DEV_UID and DEV_GID as .travis.yml did. Where a run_test.sh hard-codes a versioned tool that no current Ubuntu ships, such as scan-build-3.6, use the unversioned name from PATH; leave conan off PATH so the conan examples skip as their scripts already allow, and say in the pull request that they need conan 2. Install the apt list in your sandbox and run ./test.sh; then install docker.io, start dockerd and run the docker run line. Fix one-line breakages in an example and list anything else with its error. Delete .travis.yml, update the README badge, and open a pull request with the tail of each run.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request adds .github/workflows/ci.yml, deletes .travis.yml, edits one line of 04-static-analysis/clang-analyzer/run_test.sh and the badge line of README.adoc. Its description lists the apt packages per example group, pastes the last lines of ./test.sh from the 22.04 and 24.04 sandboxes and from the 3.5.1 container, and names which examples were exercised, which skipped themselves by design (Ninja below the generator floor, the conan pair, the disabled googletest download) and why.

Nothing changes in how a contributor runs the examples locally: test.sh is untouched, every example still builds with mkdir build && cmake .. && make, and the Docker images and their README keep working. The clang-analyzer script now finds scan-build wherever clang-tools installed it instead of a 2015 package name.

Before merging, a reviewer decides whether to keep the minimum-cmake job, which pulls a six-year-old image on every run to prove the 3.5 floor, or to drop it and raise cmake_minimum_required; and whether to take the conan 2 rewrite now, which the pull request scopes as two conanfile.txt files, two run_test.sh scripts and the generator change.

Run it on every repository with no workflow

A team with several C++ repositories sends one POST /o/{org}/sessions per repository from the terminal or a script, with this prompt and the repository in resources, and a request_id that is a UUID v5 of the repository's full name so a retry returns the run already started. GET /o/{org}/github lists every repository the Rush GitHub App installation reaches, so the script can start a run only where .github/workflows/ is empty or a .travis.yml still exists.

Each run reads its own test.sh, CMakeLists.txt files and helper scripts, so a repository that needs Qt gets the Qt packages and one with a conanfile.py on conan 2 gets a conan install step rather than a skip, and each opens its own pull request with its own run output.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A CMake test matrix is a list of system packages and tool names that drift: the tutorial's own containers pin cppcheck 1.79 and clang 3.6, and the only way to know what a 2026 Ubuntu still provides is to install it and run the twenty-seven examples. The agent does that in its own sandbox before the workflow exists, so the first pull request check is one it has already watched pass, and the docker run of the minimum image is tried the same way.

The transcript keeps the apt output, every cmake .. configure log and the All Tests Completed lines, so a reviewer reads where Boost was found and which generator was used without re-running anything. Several repositories can be migrated at once, each in its own sandbox, and nothing merges until a person reads the diff.

Frequently asked questions

Why run the old image with docker run instead of a container job?

GitHub's container: jobs run actions/checkout and the other Node-based actions inside the container, and the 3.5.1 image is Ubuntu 16.04, which cannot run them. Running docker run from the host job with the checkout mounted is what .travis.yml did, needs no action inside the image, and keeps the DEV_UID and DEV_GID handling that dockerfiles/setup.sh expects.

What about the conan examples?

Both 07-package-management/D-conan scripts exit 0 when conan is not on PATH, so they skip on the new runners exactly as they skipped on any machine without conan. Their conanfile.txt uses the conan 1 cmake generator and a bincrafters reference that ConanCenter no longer serves, so making them run means a conan 2 rewrite, which the pull request scopes but does not do.

Will the matrix be slow?

The twenty-seven examples are small C++ programs and the whole test.sh finishes in a few minutes per runner; the two Ubuntu jobs run in parallel and the concurrency group cancels a superseded push. The minimum-image job is bounded by the pull of the image, which the pull request reports from its own run.

Does it change any example to make CI green?

One line: scan-build-3.6 becomes scan-build, because the versioned name exists on no supported Ubuntu and clang-tools installs the unversioned one. Anything else that fails on a current toolchain is listed in the pull request with the error rather than patched quietly, so the maintainer decides.

Can it keep the 3.10.3 image too?

Yes, as a second docker run line in the same job; the prompt keeps only 3.5.1 because it is the floor the cmake_minimum_required lines name and the modern runners already cover a far newer CMake. Adding the second image is one more line in the workflow.

More CMake jobs

The same job on other stacks

Keep reading