Update to Raster.dtype
refactorisation and cast_nodata
logic from…
#4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
name: ${{ matrix.os }}, python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
python-version: ["3.9", "3.10", "3.11"] | |
# Run all shells using bash (including Windows) | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
# We initiate the environment empty, and check if a key for this environment doesn't already exist in the cache | |
- name: Initiate empty environment | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
auto-update-conda: true | |
use-mamba: true | |
channel-priority: strict | |
activate-environment: xdem-dev | |
python-version: | |
- name: Get month for resetting cache | |
id: get-date | |
run: echo "cache_date=$(/bin/date -u '+%Y%m')" >> $GITHUB_ENV | |
shell: bash | |
- name: Cache conda env | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CONDA }}/envs | |
key: conda-${{ matrix.os }}-${{ matrix.python-version }}-${{ env.cache_date }}-${{ hashFiles('dev-environment.yml') }}-${{ env.CACHE_NUMBER }} | |
env: | |
CACHE_NUMBER: 0 # Increase this value to reset cache if environment.yml has not changed | |
id: cache | |
# The trick below is necessary because the generic environment file does not specify a Python version, and ONLY | |
# "conda env update" CAN BE USED WITH CACHING, which upgrades the Python version when using the base environment | |
# (we add "graphviz" from dev-environment to solve all dependencies at once, at graphviz relies on image | |
# processing packages very much like geo-packages; not a problem for docs, dev installs where all is done at once) | |
- name: Install base environment with a fixed Python version | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
mamba install pyyaml python=${{ matrix.python-version }} | |
python .github/scripts/generate_yml_env_fixed_py.py --pyv ${{ matrix.python-version }} --add "graphviz,pytransform3d" "environment.yml" | |
mamba env update -n xdem-dev -f environment-ci-py${{ matrix.python-version }}.yml | |
- name: Install project | |
run: pip install -e . --no-dependencies | |
# This steps allows us to check the "import xdem" with the base environment provided to users, before adding | |
# development-specific dependencies by differencing the env and dev-env yml files | |
- name: Check import works with base environment | |
run: | | |
# We unset the PROJ_DATA environment variable to make PROJ work on Windows | |
unset PROJ_DATA | |
python -c "import xdem" | |
# This time, the trick below is necessary because: 1/ "conda update" does not support a file -f as argument | |
# and also 2/ "conda env update" does not support --freeze-installed or --no-update-deps | |
- name: Update environment with development packages if cache does not exist | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
# We unset the PROJ_DATA environment variable to make PROJ work on Windows | |
unset PROJ_DATA | |
pkgs_conda_dev=`python -c "import xdem.misc; xdem.misc.diff_environment_yml('environment.yml', 'dev-environment.yml', 'conda')"` | |
pkgs_pip_dev=`python -c "import xdem.misc; xdem.misc.diff_environment_yml('environment.yml', 'dev-environment.yml', 'pip')"` | |
mamba install $pkgs_conda_dev --freeze-installed | |
if [[ "$pkgs_pip_dev" != "None" ]]; then | |
pip install $pkgs_pip_dev | |
fi | |
- 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: Setup pip dependencies | |
run: pip install pytest-cov coveralls coveragepy-lcov | |
- name: Print conda environment (for debugging) | |
run: | | |
conda info | |
conda list | |
- name: Test with pytest | |
run: | | |
# We unset the PROJ_DATA environment variable to make PROJ work on Windows | |
unset PROJ_DATA | |
pytest -ra --cov=xdem/ | |
# We can skip the conversion step once this PR of pytest is merged: https://github.com/pytest-dev/pytest-cov/pull/536 | |
# and replace pytest argument by --cov-report=lcov | |
- name: Converting coverage to LCOV format | |
run: coveragepy-lcov --data_file_path .coverage --output_file_path coverage.info | |
- name: Upload coverage to Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.github_token }} | |
flag-name: run-${{ matrix.test_number }} | |
path-to-lcov: coverage.info | |
parallel: true | |
finish: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload to Coveralls finished | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.github_token }} | |
parallel-finished: true |