Update cmake-single-platform.yml - #3
Conversation
# Updated CMake Single Platform GitHub Actions Workflow
This repository provides an up-to-date GitHub Actions workflow for building CMake projects on a single platform (Linux, macOS, or Windows). It includes:
- CMake configuration and build
- Caching for dependencies (vcpkg, ccache)
- Multiple build types (Debug, Release)
- Running tests with CTest
- Uploading build artifacts
- Code formatting and linting (optional)
## 📄 Workflow File: `.github/workflows/cmake-single-platform.yml`
```yaml
name: CMake Single Platform Build
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch: # Allow manual trigger
env:
BUILD_TYPE: Release
# Customize CMake build type if needed
jobs:
build:
# Choose the runner: ubuntu-latest, windows-latest, or macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ===== SETUP DEPENDENCIES =====
- name: Install Linux dependencies (if any)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build ccache
# Add other packages as needed
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install ninja ccache
# Add other packages
- name: Install Windows dependencies (using Chocolatey)
if: runner.os == 'Windows'
run: |
choco install ninja ccache
# Or use vcpkg (see below)
# ===== CACHE MANAGEMENT =====
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-ccache-
- name: Cache vcpkg (if used)
if: false # Enable if you use vcpkg
uses: actions/cache@v4
with:
path: |
~/.cache/vcpkg
build/vcpkg_installed
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}
restore-keys: ${{ runner.os }}-vcpkg-
# ===== CONFIGURE & BUILD =====
- name: Configure CMake
run: |
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang # Override compiler if needed (gcc, clang, cl)
CXX: clang++
- name: Build
run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
# ===== TEST =====
- name: Test
working-directory: build
run: ctest -C ${{ env.BUILD_TYPE }} --output-on-failure --parallel
# ===== CODE QUALITY (optional) =====
- name: Run clang-format lint
if: false # Enable if you want formatting checks
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '16'
check-path: 'src'
# ===== ARTIFACTS =====
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ env.BUILD_TYPE }}-binaries
path: |
build/bin
build/lib
build/*.exe
build/*.dll
build/*.so
build/*.dylib
if-no-files-found: ignore
```
## 🔧 Customization Tips
1. **Runner OS**: Change `runs-on` to `windows-latest` or `macos-latest` as needed.
2. **Dependencies**: Adjust package installation steps for your specific libraries.
3. **vcpkg**: If your project uses vcpkg, enable the vcpkg cache step and install vcpkg in a setup step.
4. **Compiler**: Override `CC` and `CXX` environment variables to use different compilers (e.g., `gcc`, `clang`, `msvc`).
5. **Build Types**: You can matrix over `BUILD_TYPE` to build both Debug and Release, or add a strategy matrix.
6. **Artifacts**: Customize the artifact paths to match your output locations.
## 📦 Example with vcpkg and Matrix
If you need multiple build types or configurations, extend with a matrix:
```yaml
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Debug, Release]
env:
BUILD_TYPE: ${{ matrix.build_type }}
steps:
# ... steps (use matrix.os and matrix.build_type)
```
## ✅ Best Practices Included
- **Caching** with ccache and vcpkg speeds up rebuilds.
- **Ninja** generator for faster builds.
- **Parallel** builds and tests.
- **Artifact** upload for easy access to binaries.
- **Manual trigger** (`workflow_dispatch`) for ad-hoc runs.
## 🔗 References
- [GitHub Actions Documentation](https://docs.github.com/actions)
- [CMake Documentation](https://cmake.org/cmake/help/latest/)
- [vcpkg with GitHub Actions](https://vcpkg.io/en/getting-started.html)
---
**Maintainer:** Your Team
**License:** MIT
# Updated Advanced CMake Single/Multi-Platform Workflow
This workflow provides a robust CI pipeline for CMake projects, supporting multiple operating systems and build configurations. It includes caching, testing, code coverage, static analysis, and artifact upload.
## 📄 `.github/workflows/cmake-advanced.yml`
```yaml
name: CMake Advanced CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch: # Allow manual trigger
env:
# Global build type; can be overridden per matrix
BUILD_TYPE: Release
jobs:
build:
name: ${{ matrix.os }} / ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Continue other jobs if one fails
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Debug, Release]
# Optionally exclude some combinations
# exclude:
# - os: windows-latest
# build_type: Debug
steps:
- name: Checkout code
uses: actions/checkout@v4
# ===== DEPENDENCY INSTALLATION =====
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
ninja-build \
ccache \
lcov \
clang-tidy \
curl \
zip
# Add project-specific packages here
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install \
ninja \
ccache \
llvm # provides clang-tidy, lcov
# Ensure llvm binaries are in PATH
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
- name: Install Windows dependencies
if: runner.os == 'Windows'
run: |
choco install ninja ccache
# vcpkg is usually installed on GitHub runners; if needed, bootstrap:
# git clone https://github.com/Microsoft/vcpkg.git
# .\vcpkg\bootstrap-vcpkg.bat
# echo "${{ github.workspace }}/vcpkg" >> $GITHUB_PATH
# ===== CACHE SETUP =====
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ matrix.build_type }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache-${{ matrix.build_type }}-
${{ runner.os }}-ccache-
- name: Cache vcpkg (if used)
if: false # Enable if you use vcpkg.json manifest mode
uses: actions/cache@v4
with:
path: |
~/.cache/vcpkg
${{ github.workspace }}/build/vcpkg_installed
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}
restore-keys: ${{ runner.os }}-vcpkg-
# ===== CONFIGURE CMAKE =====
- name: Configure CMake
shell: bash
run: |
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON # for clang-tidy
# ===== BUILD =====
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel
# ===== RUN TESTS =====
- name: Test
working-directory: build
run: ctest -C ${{ matrix.build_type }} --output-on-failure --parallel
# ===== STATIC ANALYSIS (clang-tidy) =====
- name: Run clang-tidy
if: runner.os == 'Linux' && matrix.build_type == 'Debug' # Run once to avoid duplication
working-directory: build
run: |
# Adjust source directory and checks as needed
run-clang-tidy -p . -extra-arg=-Wno-unknown-warning-option -quiet
# ===== CODE COVERAGE (Linux only) =====
- name: Generate coverage report
if: runner.os == 'Linux' && matrix.build_type == 'Debug' && github.event_name == 'push'
run: |
# Ensure you have built with coverage flags: -fprofile-arcs -ftest-coverage
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
working-directory: build
- name: Upload coverage to Codecov
if: runner.os == 'Linux' && matrix.build_type == 'Debug' && github.event_name == 'push'
uses: codecov/codecov-action@v4
with:
files: build/coverage.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# ===== UPLOAD ARTIFACTS =====
- name: Prepare artifacts
shell: bash
run: |
mkdir -p artifacts
# Copy binaries, libraries, etc.
if [ -d build/bin ]; then cp -r build/bin artifacts/; fi
if [ -d build/lib ]; then cp -r build/lib artifacts/; fi
# Include compile_commands.json for debugging
cp build/compile_commands.json artifacts/ || true
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.build_type }}-artifacts
path: artifacts/
```
## 🚀 Key Features
- **Matrix Build**: Builds on Ubuntu, Windows, and macOS with both Debug and Release configurations.
- **Caching**: Uses `ccache` to speed up rebuilds; vcpkg cache ready.
- **Dependencies**: Installs `ninja`, `ccache`, and platform-specific tools.
- **Static Analysis**: Runs `clang-tidy` (on Linux/Debug once).
- **Code Coverage**: Generates and uploads coverage reports to Codecov (Linux/Debug only).
- **Artifacts**: Uploads binaries, libraries, and `compile_commands.json`.
## 🔧 Customization
- **Add more packages**: Modify the dependency installation steps.
- **Adjust coverage**: Ensure your CMake project enables coverage flags when `CMAKE_BUILD_TYPE` is Debug.
- **vcpkg**: Uncomment the cache step and add a vcpkg installation step if needed.
- **Compiler**: Override `CC`/`CXX` in the configure step to use specific compilers.
- **Artifacts**: Modify the `Prepare artifacts` step to capture your desired output.
## ✅ Best Practices
- **fail-fast: false** allows all matrix jobs to run even if one fails.
- **Conditional steps** avoid redundant work (e.g., coverage only once).
- **Caching keys** use both OS and build type to avoid mixing caches.
- **Parallel** builds and tests reduce CI time.
## 📚 References
- [GitHub Actions Documentation](https://docs.github.com/actions)
- [CMake Documentation](https://cmake.org/documentation)
- [Codecov Action](https://github.com/codecov/codecov-action)
- [clang-tidy Integration](https://clang.llvm.org/extra/clang-tidy/)
---
**Maintainer:** Your Team
**License:** MIT
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Sequence DiagramThis PR replaces the prior CMake and provenance-oriented workflow with a two-stage GitHub Pages pipeline for a Nuxt app. The core flow now builds static Nuxt output, uploads it as a Pages artifact, and deploys it to the GitHub Pages environment. sequenceDiagram
participant Developer
participant Actions
participant BuildJob
participant ArtifactStore
participant DeployJob
participant GitHubPages
Developer->>Actions: Push to main or manual trigger
Actions->>BuildJob: Start build job
BuildJob->>BuildJob: Checkout setup Node install and build Nuxt
BuildJob->>ArtifactStore: Upload static site artifact
Actions->>DeployJob: Start deploy job after build
DeployJob->>GitHubPages: Deploy artifact to pages
GitHubPages-->>Developer: Publish site URL
Generated by CodeAnt AI |
|
CodeAnt AI finished reviewing your PR. |
User description
Updated CMake Single Platform GitHub Actions Workflow
This repository provides an up-to-date GitHub Actions workflow for building CMake projects on a single platform (Linux, macOS, or Windows). It includes:
📄 Workflow File:
.github/workflows/cmake-single-platform.yml🔧 Customization Tips
runs-ontowindows-latestormacos-latestas needed.CCandCXXenvironment variables to use different compilers (e.g.,gcc,clang,msvc).BUILD_TYPEto build both Debug and Release, or add a strategy matrix.📦 Example with vcpkg and Matrix
If you need multiple build types or configurations, extend with a matrix:
✅ Best Practices Included
workflow_dispatch) for ad-hoc runs.🔗 References
Maintainer: Your Team
License: MIT
Updated Advanced CMake Single/Multi-Platform Workflow
This workflow provides a robust CI pipeline for CMake projects, supporting multiple operating systems and build configurations. It includes caching, testing, code coverage, static analysis, and artifact upload.
📄
.github/workflows/cmake-advanced.yml🚀 Key Features
ccacheto speed up rebuilds; vcpkg cache ready.ninja,ccache, and platform-specific tools.clang-tidy(on Linux/Debug once).compile_commands.json.🔧 Customization
CMAKE_BUILD_TYPEis Debug.CC/CXXin the configure step to use specific compilers.Prepare artifactsstep to capture your desired output.✅ Best Practices
📚 References
Maintainer: Your Team
License: MIT
CodeAnt-AI Description
Add GitHub Actions workflow to deploy Nuxt app to GitHub Pages
What Changed
github_pagespreset, and uploads the generated ./.output/public directory to GitHub Pages.Impact
✅ Deploy static Nuxt sites to GitHub Pages✅ Run DB-backed tests during CI✅ Clearer GitHub Pages and Nuxt configuration guidance💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.