diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 358ab04a..c6e547d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,31 +1,84 @@ +# Run the project's test suite name: Tests on: - # This avoids having duplicate builds for a pull request push: branches: - master + - main + - '*.x' pull_request: branches: - master + - main + - '*.x' jobs: - linux: - name: Linux Py${{ matrix.PYTHON_VERSION }} conda=${{ matrix.USE_CONDA }} - runs-on: ubuntu-latest + test: + name: Test ${{ matrix.os }} Python ${{ matrix.python-version }} conda=${{ matrix.use-conda }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: ${{ matrix.special-invocation }}bash -l {0} env: - CI: True - PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} - USE_CONDA: ${{ matrix.USE_CONDA }} + CI: 'True' + PYTHON_VERSION: ${{ matrix.python-version }} + USE_CONDA: ${{ matrix.use-conda }} + QT_VERSION_ARG: ${{ matrix.qt-version-arg }} strategy: fail-fast: false matrix: - PYTHON_VERSION: ['3.6', '3.8'] - USE_CONDA: ['Yes', 'No'] + include: + - os: ubuntu-latest + python-version: '3.8' + use-conda: 'Yes' + special-invocation: 'xvfb-run --auto-servernum ' + coverage: 'True' + - os: ubuntu-latest + python-version: '3.8' + use-conda: 'No' + special-invocation: 'xvfb-run --auto-servernum ' + - os: ubuntu-latest + python-version: '3.6' + use-conda: 'Yes' + special-invocation: 'xvfb-run --auto-servernum ' + - os: ubuntu-latest + python-version: '3.6' + use-conda: 'No' + special-invocation: 'xvfb-run --auto-servernum ' + - os: windows-latest + python-version: '3.8' + use-conda: 'Yes' + skip-pyside2: true + - os: windows-latest + python-version: '3.8' + use-conda: 'No' + - os: windows-latest + python-version: '3.6' + use-conda: 'Yes' + qt-version-arg: '=5.9' + - os: windows-latest + python-version: '3.6' + use-conda: 'No' + - os: macos-latest + python-version: '3.8' + use-conda: 'Yes' + skip-pyside2: true # No wheel on Windows and Python 3.8? + - os: macos-latest + python-version: '3.8' + use-conda: 'No' + - os: macos-latest + python-version: '3.6' + use-conda: 'Yes' + - os: macos-latest + python-version: '3.6' + use-conda: 'No' steps: - name: Checkout branch uses: actions/checkout@v2 - - name: Install System Packages + - name: Install Linux system packages + if: contains(matrix.os, 'ubuntu') + shell: bash run: | sudo apt update sudo apt install libpulse-dev libegl1-mesa libopengl0 @@ -33,82 +86,28 @@ jobs: uses: conda-incubator/setup-miniconda@v2 with: activate-environment: '' + auto-activate-base: true auto-update-conda: true - auto-activate-base: false - - name: Test PyQt5 + channels: conda-forge + - name: Print Conda info shell: bash -l {0} run: | - eval "$(conda shell.bash hook)" - xvfb-run --auto-servernum bash -l ./.github/workflows/test-pyqt5.sh - - name: Test PySide2 - shell: bash -l {0} - run: xvfb-run --auto-servernum bash -l ./.github/workflows/test-pyside2.sh - - name: Test PySide6 - shell: bash -l {0} - run: xvfb-run --auto-servernum bash -l ./.github/workflows/test-pyside6.sh - - name: Upload coverage - if: matrix.PYTHON_VERSION == '3.8' - shell: bash -l {0} - run: bash -l ./.github/workflows/coverage.sh - - macos: - name: Mac Py${{ matrix.PYTHON_VERSION }} conda=${{ matrix.USE_CONDA }} - runs-on: macos-latest - env: - CI: True - PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} - USE_CONDA: ${{ matrix.USE_CONDA }} - strategy: - fail-fast: false - matrix: - PYTHON_VERSION: ['3.6', '3.8'] - USE_CONDA: ['Yes', 'No'] - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - name: Install Conda - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: '' - auto-update-conda: true - auto-activate-base: false - - name: Test PyQt5 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyqt5.sh - - name: Test PySide2 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyside2.sh - - name: Test PySide6 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyside6.sh - - windows: - name: Windows Py${{ matrix.PYTHON_VERSION }} conda=${{ matrix.USE_CONDA }} - runs-on: windows-latest - env: - CI: True - PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} - USE_CONDA: ${{ matrix.USE_CONDA }} - strategy: - fail-fast: false - matrix: - PYTHON_VERSION: ['3.6', '3.8'] - USE_CONDA: ['Yes', 'No'] - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - name: Install Conda - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: '' - auto-update-conda: true - auto-activate-base: true + conda info + conda list - name: Test PyQt5 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyqt5.sh + if: (! matrix.skip-pyqt5) + run: ./.github/workflows/test.sh pyqt5 - name: Test PySide2 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyside2.sh + if: (! ((matrix.skip-pyside2) || (matrix.use-conda == 'Yes'))) # No conda packages for Pyside2? + run: ./.github/workflows/test.sh pyside2 - name: Test PySide6 - shell: bash -l {0} - run: bash -l ./.github/workflows/test-pyside6.sh + if: (! ((matrix.skip-pyside6) || (matrix.use-conda == 'Yes'))) # No conda packages yet for Pyside6 + run: ./.github/workflows/test.sh pyside6 + - name: Upload coverage data to coveralls.io + if: matrix.coverage + shell: bash + env: + COVERALLS_REPO_TOKEN: 'xh75EzxFFMoTEyNPo3wXxXv8OVkul3eE5' + run: | + python3 -m pip install --upgrade coveralls + python3 -m coveralls --service=github-actions || true diff --git a/.github/workflows/coverage.sh b/.github/workflows/coverage.sh deleted file mode 100755 index f68ecb3e..00000000 --- a/.github/workflows/coverage.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -eval "$(conda shell.bash hook)" -conda deactivate -conda activate test-pyqt5 - -export COVERALLS_REPO_TOKEN="xh75EzxFFMoTEyNPo3wXxXv8OVkul3eE5" -coveralls - -# Don't fail at this step -exit 0 diff --git a/.github/workflows/test-pyqt5.sh b/.github/workflows/test-pyqt5.sh deleted file mode 100755 index cdd68b26..00000000 --- a/.github/workflows/test-pyqt5.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -ex - -# Create conda environment for this test -conda create -n test-pyqt5 -conda activate test-pyqt5 - -# Select build with QtMultimedia -if [ "$(uname)" == "Darwin" ]; then - - if [ "$PYTHON_VERSION" = "3.6" ]; then - export QT_VER=5.12 - else - export QT_VER=5.* - fi - -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - - if [ "$PYTHON_VERSION" = "3.6" ]; then - export QT_VER=5.12 - else - export QT_VER=5.* - fi - -else - - if [ "$PYTHON_VERSION" = "3.6" ]; then - export QT_VER=5.9 - else - export QT_VER=5.* - fi - -fi - -if [ "$USE_CONDA" = "Yes" ]; then - conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge - conda install -q qt=$QT_VER pyqt=$QT_VER -c conda-forge -else - # We are getting segfaults in 5.10 - conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c anaconda - pip install -q pyqt5 PyQtWebEngine -fi - -# Install package -python -m pip install -e . - -# Run tests -python qtpy/tests/runtests.py diff --git a/.github/workflows/test-pyside2.sh b/.github/workflows/test-pyside2.sh deleted file mode 100755 index 46198351..00000000 --- a/.github/workflows/test-pyside2.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -ex - -# Create conda environment for this test -conda create -n test-pyside2 -conda activate test-pyside2 - -if [ "$USE_CONDA" = "Yes" ]; then - # There are no conda packages for PySide2 - exit 0 -elif [ "$PYTHON_VERSION" != "3.6" ] && [ "$RUNNER_OS" = "Windows" ]; then - # There is no wheel for PySide 5.12 on Windows and Python 3.8 - exit 0 -else - # Simple solution to avoid failures with the Qt3D modules - conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge - pip install -q pyside2==5.12 -fi - -# Install package -python -m pip install -e . - -# Run tests -python qtpy/tests/runtests.py diff --git a/.github/workflows/test-pyside6.sh b/.github/workflows/test-pyside6.sh deleted file mode 100755 index eb927888..00000000 --- a/.github/workflows/test-pyside6.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -ex - -# Create conda environment for this test -conda create -n test-pyside6 -conda activate test-pyside6 - -if [ "$USE_CONDA" = "Yes" ]; then - # There are no conda packages for PySide6 - exit 0 -else - # Simple solution to avoid failures with the Qt3D modules - conda install -q coveralls pytest pytest-cov python="$PYTHON_VERSION" -c conda-forge - pip install -q pyside6==6.2.0 -fi - -# Install package -python -m pip install -e . - -# Run tests -python qtpy/tests/runtests.py diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh new file mode 100755 index 00000000..91a6e312 --- /dev/null +++ b/.github/workflows/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash -ex + +# Activate conda properly +eval "$(conda shell.bash hook)" + +# Set conda channel +if [ "$USE_CONDA" = "No" ]; then + CONDA_CHANNEL_ARG="-c anaconda" +fi + +# Create conda environment for this test +conda create -q -n test-${1} ${CONDA_CHANNEL_ARG} python=${PYTHON_VERSION} coveralls pytest pytest-cov +conda activate test-${1} + +if [ "$USE_CONDA" = "Yes" ]; then + conda install -q qt${QT_VERSION_ARG} + + if [ "${1}" = "pyqt5" ]; then + conda install -q pyqt + else + exit 1 + fi + +else + + if [ "${1}" = "pyqt5" ]; then + pip install pyqt5 PyQtWebEngine + elif [ "${1}" = "pyside2" ]; then + pip install pyside2==5.12 + elif [ "${1}" = "pyside6" ]; then + pip install pyside6==6.2 + else + exit 1 + fi + +fi + +# Install package +pip install -e . + +# Print environment information +conda list + +# Run tests +python qtpy/tests/runtests.py