build #307
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
name: build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "rabpro/**" | |
- "tests/**" | |
- .coveragerc | |
- setup.py | |
- environment.yml | |
- .github/workflows/build.yaml | |
pull_request: | |
paths: | |
- "rabpro/**" | |
- .github/workflows/build.yaml | |
schedule: | |
- cron: '0 0 10 * *' # run workflow at 12AM on tenth day of every month | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest , macos-latest] # windows-latest | |
python-version: [3.9] | |
include: | |
# All paths are relative to $HOME | |
- os: ubuntu-latest | |
data-path: .local/share/rabpro/ | |
- os: macos-latest | |
data-path: Library/Application Support/rabpro/ | |
# - os: windows-latest | |
# data-path: AppData/Local/rabpro/rabpro/ | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Cache conda | |
uses: actions/cache@v4 | |
env: | |
# Increase this value to reset cache if environment.yml has not changed | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/conda_pkgs_dir/ | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
${{ runner.os }}-conda- | |
${{ runner.os }}- | |
- name: Set up conda environment | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
miniforge-variant: Mambaforge | |
activate-environment: rabpro | |
environment-file: environment.yml | |
channels: conda-forge | |
auto-activate-base: false | |
use-only-tar-bz2: true # needs to be set for caching to work | |
- name: Install dependencies and rabpro | |
run: | | |
conda info | |
conda list | |
pip install coverage | |
pip install pytest | |
pip install . | |
- name: Set up credentials | |
run: | | |
mkdir -p "$HOME/.config/earthengine" | |
echo "$EARTH_ENGINE_KEY" > "$HOME/.config/earthengine/credentials" | |
env: | |
EARTH_ENGINE_KEY: ${{ secrets.EARTH_ENGINE_SECRET }} | |
- name: Set up data | |
run: | | |
mkdir -p "$HOME/$DATA_PATH" | |
cp -r ./tests/data/MERIT_Hydro ./tests/data/HydroBasins "$HOME/$DATA_PATH" | |
env: | |
DATA_PATH: ${{ matrix.data-path }} | |
- name: Run unit tests | |
run: | | |
python -m pytest | |
# coverage run -m pytest | |
# coverage report -m |