Skip to content

Python Testing

Python Testing #102

Workflow file for this run

# 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: Python Testing
on: [push]
jobs:
resources:
runs-on: ubuntu-latest
steps:
- name: Setup test-resources/
run: |
mkdir test-resources/
- name: Download IMG
run: curl "https://hirise-pds.lpl.arizona.edu/PDS/EDR/PSP/ORB_010500_010599/PSP_010502_2090/PSP_010502_2090_RED5_0.IMG" -o test-resources/PSP_010502_2090_RED5_0.img
- name: Tar file
run: tar -cvf img.tar test-resources/
- name: Upload img artifact
uses: actions/upload-artifact@v4
with:
name: img-artifact
path: img.tar
retention-days: 3
build:
needs: resources
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
# isis 4.4.0 apparently needs jpeg 9b, which is missing
# isis-version: 5.0.2 and 6.0.0 don't have a high enough Python for pyproject.toml
isis-version: [7.2.0, 8.0.3]
steps:
- name: Conda setup
uses: mamba-org/setup-micromamba@v1
with:
environment-name: isis
create-args: >-
isis=${{ matrix.isis-version }}
condarc: |
channels:
- usgs-astrogeology
- conda-forge
channel-priority: flexible
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Download IMG artifact
uses: actions/download-artifact@v4
with:
name: img-artifact
- name: Unpack Tar
run: |
tar -xvf img.tar
ls -R
- name: Lint with flake8
run: |
micromamba activate isis
micromamba install -y flake8
# stop the build if there are Python syntax errors or undefined names
flake8 kalasiris tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 kalasiris tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test Install
run: pip install -e .
- name: Test with pytest
run: |
micromamba activate isis
export ISISROOT=$MAMBA_ROOT_PREFIX/envs/isis
export ISISDATA=$MAMBA_ROOT_PREFIX/envs/isis
micromamba install -y pytest
python --version
pytest