Skip to content

docs(cookbook): Add SPDX headers and tidy functional_field_ops.md #44

docs(cookbook): Add SPDX headers and tidy functional_field_ops.md

docs(cookbook): Add SPDX headers and tidy functional_field_ops.md #44

Workflow file for this run

# SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
# SPDX-License-Identifier: AGPL-3.0-or-later
name: CI
on:
push:
branches: [ "master", "main", "develop" ]
pull_request:
branches: [ "master", "main" ]
# Cancel in-progress runs when a new workflow with the same group name starts
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ============================================================================
# Code Quality Checks
# ============================================================================
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Check code formatting (clang-format)
uses: ahojukka5/clang-format-action@main
with:
clang-format-version: '16'
check-path: '.'
exclude-regex: '(build|\.cache|extern|third[-_]party|doxygen-awesome-css)'
fail-on-error: 'false'
- name: Clean up clang-format artifacts
run: rm -f failing-files.txt
- name: Check REUSE compliance
uses: fsfe/reuse-action@v2
# ============================================================================
# Clang-Tidy Static Analysis
# ============================================================================
clang-tidy:
name: Clang-Tidy Analysis
runs-on: ubuntu-latest
continue-on-error: true # Make non-blocking - informative only
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cmake \
ninja-build \
clang-tidy-16 \
clang-tools-16 \
libopenmpi-dev \
openmpi-bin \
libfftw3-dev \
libfftw3-mpi-dev \
nlohmann-json3-dev
- name: Configure (Debug with compile_commands)
run: |
cmake -S . -B build-tidy -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DHeffte_FIND_VERSION=2.4.1
- name: Run clang-tidy (run-clang-tidy-16 if available)
run: |
if command -v run-clang-tidy-16 >/dev/null 2>&1; then
# Exclude third-party code from analysis
run-clang-tidy-16 -p build-tidy -quiet \
-header-filter='include/openpfc/.*' \
'src/.*\.cpp$' \
'apps/.*\.cpp$' \
'tests/.*\.cpp$' || echo "⚠️ Clang-tidy found issues (non-blocking)"
else
echo "run-clang-tidy-16 not found; falling back to per-file analysis"
find src apps tests -name "*.cpp" | while read -r file; do
clang-tidy-16 -p build-tidy --quiet \
-header-filter='include/openpfc/.*' \
"$file" || echo "⚠️ Issues in $file"
done
fi
# ============================================================================
# Nix Build and Test
# ============================================================================
nix-check:
name: Nix Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install Nix
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run Nix flake checks
run: nix flake check --print-build-logs
- name: Run tests (excluding benchmarks)
run: |
# Run tests with verbose output
nix run .#test -- '~[benchmark]' --reporter compact || {
echo "❌ Tests failed. Checking test binary..."
nix build .#openpfc-tests --print-build-logs
echo "Test binary location:"
nix path-info .#openpfc-tests
exit 1
}
# ============================================================================
# CMake Build Matrix
# ============================================================================
build-and-test:
name: ${{ matrix.os }} / ${{ matrix.compiler }} / ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
compiler: [gcc-11, gcc-13, clang-14, clang-16]
build_type: [Debug, Release]
exclude:
# Reduce matrix size - skip some combinations
- build_type: Debug
compiler: clang-14
include:
# Add specific compiler versions for each
- compiler: gcc-11
cc: gcc-11
cxx: g++-11
- compiler: gcc-13
cc: gcc-13
cxx: g++-13
- compiler: clang-14
cc: clang-14
cxx: clang++-14
- compiler: clang-16
cc: clang-16
cxx: clang++-16
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies (Ubuntu)
run: |
sudo apt-get update
# Add LLVM repository for clang-16
if [[ "${{ matrix.compiler }}" == "clang-16" ]]; then
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm.asc
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
fi
# Add toolchain PPA for gcc-13 if needed (Ubuntu 22.04 may not have it by default)
if [[ "${{ matrix.compiler }}" == "gcc-13" ]]; then
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
fi
sudo apt-get install -y \
${{ matrix.cc }} \
${{ matrix.cxx }} \
cmake \
ninja-build \
libopenmpi-dev \
openmpi-bin \
libfftw3-dev \
libfftw3-mpi-dev \
nlohmann-json3-dev
- name: Cache HeFFTe
id: cache-heffte
uses: actions/cache@v4
with:
path: ~/opt/heffte
key: heffte-2.4.0-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}
- name: Build and Install HeFFTe
if: steps.cache-heffte.outputs.cache-hit != 'true'
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
# Download HeFFTe
wget -q https://github.com/icl-utk-edu/heffte/archive/refs/tags/v2.4.0.tar.gz
tar xzf v2.4.0.tar.gz
# Build HeFFTe
cmake -S heffte-2.4.0 -B heffte-build \
-GNinja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_INSTALL_PREFIX=$HOME/opt/heffte \
-DHeffte_ENABLE_FFTW=ON \
-DBUILD_SHARED_LIBS=ON
cmake --build heffte-build -j2
cmake --install heffte-build
- name: Configure OpenPFC
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -S . -B build \
-GNinja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_PREFIX_PATH=$HOME/opt/heffte \
-DOpenPFC_BUILD_TESTS=ON \
-DOpenPFC_BUILD_EXAMPLES=ON \
-DOpenPFC_BUILD_APPS=ON \
-DOpenPFC_BUILD_DOCUMENTATION=OFF
- name: Build OpenPFC
run: cmake --build build -j2
- name: Run Tests
working-directory: build
run: |
# Run tests with verbose output on failure
ctest --output-on-failure -j2 \
--exclude-regex "benchmark" \
--timeout 300
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}
path: build/Testing/Temporary/LastTest.log
# ============================================================================
# Status Check (required for merge)
# ============================================================================
ci-status:
name: CI Status
if: always()
needs: [code-quality, nix-check, build-and-test]
runs-on: ubuntu-latest
steps:
- name: Check all jobs status
run: |
if [[ "${{ needs.code-quality.result }}" != "success" ]]; then
echo "❌ Code quality checks failed"
exit 1
fi
if [[ "${{ needs.nix-check.result }}" != "success" ]]; then
echo "❌ Nix checks failed"
exit 1
fi
if [[ "${{ needs.build-and-test.result }}" != "success" ]]; then
echo "❌ Build and test failed"
exit 1
fi
echo "✅ All CI checks passed"