diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 16be91b..10aa336 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -12,33 +12,63 @@ on: jobs: test: runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} strategy: fail-fast: false matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ macos-latest, ubuntu-latest, windows-latest ] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/checkout@v3 # for the test data + - uses: conda-incubator/setup-miniconda@v2 with: python-version: ${{ matrix.python-version }} + channels: conda-forge + channel-priority: true + activate-environment: test + mamba-version: "*" - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pytest-cov - python -m pip install rasterio "opencv-python-headless<4.8" numpy click tqdm pyyaml - python -m pip list - - 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: Test with pytest - timeout-minutes: 5 + mamba info + mamba list + mamba install -c conda-forge rasterio opencv numpy click tqdm pyyaml pytest pytest-cov + mamba list + - name: Run unit tests run: | python -m pytest --cov=simple_ortho --cov-report=term-missing --cov-report=xml:coverage.xml ./tests + +#jobs: +# test: +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# python-version: ['3.8', '3.9', '3.10', '3.11'] +# os: [ macos-latest, ubuntu-latest, windows-latest ] +# steps: +# - uses: actions/checkout@v3 +# - 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 +# python -m pip install flake8 pytest pytest-cov +# python -m pip install rasterio "opencv-python-headless<4.8" numpy click tqdm pyyaml +# python -m pip list +# - 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: Test with pytest +# timeout-minutes: 5 +# run: | +# python -m pytest --cov=simple_ortho --cov-report=term-missing --cov-report=xml:coverage.xml ./tests # - name: Upload coverage # uses: codecov/codecov-action@v3 # with: diff --git a/tests/conftest.py b/tests/conftest.py index 163adb2..5e3fa45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -298,7 +298,7 @@ def webmerc_egm2008_crs() -> str: @pytest.fixture(scope='session') def rgb_byte_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path: """ An RGB byte checkerboard image with no CRS. """ - src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_byte_src.tif')) + src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_byte_src.tif') create_src(src_filename, im_size, dtype='uint8', count=3) return src_filename @@ -306,7 +306,7 @@ def rgb_byte_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> @pytest.fixture(scope='session') def rgb_float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path: """ An RGB float32 checkerboard image with no CRS. """ - src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_float_src.tif')) + src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_float_src.tif') create_src(src_filename, im_size, dtype='float32', count=3) return src_filename @@ -314,7 +314,7 @@ def rgb_float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> @pytest.fixture(scope='session') def float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path: """ A single band float64 checkerboard image with no CRS. """ - src_filename = Path(tmpdir_factory.mktemp('data').join('float_src.tif')) + src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_src.tif') create_src(src_filename, im_size, dtype='float32', count=1) return src_filename @@ -322,7 +322,7 @@ def float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Pat @pytest.fixture(scope='session') def rgb_byte_utm34n_src_file(tmpdir_factory: pytest.TempdirFactory, pinhole_camera, utm34n_crs) -> Path: """ An RGB byte checkerboard image with UTM zone 34N CRS and bounds 100m below `pinhole_camera`. """ - src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_byte_src.tif')) + src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_byte_src.tif') create_src(src_filename, pinhole_camera._im_size, dtype='uint8', count=3, camera=pinhole_camera, crs=utm34n_crs) return src_filename @@ -333,7 +333,7 @@ def float_utm34n_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_camera, A 2 band float DEM file in UTM zone 34N with no vertical datum. Band 1 is a sinusoidal surface, and band 2, a planar surface. """ - filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_dem.tif')) + filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_dem.tif') create_dem(filename, pinhole_camera, utm34n_crs, resolution=_dem_resolution, dtype='float32') return filename @@ -344,7 +344,7 @@ def float_utm34n_wgs84_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_c A 2 band float DEM file in UTM zone 34N with WGS84 ellipsoid vertical datum. Band 1 is a sinusoidal surface, and band 2, a planar surface. """ - filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_wgs84_dem.tif')) + filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_wgs84_dem.tif') create_dem(filename, pinhole_camera, utm34n_wgs84_crs, resolution=_dem_resolution, dtype='float32') return filename @@ -355,7 +355,7 @@ def float_utm34n_egm96_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_c A 2 band float DEM file in UTM zone 34N with EGM96 geoid vertical datum. Band 1 is a sinusoidal surface, and band 2, a planar surface. """ - filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_egm96_dem.tif')) + filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_egm96_dem.tif') create_dem(filename, pinhole_camera, utm34n_egm96_crs, resolution=_dem_resolution, dtype='float32') return filename @@ -366,7 +366,7 @@ def float_wgs84_wgs84_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_ca A 2 band float DEM file in WGS84 with WGS84 ellipsoid vertical datum. Band 1 is a sinusoidal surface, and band 2, a planar surface. """ - filename = Path(tmpdir_factory.mktemp('data').join('float_wgs84_wgs84_dem.tif')) + filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_wgs84_wgs84_dem.tif') create_dem( filename, pinhole_camera, utm34n_wgs84_crs, resolution=_dem_resolution, dtype='float32', dem_crs='EPSG:4326+4326'