Skip to content

Initial CI/CD, Nix and GTest setup#1

Merged
ujaandas merged 10 commits intomainfrom
chore/lang/setup-cicd
Apr 3, 2026
Merged

Initial CI/CD, Nix and GTest setup#1
ujaandas merged 10 commits intomainfrom
chore/lang/setup-cicd

Conversation

@ujaandas
Copy link
Copy Markdown
Owner

@ujaandas ujaandas commented Apr 3, 2026

This pull request introduces a foundational C++ project structure for the "invariants" project, complete with build tooling, development environment setup, and initial documentation. The changes establish a reproducible and test-driven workflow using Nix, CMake, and GoogleTest, and add basic automation and contribution guidelines.

Project bootstrapping and build system:

  • Added a flake.nix to provide a reproducible Nix-based development environment, including build, test, and formatting tools, as well as shell and app definitions for building and configuring the project.
  • Created lang/CMakeLists.txt to define the CMake build for the C++ project, enabling testing, setting C++23, and building the hello_world executable.
  • Added .clangd and .envrc to configure clangd integration and automatically load the Nix flake environment for development.

Source code and testing:

  • Added a minimal C++ "Hello, world!" program in lang/src/main.cpp and set up a basic GoogleTest-based test in lang/tests/hello_test.cpp with corresponding CMake configuration.

Developer workflow and automation:

  • Introduced a prek.toml configuration for pre-commit hooks, automating code formatting and static analysis with clang-format, clang-tidy, and cppcheck.
  • Added a CONTRIBUTING.md with clear guidelines for TDD, branching, PRs, and project structure to enforce code quality and maintainability.

CI/CD:

  • Added .github/workflows/ci.yml — a GitHub Actions workflow that triggers on pushes and pull requests targeting main. It installs Nix with flakes enabled and runs nix build --show-trace, which automatically executes the full CTest suite via doCheck = true in flake.nix. The job is scoped to contents: read permissions.

Documentation:

  • Updated README.md with a project overview, prerequisites (Nix with flakes), dev-shell entry instructions, the nix run .#configure setup step required for clangd and pre-commit hooks, a build/test command reference table, pre-commit hook installation instructions, and a project layout map.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Bootstraps the new invariants C++ project with a Nix-flake-driven dev/build workflow, a CMake + GoogleTest build/test setup, and initial contributor tooling/docs to support a reproducible, test-first development process.

Changes:

  • Added Nix flake environment (devShell, build/checks, helper app) and locked inputs.
  • Introduced initial CMake project with a hello_world executable and a GoogleTest-based test target.
  • Added developer workflow files: prek hooks config, clangd/direnv integration, gitignore updates, and a CONTRIBUTING guide.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
flake.nix Defines reproducible build/devShell, package/checks/apps outputs for the C++ project
flake.lock Pins Nix inputs for reproducibility
lang/CMakeLists.txt Sets C++23, enables testing, wires in GTest and test subdirectory
lang/src/main.cpp Adds initial hello_world executable source
lang/tests/CMakeLists.txt Adds GTest executable and test discovery
lang/tests/hello_test.cpp Adds initial GoogleTest smoke test
prek.toml Adds pre-commit hook configuration for formatting and static analysis
CONTRIBUTING.md Adds contribution and workflow guidelines
.clangd Configures clangd compilation database location
.envrc Enables direnv to load the flake environment
.gitignore Ignores Nix/direnv artifacts and compile DB output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .clangd Outdated
Comment thread flake.nix Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md
Comment on lines +13 to +15
## 2. Branching & PRs
Always use branches and PRs to trigger GitHub Actions and Copilot reviews.

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The PR metadata and contributing guide reference GitHub Actions/CI being triggered by PRs, but this change set doesn’t add any workflow configuration (there is no .github/workflows directory). Either add the initial CI workflow(s) as part of this PR, or update the PR description/docs to avoid implying CI is already in place.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added .github/workflows/ci.yml in f7ff9f1. The workflow triggers on pushes and PRs to main, installs Nix, and runs nix build --show-trace — which includes the CTest suite automatically because doCheck = true in flake.nix. Explicit contents: read permissions are set on the job.

Comment thread prek.toml
id = "clang-format",
args = ["--style=Google"]
},
{
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The clang-tidy hook hard-codes -p=.nix-dev/build, but that build directory won’t exist on a fresh checkout unless the developer has run the configure step first. This will cause the hook to fail unexpectedly. Consider making the hook create/configure the build dir when missing, or document the required nix run .#configure/CMake configure step in CONTRIBUTING/README.

Suggested change
{
# `clang-tidy` reads compile commands from `.nix-dev/build`.
# On a fresh checkout, run the configure step first (for example
# `nix run .#configure`) so `.nix-dev/build/compile_commands.json` exists.
{

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

@ujaandas ujaandas Apr 3, 2026

Choose a reason for hiding this comment

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

I'll document this properly later. I don't have anything about setup in the readme to begin with so...

ujaandas and others added 3 commits April 3, 2026 02:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ujaandas
Copy link
Copy Markdown
Owner Author

ujaandas commented Apr 3, 2026

@copilot can you update the readme based on what we have right now and what the project is generally about?

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

@copilot can you update the readme based on what we have right now and what the project is generally about?

Done in 17a46a3. The README now covers what the project is, prerequisites (Nix with flakes), dev-shell entry, the nix run .#configure setup step, build/test commands (both Nix sandbox and incremental), pre-commit hook installation, and the project layout.

@ujaandas ujaandas merged commit a68f9dc into main Apr 3, 2026
1 check passed
@ujaandas ujaandas deleted the chore/lang/setup-cicd branch April 10, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants