Skip to content

Try to pass some tests #275

Try to pass some tests

Try to pass some tests #275

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Test, build, deploy ImpDAR
on:
workflow_dispatch:
pull_request:
push:
release:
types:
- published
jobs:
Test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
qt5: [true, false]
gdal: [true, false]
seisunix: [true, false]
exclude:
- os: macos-latest
qt5: true
- os: macos-latest
seisunix: true
- os: macos-latest
gdal: true
- os: windows-latest
qt5: true
- os: windows-latest
seisunix: true
- os: windows-latest
gdal: true
- os: macos-latest
python-version: 3.8
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
# testing
python -m pip install flake8 pytest
python -m pip install coverage
python -m pip install mock
# production
python -m pip install wheel
python -m pip install -r requirements.txt
- name: Install optional dependency qt5
if: ${{ matrix.qt5 }}
run: |
sudo apt install -y xvfb x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 pyqt5-dev-tools
python -m pip install pyqt5
python -c 'import PyQt5'
- name: Install optional dependency SeisUnix
if: ${{ matrix.seisunix }}
run: bash install_su.sh
- name: Install optional dependency GDAL
if: ${{ matrix.gdal }}
run: |
sudo apt-get install -y libcurl4-gnutls-dev
sudo apt-get install libgdal-dev=3.4.1+dfsg-1build4
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python -m pip install gdal==3.4.1
- name: Install ImpDAR
run: python -m pip install .
- 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: Run tests GUI
if: ${{ matrix.qt5 }}
run: |
xvfb-run `which coverage` run --source impdar --omit=impdar/tests/*,impdar/lib/analysis/* -m pytest
- name: Run tests no GUI
if: ${{ !matrix.qt5 }}
run: |
coverage run --source impdar --omit=impdar/tests/*,impdar/lib/analysis/* -m pytest
- name: Produce xml coverage
run: coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false # I see no reason to fail over this.
build_wheels:
name: Build wheels on ${{ matrix.os }}
needs: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.18.1
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
needs: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
Upload-PyPi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Upload-Test-PyPi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/