Skip to content

Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu… #9784

Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…

Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu… #9784

Workflow file for this run

name: PsyNeuLink CI
on:
schedule:
- cron: "22 2 * * *"
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- 'docs/**'
- 'doc_requirements.txt'
tags-ignore:
- 'v**'
pull_request:
# run only the latest instance of this workflow job for the current branch/PR
# cancel older runs
# fall back to run id if not available (run id is unique -> no cancellations)
concurrency:
group: ci-${{ github.ref || github.run_id }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
# The main test job
build:
runs-on: ${{ (contains(vars.SELF_HOSTED, format(';{0}_{1}_{2}_{3};', matrix.os, matrix.python-version, matrix.python-architecture, matrix.extra-args))
&& fromJSON(format('[ "self-hosted","{0}", "X64", "enabled" ]', matrix.os == 'ubuntu' && 'Linux' || matrix.os)))
|| format('{0}-latest', matrix.os) }}
env:
# Keep DESCRIPTION in sync with the above
DESCRIPTION: ${{ format(';{0}_{1}_{2}_{3};', matrix.os, matrix.python-version, matrix.python-architecture, matrix.extra-args) }}
SELF_HOSTED: ${{ vars.SELF_HOSTED }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.11', '3.12']
python-architecture: ['x64']
extra-args: ['']
os: [ubuntu, macos, windows]
version-restrict: ['']
include:
# code-coverage build on macos python 3.9
- python-version: '3.9'
os: macos
extra-args: '--cov=psyneulink'
# --forked run of python only tests
# Python tests are enough to test potential naming issues
- python-version: '3.9'
os: ubuntu
extra-args: '--forked -m "not llvm"'
# add 32-bit build on windows
- python-version: '3.8'
python-architecture: 'x86'
os: windows
# fp32 run on linux python 3.10
- python-version: '3.10'
os: ubuntu
extra-args: '--fp-precision=fp32'
# --benchmark-enable run on macos python 3.10
- python-version: '3.10'
os: macos
# pytest needs both '--benchmark-only' and '-m benchmark'
# The former fails the test if benchmarks cannot be enabled
# (e.g. due to --dist setting)
# The latter works around a crash in pytest when collecting tests:
# https://github.com/ionelmc/pytest-benchmark/issues/243
extra-args: '-m benchmark --benchmark-enable --benchmark-only --benchmark-min-rounds=2 --benchmark-max-time=0.001 --benchmark-warmup=off -n0 --dist=no'
# add python 3.7 with deps restricted to min supported version
- python-version: '3.7'
python-architecture: 'x64'
os: ubuntu
version-restrict: 'min'
# add python 3.8 build on macos since 3.7 is broken
# https://github.com/actions/virtual-environments/issues/4230
# use default python-architecture
- python-version: '3.8'
os: macos
exclude:
# 3.7 is broken on macos-11,
# https://github.com/actions/virtual-environments/issues/4230
- python-version: '3.7'
os: macos
steps:
# increased fetch-depth and tag checkout needed to get correct
# version string from versioneer (must have history to a prior tag);
# otherwise install fails due to circular dependency with modeci_mdf
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 200
# fetch only master to avoid getting unneeded branches with
# characters invalid on windows
- name: Checkout tags
run: git fetch --tags origin master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-architecture }}
- name: Restrict version of direct dependencies
if: ${{ matrix.version-restrict == 'min' }}
shell: bash
run: |
sed -i '/^[^#]/s/>=/==/' *requirements.txt
git config user.name "github actions"
git config user.email "none"
git commit -a -m "Restrict version of direct dependencies to min"
- name: Get pip cache location
shell: bash
id: pip_cache
run: |
python -m pip install -U pip
python -m pip --version
echo "pip_cache_dir=$(python -m pip cache dir)" | tee -a $GITHUB_OUTPUT
- name: Wheels cache
uses: actions/cache@v4
with:
path: ${{ steps.pip_cache.outputs.pip_cache_dir }}/wheels
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'dev_requirements.txt') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'dev_requirements.txt') }}
- name: Install PNL package
uses: ./.github/actions/install-pnl
id: install
with:
features: 'dev'
- name: Lint with flake8
shell: bash
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Print numpy info
shell: bash
run: |
python -c "import numpy; numpy.show_config()"
- name: Print machine info
shell: bash
run: |
case "$RUNNER_OS" in
Linux*) lscpu; lsmem;;
macOS*) sysctl -a | grep '^hw' ;;
Windows*) wmic cpu get description,currentclockspeed,NumberOfCores,NumberOfEnabledCore,NumberOfLogicalProcessors; wmic memorychip get capacity,speed,status,manufacturer ;;
esac
- name: Test with pytest
timeout-minutes: 180
run: pytest --junit-xml=tests_out.xml --verbosity=0 -n logical ${{ matrix.extra-args }}
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}-${{ matrix.version-restrict }}
path: tests_out.xml
retention-days: 5
if: (success() || failure()) && ! contains(matrix.extra-args, 'forked')
- name: Upload coveralls code coverage
if: contains(matrix.extra-args, '--cov=psyneulink')
shell: bash
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
if [ -n "$COVERALLS_REPO_TOKEN" ]; then
pip install coveralls
coveralls
else
echo "::warning::Not uploading to coveralls.io, token not available!"
fi
- name: Upload dist packages
uses: actions/upload-artifact@v4
if: matrix.version-restrict == ''
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}
path: ${{ steps.install.outputs.wheel }} ${{ steps.install.outputs.sdist }}
retention-days: 2