Skip to content

Merged release branch updates into dev #5719

Merged release branch updates into dev

Merged release branch updates into dev #5719

Workflow file for this run

name: pytest
on:
workflow_dispatch: # manual
pull_request:
branches: [ release, dev ]
permissions:
contents: read
jobs:
testsuite:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11, ubuntu-latest]
python-version: ['3.8', '3.10']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: get_month
if: runner.os=='Linux'
id: month
run: echo "::set-output name=month::$(date +'%Y-%m')"
- name: cache wxPython for linux
if: runner.os=='Linux'
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.os }}-py${{ matrix.python-version }}-${{ steps.get_month.outputs.month }}
- name: Install Linux system dependencies
if: runner.os=='Linux'
run: |
# mostly for wxPython:
sudo apt-get update
sudo apt-get install -y -qq python3-dev libgtk-3-dev
sudo apt-get install -y -qq libgstreamer1.0-0 gstreamer1.0-plugins-base
sudo apt-get install -y -qq libwebkit2gtk-4.0-dev
sudo apt-get install -y -qq libpng-dev libjpeg-dev libtiff-dev libnotify-dev libsm-dev
sudo apt-get install -y -qq libsdl2-dev libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-2.0-0
sudo apt-get install -y -qq libportaudio2
# virtual frame buffer
sudo apt install llvm-13-dev # for xvfb
sudo apt install xvfb xauth libgl1-mesa-dri
# set up fake sound device?
# sudo apt-get install -y -qq libasound2-dev alsa-utils alsa-oss
# sudo apt-get install -y linux-modules-extra-$(uname -r) # needed for modprobe snd-dummy
# sudo sh .github/workflows/prep_dummy_soundcard.sh # couldn't find that file
# for PyQt:
sudo apt-get install -y -qq libdbus-1-3
sudo apt-get install -y -qq '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
export LIBGL_ALWAYS_INDIRECT=0
export QT_DEBUG_PLUGINS=1 # let us know about missing dependencies?
- name: Pre-Install
run: |
python -m pip install --upgrade pip
pip install wheel
pip install six # for configobj and wxpython
pip install distro # used by createInitFile
pip install attrdict3 # used by wxpython setup
python ./building/plat_custom_installs.py
pip install pdm
# pdm config python.use_venv false # don't need/want venv in a vm!
# pdm install # fetch dependendices in lock file
# pdm add -G tests
# pdm install -G tests
# pdm build
# install with pip both the main and [tests] group
pip install . --prefer-binary # install with pip
pip install '.[tests]' --prefer-binary # optional dependency group
- name: Install plugins
run: |
if [ "${{ runner.os }}" == "macOS" ]
then
# for pocketsphinx we need this adapted package:
brew install swig vlc portaudio portmidi liblo sdl2
fi
# install optional components
pip install psychopy-sounddevice psychopy-pyo psychopy-legacy-mic psychopy-connect psychopy-crs psychopy-emotiv psychopy-gammasci psychopy-mri-emulator
pip install moviepy
# - name: test docs to pdf
# run: |
# pip install sphinx sphinxcontrib-napoleon
# brew install basictex # or mactex
# # update path after brew install
# eval "$(/usr/libexec/path_helper)"
# sudo tlmgr update --self
# sudo tlmgr install latexmk
# sudo tlmgr install collection-fontsrecommended
# sudo tlmgr install collection-fontsextra
# cd docs
# make latexpdf
# cd ..
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# # flake8 . --count --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: Set nice level (linux)
if: runner.os=='Linux'
run: |
# sudo setcap cap_sys_nice=eip ${{ env.pythonLocation }}/python
export PYTHON_EXECUTABLE=`python -c "import os; import sys; print(os.path.realpath(sys.executable))"`
sudo setcap cap_sys_nice+ep ${PYTHON_EXECUTABLE}
getcap ${PYTHON_EXECUTABLE} # did it work?
- name: Test gui toolkits
if: runner.os=='Linux'
run: |
# quick test of the gui toolkits (without pytest swallowing errors)
xvfb-run -a --server-args="-screen 0 1024x768x24" python psychopy/tests/test_gui/test_DlgFromDictQt.py
xvfb-run -a --server-args="-screen 0 1024x768x24" python psychopy/tests/test_gui/test_DlgFromDictWx.py
- name: Test with pytest
run: |
if [ "${{ runner.os }}" == "Linux" ]
then
xvfb-run -a --server-args="-screen 0 1024x768x24" pytest -m "not needs_sound and not needs_wx and not needs_qt and not needs_pygame and not emulator" --cov=psychopy -v psychopy
else
pytest --ignore="psychopy/tests/test_app" --ignore="psychopy/tests/test_preferences" --ignore="psychopy/tests/test_experiment/needs_wx" -m "not needs_sound and not needs_wx and not emulator" --cov=psychopy -v psychopy
fi
- name: upload failed app data
if: always()
uses: actions/upload-artifact@v3
with:
name: prefs for ${{ matrix.os }}_${{ matrix.python-version }}
path: |
~/.psychopy3
!~/.psychopy3/versions
!~/.psychopy3/fonts
- name: upload failed screenshots
if: always()
uses: actions/upload-artifact@v3
with:
name: test artifacts
path: |
psychopy/tests/fails
!**/*.mp4
!psychopy/tests/**/*.data
!**/*.wav
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
# - name: test docs to pdf
# run: |
# pip install sphinx sphinxcontrib-napoleon
# brew install basictex
# # update path after brew install
# eval "$(/usr/libexec/path_helper)"
# # go to the folder and make
# cd docs
# make latexpdf
# cd ..
# - name: Check bdist/sdist
# # checks whether different forms of build work (e.g. missing files in sdist)
# run: |
# python setup.py build
# # Build & install sdist
# python setup.py sdist --formats=gztar
# pip install --no-deps dist/PsychoPy-*.tar.gz
# pip uninstall --yes psychopy
# # Build & install wheel
# python setup.py bdist_wheel
# pip install --no-deps dist/PsychoPy-*.whl
# # uninstall the build (but not the dependencies)
# pip uninstall --yes psychopy
# - name: test docs to pdf
# if: runner.os=='Linux'
# run: |
# sudo apt-get install -y python3-sphinx
# which sphinx-build
# which python
# python -c "import psychopy; psychopy"
# # sudo apt-get install -y latexmk xindy texlive-latex-recommended texlive-xetex texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra
# # cd docs
# # make latexpdf
# # cd ..