Skip to content

Add C++ DynamicArrays in Brian2 for runtime mode #1525

Add C++ DynamicArrays in Brian2 for runtime mode

Add C++ DynamicArrays in Brian2 for runtime mode #1525

Workflow file for this run

name: TestSuite
on: [push, pull_request]
jobs:
get_python_versions:
name: "Determine Python versions"
runs-on: ubuntu-latest
outputs:
min-python: ${{ steps.nep29.outputs.min-python }}
max-python: ${{ steps.nep29.outputs.max-python }}
steps:
- name: "calculate versions according to NEP29"
id: nep29
uses: mstimberg/github-calc-nep29@a73481e4e8488a5fa0b3be70a385cc5206a261ba # v0.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
pre-commit:
name: Run linters with pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: .devcontainer/dev-requirements.txt
- name: Install deps
run: pip3 install -r .devcontainer/dev-requirements.txt
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
testing:
needs: [get_python_versions, pre-commit]
name: "Python ${{ matrix.python-version }} on ${{ matrix.os.image }} (standalone: ${{ matrix.standalone }}, 32bit: ${{ matrix.float_dtype_32 }})"
runs-on: ${{ matrix.os.image }}
strategy:
fail-fast: false
matrix:
os: [{image: ubuntu-24.04, triplet: x64-linux},
{image: windows-2022, triplet: x64-windows},
{image: macOS-13, triplet: x64-osx},
{image: macOS-14, triplet: arm64-osx}]
standalone: [false, true]
float_dtype_32: [false, true]
python-version: ["${{ needs.get_python_versions.outputs.max-python }}"]
include:
- os: {image: ubuntu-24.04, triplet: x64-linux}
standalone: false
python-version: "${{ needs.get_python_versions.outputs.min-python }} < 3.11.9 || ${{ needs.get_python_versions.outputs.min-python }} >= 3.12"
float_dtype_32: false
- os: {image: ubuntu-24.04, triplet: x64-linux}
standalone: true
python-version: "${{ needs.get_python_versions.outputs.min-python }} < 3.11.9 || ${{ needs.get_python_versions.outputs.min-python }} >= 3.12"
float_dtype_32: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Install GSL
uses: johnwason/vcpkg-action@ff71808de10afc0e3160fd079353c69ba0d7dd60 # v7.0.0
id: vcpkg
with:
pkgs: gsl
triplet: ${{ matrix.os.triplet }}
cache-key: gsl-${{ matrix.os.triplet }}
revision: master
token: ${{ github.token }}
- name: Set GSL preference for vcpkg
shell: bash
run: |
mkdir ~/.brian/
# Replaces backslashes with forward slashes
echo "GSL.directory=\"${{ github.workspace }}\\vcpkg\\installed\${{ matrix.os.triplet }}\\include"\" | tr '\\' '/' > ~/.brian/user_preferences
cat ~/.brian/user_preferences
- name: Install Python
id: python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
cache: 'pip'
python-version: ${{ matrix.python-version }}
- name: Install Brian2 and dependencies
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
run: |
"$PYTHON_BINARY" -m pip install .[test]
- name: Determine Cython cache dir
id: cython-cache
run: |
cd $GITHUB_WORKSPACE/.. # move out of the workspace to avoid direct import
CACHE_DIR=$("$PYTHON_BINARY" -c 'from brian2.codegen.runtime.cython_rt.extension_manager import get_cython_cache_dir; print(get_cython_cache_dir())')
echo "Cython cache dir: $CACHE_DIR"
echo "cachedir=$CACHE_DIR" >> "$GITHUB_OUTPUT"
env:
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
- name: restore Cython cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: ${{ ! matrix.standalone }}
with:
key: cython-extensions-${{ matrix.os.image }}-${{ matrix.python-version }}-32bit-${{ matrix.float_dtype_32 }}
path: ${{ steps.cython-cache.outputs.cachedir }}
- name: Run Tests
run: |
cd $GITHUB_WORKSPACE/.. && \
"$PYTHON_BINARY" $GITHUB_WORKSPACE/$SCRIPT_NAME && \
cp coverage.xml $GITHUB_WORKSPACE/
env:
SCRIPT_NAME: dev/continuous-integration/run_test_suite.py
SPHINX_DIR: ${{ github.workspace }}/docs_sphinx
AGENT_OS: ${{runner.os}}
STANDALONE: ${{ matrix.standalone }}
FLOAT_DTYPE_32: ${{ matrix.float_dtype_32 }}
PYTHON_BINARY: ${{ steps.python.outputs.python-path }}
DO_NOT_RESET_PREFERENCES: true # Make sure that GSL setting is used
- name: Send coverage to Coveralls (parallel)
if: ${{ startsWith(matrix.os.image, 'ubuntu-') && matrix.python-version == needs.get_python_versions.outputs.max-python }}
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel: true
flag-name: run ${{ join(matrix.*, ' - ') }}
coveralls:
name: Indicate completion to coveralls.io
needs: testing
runs-on: ubuntu-latest
steps:
- name: Close parallel build
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel-finished: true
test_doc_build:
needs: get_python_versions
name: Test building the documentation
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Setup Conda and Python
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
conda-remove-defaults: true
auto-update-conda: true
auto-activate-base: false
miniforge-version: latest
activate-environment: 'test_env'
python-version: "${{ needs.get_python_versions.outputs.max-python }}"
- name: Install dependencies
run: pip install -r rtd-requirements.txt
- name: Install brian2
run: pip install .
- name: Build HTML documentation
run: |
cd docs_sphinx
sphinx-build -b html . ../docs
env:
READTHEDOCS: True