Skip to content

Refactor and clean up codebase by removing unused functions and legac… #127

Refactor and clean up codebase by removing unused functions and legac…

Refactor and clean up codebase by removing unused functions and legac… #127

Workflow file for this run

name: Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
miniforge-variant: Miniforge3
use-mamba: true
- name: Install conda dependencies (with retry via mamba)
shell: bash -l {0}
run: |
conda config --set channel_priority strict
for attempt in {1..5}; do \
mamba install -y \
gdal proj geos libspatialindex \
fiona rasterio shapely pyproj rtree \
geopandas llvmlite numba osmnx && break || { \
echo "mamba install failed (attempt $attempt). Retrying in 15s..."; \
sleep 15; \
}; \
done
- name: Install package with dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
python -m pip install .
- name: Setup Earth Engine authentication (if credentials available)
shell: bash -l {0}
env:
GEE_KEY: ${{ secrets.SAEETEST }}
run: |
if [ -n "${GEE_KEY}" ]; then
echo "${GEE_KEY}" > /tmp/gee-key.json
echo "GOOGLE_APPLICATION_CREDENTIALS=/tmp/gee-key.json" >> $GITHUB_ENV
python -c 'import os,ee,json; key_data=json.load(open("/tmp/gee-key.json")); os.environ.setdefault("GOOGLE_APPLICATION_CREDENTIALS","/tmp/gee-key.json"); credentials=ee.ServiceAccountCredentials(email=key_data["client_email"], key_file="/tmp/gee-key.json"); ee.Initialize(credentials); ee.data.getAssetRoots(); print("Earth Engine initialized successfully")'
echo "GEE_AUTHENTICATED=true" >> $GITHUB_ENV
else
echo "GEE_AUTHENTICATED=false" >> $GITHUB_ENV
echo "No GEE credentials found - Earth Engine tests will be skipped"
fi
- name: Run all tests with coverage
shell: bash -l {0}
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
run: |
pytest --cov=voxcity --cov-report=xml -v
- name: Upload coverage reports to Codecov
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # <-- Add repo secret in GitHub: CODECOV_TOKEN
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
verbose: true