| 1 |
name: TestSuite |
| 2 |
|
| 3 |
on: [push, pull_request] |
| 4 |
|
| 5 |
permissions: |
| 6 |
contents: read |
| 7 |
|
| 8 |
jobs: |
| 9 |
get_python_versions: |
| 10 |
name: "Determine Python versions" |
| 11 |
runs-on: ubuntu-latest |
| 12 |
permissions: {} |
| 13 |
outputs: |
| 14 |
min-python: ${{ steps.nep29.outputs.min-python }} |
| 15 |
max-python: ${{ steps.nep29.outputs.max-python }} |
| 16 |
steps: |
| 17 |
- name: "calculate versions according to SPEC-0" |
| 18 |
id: nep29 |
| 19 |
uses: mstimberg/github-calc-nep29@a73481e4e8488a5fa0b3be70a385cc5206a261ba # v0.7 |
| 20 |
with: |
| 21 |
token: ${{ secrets.GITHUB_TOKEN }} |
| 22 |
# Match SPEC-0 |
| 23 |
deprecate-python-after: 36 |
| 24 |
min-python-releases: 0 |
| 25 |
|
| 26 |
pre-commit: |
| 27 |
name: Run linters with pre-commit |
| 28 |
runs-on: ubuntu-latest |
| 29 |
steps: |
| 30 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 31 |
with: |
| 32 |
persist-credentials: false |
| 33 |
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 34 |
with: |
| 35 |
python-version: "3.12" |
| 36 |
cache: "pip" |
| 37 |
- name: set PY |
| 38 |
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV |
| 39 |
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 40 |
with: |
| 41 |
path: ~/.cache/pre-commit |
| 42 |
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| 43 |
- name: Install pre-commit |
| 44 |
run: pip3 install pre-commit |
| 45 |
- name: Run pre-commit hooks |
| 46 |
run: pre-commit run --all-files --show-diff-on-failure |
| 47 |
|
| 48 |
testing: |
| 49 |
needs: [get_python_versions, pre-commit] |
| 50 |
name: "Python ${{ matrix.python-version }} on ${{ matrix.os.image }} (standalone: ${{ matrix.standalone }}, 32bit: ${{ matrix.float_dtype_32 }})" |
| 51 |
runs-on: ${{ matrix.os.image }} |
| 52 |
strategy: |
| 53 |
fail-fast: false |
| 54 |
matrix: |
| 55 |
os: |
| 56 |
[ |
| 57 |
{ image: ubuntu-24.04, triplet: x64-linux }, |
| 58 |
{ image: windows-2022, triplet: x64-windows }, |
| 59 |
{ image: macos-15-intel, triplet: x64-osx }, |
| 60 |
{ image: macos-latest, triplet: arm64-osx }, |
| 61 |
] |
| 62 |
standalone: [false, true] |
| 63 |
float_dtype_32: [false, true] |
| 64 |
python-version: ["${{ needs.get_python_versions.outputs.max-python }}"] |
| 65 |
include: |
| 66 |
- os: { image: ubuntu-24.04, triplet: x64-linux } |
| 67 |
standalone: false |
| 68 |
python-version: "${{ needs.get_python_versions.outputs.min-python }}" |
| 69 |
float_dtype_32: false |
| 70 |
- os: { image: ubuntu-24.04, triplet: x64-linux } |
| 71 |
standalone: true |
| 72 |
python-version: "${{ needs.get_python_versions.outputs.min-python }}" |
| 73 |
float_dtype_32: false |
| 74 |
|
| 75 |
defaults: |
| 76 |
run: |
| 77 |
shell: bash -l {0} |
| 78 |
steps: |
| 79 |
- name: Checkout Repository |
| 80 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 81 |
with: |
| 82 |
fetch-depth: 0 |
| 83 |
persist-credentials: false |
| 84 |
- name: Fetch tags |
| 85 |
run: git fetch --tags --force origin |
| 86 |
- name: Install GSL |
| 87 |
uses: johnwason/vcpkg-action@ff71808de10afc0e3160fd079353c69ba0d7dd60 # v7.0.0 |
| 88 |
id: vcpkg |
| 89 |
with: |
| 90 |
pkgs: gsl |
| 91 |
triplet: ${{ matrix.os.triplet }} |
| 92 |
cache-key: gsl-${{ matrix.os.triplet }} |
| 93 |
revision: master |
| 94 |
token: ${{ github.token }} |
| 95 |
- name: Set GSL preference for vcpkg |
| 96 |
shell: bash |
| 97 |
run: | |
| 98 |
mkdir ~/.brian/ |
| 99 |
# Replaces backslashes with forward slashes |
| 100 |
echo "GSL.directory=\"${{ github.workspace }}\\vcpkg\\installed\${{ matrix.os.triplet }}\\include"\" | tr '\\' '/' > ~/.brian/user_preferences |
| 101 |
cat ~/.brian/user_preferences |
| 102 |
- name: Install Python |
| 103 |
id: python |
| 104 |
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 105 |
with: |
| 106 |
cache: "pip" |
| 107 |
python-version: ${{ matrix.python-version }} |
| 108 |
- name: Install Brian2 and dependencies |
| 109 |
env: |
| 110 |
PYTHON_BINARY: ${{ steps.python.outputs.python-path }} |
| 111 |
run: | |
| 112 |
"$PYTHON_BINARY" -m pip install .[test] |
| 113 |
|
| 114 |
- name: Determine Cython cache dir |
| 115 |
id: cython-cache |
| 116 |
run: | |
| 117 |
cd $GITHUB_WORKSPACE/.. # move out of the workspace to avoid direct import |
| 118 |
CACHE_DIR=$("$PYTHON_BINARY" -c 'from brian2.codegen.runtime.cython_rt.extension_manager import get_cython_cache_dir; print(get_cython_cache_dir())') |
| 119 |
echo "Cython cache dir: $CACHE_DIR" |
| 120 |
echo "cachedir=$CACHE_DIR" >> "$GITHUB_OUTPUT" |
| 121 |
env: |
| 122 |
PYTHON_BINARY: ${{ steps.python.outputs.python-path }} |
| 123 |
|
| 124 |
- name: restore Cython cache |
| 125 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 126 |
if: ${{ ! matrix.standalone }} |
| 127 |
with: |
| 128 |
key: cython-extensions-${{ matrix.os.image }}-${{ matrix.python-version }}-32bit-${{ matrix.float_dtype_32 }} |
| 129 |
path: ${{ steps.cython-cache.outputs.cachedir }} |
| 130 |
|
| 131 |
- name: Run Tests |
| 132 |
run: | |
| 133 |
cd $GITHUB_WORKSPACE/.. && \ |
| 134 |
"$PYTHON_BINARY" $GITHUB_WORKSPACE/$SCRIPT_NAME && \ |
| 135 |
cp coverage.xml $GITHUB_WORKSPACE/ |
| 136 |
env: |
| 137 |
SCRIPT_NAME: dev/continuous-integration/run_test_suite.py |
| 138 |
SPHINX_DIR: ${{ github.workspace }}/docs_sphinx |
| 139 |
AGENT_OS: ${{runner.os}} |
| 140 |
STANDALONE: ${{ matrix.standalone }} |
| 141 |
FLOAT_DTYPE_32: ${{ matrix.float_dtype_32 }} |
| 142 |
PYTHON_BINARY: ${{ steps.python.outputs.python-path }} |
| 143 |
DO_NOT_RESET_PREFERENCES: true # Make sure that GSL setting is used |
| 144 |
- name: Send coverage to Coveralls (parallel) |
| 145 |
if: ${{ startsWith(matrix.os.image, 'ubuntu-') && matrix.python-version == needs.get_python_versions.outputs.max-python }} |
| 146 |
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 |
| 147 |
with: |
| 148 |
parallel: true |
| 149 |
flag-name: run ${{ join(matrix.*, ' - ') }} |
| 150 |
|
| 151 |
coveralls: |
| 152 |
name: Indicate completion to coveralls.io |
| 153 |
needs: testing |
| 154 |
runs-on: ubuntu-latest |
| 155 |
steps: |
| 156 |
- name: Close parallel build |
| 157 |
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 |
| 158 |
with: |
| 159 |
parallel-finished: true |
| 160 |
|
| 161 |
test_doc_build: |
| 162 |
needs: get_python_versions |
| 163 |
name: Test building the documentation |
| 164 |
runs-on: ubuntu-latest |
| 165 |
defaults: |
| 166 |
run: |
| 167 |
shell: bash -l {0} |
| 168 |
steps: |
| 169 |
- name: Checkout Repository |
| 170 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 171 |
with: |
| 172 |
fetch-depth: 0 |
| 173 |
persist-credentials: false |
| 174 |
submodules: true |
| 175 |
- name: Fetch tags |
| 176 |
run: git fetch --tags --force origin |
| 177 |
- name: Setup Conda and Python |
| 178 |
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 |
| 179 |
with: |
| 180 |
conda-remove-defaults: true |
| 181 |
auto-update-conda: true |
| 182 |
auto-activate-base: false |
| 183 |
miniforge-version: latest |
| 184 |
activate-environment: "test_env" |
| 185 |
python-version: "${{ needs.get_python_versions.outputs.max-python }}" |
| 186 |
|
| 187 |
- name: Install dependencies |
| 188 |
run: pip install -r rtd-requirements.txt |
| 189 |
|
| 190 |
- name: Install brian2 |
| 191 |
run: pip install . |
| 192 |
|
| 193 |
- name: Build HTML documentation |
| 194 |
run: | |
| 195 |
cd docs_sphinx |
| 196 |
sphinx-build -b html . ../docs |
| 197 |
env: |
| 198 |
READTHEDOCS: True |