Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/_reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
if: matrix.os == 'ubuntu-24.04' || matrix.os == 'macos-26'
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DUSE_ONNXRUNTIME=ON -DMNE_WARNINGS_AS_ERRORS=ON
cmake --build build
cmake --build build --parallel "$(nproc 2>/dev/null || sysctl -n hw.logicalcpu)"

- name: Configure and compile MNE-CPP (Windows)
if: matrix.os == 'windows-2025-vs2026'
Expand All @@ -128,7 +128,7 @@ jobs:
cmd.exe /c "call `"$vcvarsPath`" && set > %temp%\vcvars.txt"
Get-Content "$env:temp\vcvars.txt" | Foreach-Object { if ($_ -match "^(.*?)=(.*)$") { Set-Content "env:\$($matches[1])" $matches[2] } }
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DUSE_ONNXRUNTIME=ON -DMNE_WARNINGS_AS_ERRORS=ON
cmake --build build --config Release
cmake --build build --config Release --parallel

- name: Deploy binaries
run: |
Expand Down
67 changes: 66 additions & 1 deletion .github/workflows/_reusable-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ on:
required: false
default: false
type: boolean
os_json:
description: "JSON list of runner OSes to test on"
required: false
default: '["ubuntu-24.04", "macos-26", "windows-2025-vs2026"]'
type: string
save_ccache:
description: "Save the ccache and prune older entries (needs actions: write)"
required: false
default: false
type: boolean
secrets:
CODECOV_TOKEN:
required: false
Expand All @@ -46,7 +56,7 @@ jobs:
fail-fast: false
max-parallel: 3
matrix:
os: [ubuntu-24.04, macos-26, windows-2025-vs2026]
os: ${{ fromJSON(inputs.os_json) }}

steps:
- name: Clone repository
Expand Down Expand Up @@ -164,6 +174,39 @@ jobs:
run: |
python -c "import mne; mne.datasets.sample.data_path()"

# ── Compiler cache (Linux|MacOS) ───────────────────────────────────────
# One entry per OS/Qt/coverage configuration, capped by CCACHE_MAXSIZE.
# Only callers that pass save_ccache write it, and then delete the entries
# they supersede, so the total stays at a few hundred MB per configuration
# instead of growing with every run and evicting the other Actions caches.
- name: Set up ccache (Linux|MacOS)
if: runner.os != 'Windows'
shell: bash
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
sudo apt-get install -q ccache
else
brew install ccache
fi
{
echo "CCACHE_DIR=$RUNNER_TEMP/ccache"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE"
echo "CCACHE_COMPILERCHECK=content"
echo "CCACHE_MAXSIZE=400M"
echo "CMAKE_C_COMPILER_LAUNCHER=ccache"
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache"
# Coverage only changes the compile on Linux, so macOS shares one key.
echo "CCACHE_KEY_PREFIX=ccache-v1-${{ matrix.os }}-qt${{ inputs.qt_version }}-cov${{ runner.os == 'Linux' && inputs.with_code_coverage }}-"
} >> "$GITHUB_ENV"

- name: Restore ccache (Linux|MacOS)
if: runner.os != 'Windows'
uses: actions/cache/restore@v5
with:
path: ${{ runner.temp }}/ccache
key: ${{ env.CCACHE_KEY_PREFIX }}${{ github.run_id }}
restore-keys: ${{ env.CCACHE_KEY_PREFIX }}

# ── Build ──────────────────────────────────────────────────────────────
# MNE_WARNINGS_AS_ERRORS enforces release gate G5 for the test build too, so
# test sources cannot become the loophole through which warnings return.
Expand Down Expand Up @@ -211,6 +254,28 @@ jobs:
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DMNE_WARNINGS_AS_ERRORS=ON
cmake --build build --config Release --parallel

- name: Save ccache (Linux|MacOS)
if: runner.os != 'Windows' && inputs.save_ccache
uses: actions/cache/save@v5
with:
path: ${{ runner.temp }}/ccache
key: ${{ env.CCACHE_KEY_PREFIX }}${{ github.run_id }}

- name: Prune superseded ccache entries (Linux|MacOS)
if: runner.os != 'Windows' && inputs.save_ccache
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
ccache --show-stats || true
current="${CCACHE_KEY_PREFIX}${{ github.run_id }}"
gh cache list --key "$CCACHE_KEY_PREFIX" --ref "$GITHUB_REF" --limit 100 --json id,key \
--jq ".[] | select(.key != \"$current\") | .id" |
while read -r id; do
gh cache delete "$id" || true
done

# ── Run tests ──────────────────────────────────────────────────────────
# CTest drives the run from the add_test() registrations rather than from a
# glob over the binary output directory. A test that is built but written
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/_reusable-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 MNE-CPP Authors
# Christoph Dinh <christoph.dinh@mne-cpp.org>

# Builds the WebAssembly applications and examples (Linux only). Callers that
# publish them pass upload_artifact and deploy the "wasm-build" artifact.

name: Reusable WebAssembly build

on:
workflow_call:
inputs:
upload_artifact:
description: "Upload out/wasm as the wasm-build artifact"
required: false
default: false
type: boolean

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'

jobs:
WasmBuild:
runs-on: ubuntu-24.04

steps:
- name: Clone repository
uses: actions/checkout@v5

- name: Install dependencies
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-*.list /etc/apt/sources.list.d/azure-*.list /etc/apt/sources.list.d/microsoft-*.sources /etc/apt/sources.list.d/azure-*.sources
sudo apt-get update -qq
sudo apt-get install -qq build-essential libgl1-mesa-dev ninja-build

- name: Setup Emscripten
run: |
cd ..
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 4.0.7
./emsdk activate 4.0.7

- name: Load external dependency versions
shell: bash
run: ./scripts/ci/load_external_deps.sh

- name: Download pre-built WASM Qt binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download qt_binaries -p "qt6_${QT_VERSION_TOKEN}_static_binaries_wasm.tar.gz" -D /tmp
mkdir -p "${RUNNER_TOOL_CACHE}/Qt/${QT_VERSION}/wasm_multithread"
tar xf "/tmp/qt6_${QT_VERSION_TOKEN}_static_binaries_wasm.tar.gz" -C "${RUNNER_TOOL_CACHE}/Qt/${QT_VERSION}/wasm_multithread"
echo "Qt6_DIR=${RUNNER_TOOL_CACHE}/Qt/${QT_VERSION}" >> "$GITHUB_ENV"

- name: Download host Qt binaries for cross-compilation
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download qt_binaries -p "qt6_${QT_VERSION_TOKEN}_static_binaries_linux.tar.gz" -D /tmp
mkdir -p "${RUNNER_TOOL_CACHE}/Qt/${QT_VERSION}/gcc_64"
tar xf "/tmp/qt6_${QT_VERSION_TOKEN}_static_binaries_linux.tar.gz" -C "${RUNNER_TOOL_CACHE}/Qt/${QT_VERSION}/gcc_64"

- name: Download Eigen package
env:
GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
run: |
./scripts/ci/download_toolchain.sh \
--kind eigen \
--version "$EIGEN_VERSION" \
--output-dir "$GITHUB_WORKSPACE/src/external/eigen"

- name: Download ONNX Runtime (WASM)
env:
GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
run: |
./scripts/ci/download_toolchain.sh \
--kind onnxruntime \
--version "$ONNXRUNTIME_VERSION" \
--platform wasm \
--output-dir "$GITHUB_WORKSPACE/src/external/onnxruntime"

- name: Clone Skigen
run: ./scripts/ci/clone_skigen.sh

- name: Build WASM
run: |
source ../emsdk/emsdk_env.sh
./scripts/wasm/wasm.sh --emsdk 4.0.7

- name: Prepare WASM artifacts
run: |
rm -rf out/wasm/bin/mne_analyze_plugins
rm -rf resources/data
cp resources/design/logos/qtlogo.svg out/wasm/bin/qtlogo.svg
if [ -d "out/wasm/examples" ]; then
cp resources/design/logos/qtlogo.svg out/wasm/examples/qtlogo.svg
fi
# Replace bare Qt HTML with branded loading screens & inject COOP/COEP SW
./scripts/wasm/wasm_postbuild.sh out/wasm/bin
if [ -d "out/wasm/examples" ]; then
./scripts/wasm/wasm_postbuild.sh out/wasm/examples
fi

- name: Upload WASM build
if: inputs.upload_artifact
uses: actions/upload-artifact@v7
with:
name: wasm-build
path: out/wasm
retention-days: 1
9 changes: 7 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@

name: "CodeQL"

# Not run on pushes to staging: the shared mne-tools runner pool cannot absorb
# an analysis per push, and the weekly schedule covers staging. The analysis
# keeps a real build so moc/uic output and template instantiations are seen.
on:
push:
branches: [ "main", "staging" ]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '28 15 * * 1'
workflow_dispatch:

concurrency:
group: codeql-${{ github.ref }}
Expand Down Expand Up @@ -83,6 +87,7 @@ jobs:
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: manual
# Disable CodeQL TRAP caching: each cache entry is ~3.7 GB and two of
# them (~7.4 GB) dominate the repo's 10 GB Actions cache budget, evicting
# the Qt/sample-data caches via LRU and forcing unnecessary re-downloads.
Expand All @@ -100,7 +105,7 @@ jobs:
- name: Configure and compile MNE-CPP
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --build build --parallel "$(nproc)"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# Triggered on pull requests targeting `staging` or `main`.
#
# This is the FEATURE BRANCH pipeline:
# • Verifies the project builds across all platforms
# • Tests min + max supported Qt versions
# • Runs the full test suite (without coverage — that's done on staging)
# • Runs the full test suite on all platforms with the maximum supported Qt
# (without coverage — that's done on staging)
# • Runs it with the minimum supported Qt on Linux
# • No deployments, no releases
#
# Branch model: Feature → Staging → Main
Expand All @@ -34,17 +34,10 @@ env:

jobs:

# ── Build compatibility: minimum supported Qt ────────────────────────────
BuildMinQt:
uses: ./.github/workflows/_reusable-build.yml
with:
qt_version: min

# ── Build compatibility: maximum supported Qt ────────────────────────────
BuildMaxQt:
uses: ./.github/workflows/_reusable-build.yml
with:
qt_version: max
# No separate min/max Qt build-only jobs: the test jobs compile the same tree
# with the same warnings-as-errors flags. The runner pool is shared by the
# whole mne-tools organization (and only 5 macOS jobs run at once), so
# duplicate builds delay every repository's CI.

# ── Tests (no coverage collection) ──────────────────────────────────────
Tests:
Expand All @@ -53,10 +46,12 @@ jobs:
with_code_coverage: false
upload_codecov: false

# Min-Qt on Linux; release PRs into main test it on all three OSes.
TestsMinQt:
uses: ./.github/workflows/_reusable-tests.yml
with:
qt_version: min
os_json: ${{ github.base_ref == 'main' && '["ubuntu-24.04", "macos-26", "windows-2025-vs2026"]' || '["ubuntu-24.04"]' }}

# ── Quality gates (static, no build) ────────────────────────────────────
Quality:
Expand Down Expand Up @@ -123,3 +118,8 @@ jobs:
channel: stable
secrets: inherit

# ── WebAssembly build (Linux only, no deployment) ───────────────────────
WasmBuild:
uses: ./.github/workflows/_reusable-wasm.yml
secrets: inherit

Loading
Loading