Skip to content

Tests

Tests #284

Workflow file for this run

# Based on github template: https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml
name: Tests
on:
schedule:
- cron: '0 9 * * 1' # run every Monday at 9 AM UTC (3 am PST)
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.python-version }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: ['3.11', '3.10'] # ['3.8', '3.x']
exclude:
# tests with ubuntu-latest, python latest
# are executed by build_docs.yaml
- os: ubuntu-latest
python-version: 3.11
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Fetch all Git tags
run: git fetch --prune --unshallow --tags
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@main
with:
environment-file: ci/test_environment.yaml
cache-environment: true
cache-downloads: true
# persist on the same day.
cache-environment-key: environment-${{ steps.date.outputs.date }}
cache-downloads-key: downloads-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.python-version }}
init-shell: >-
bash
powershell
- name: Conda info
shell: bash -l {0}
run: micromamba info
- name: Add executables to path
shell: bash
run: |
if [[ ! -d "$HOME/.local/bin" ]]; then
mkdir -p "$HOME/.local/bin";
fi
# copy modflow bins to local dir to add to PATH later
if [ "$RUNNER_OS" == "Windows" ]; then
d="win"
elif [ "$RUNNER_OS" == "macOS" ]; then
d="mac"
elif [ "$RUNNER_OS" == "Linux" ]; then
d="linux"
else
d="unexpectedos"
exit 1
fi
cp -r bin/$d/. "$HOME/.local/bin/"
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo $GITHUB_PATH
- name: Test install from git
shell: bash -l {0}
run: |
pip install git+https://github.com/aleaf/modflow-setup@develop
cd ..
python -c "import mfsetup"
cd modflow-setup
- name: Install Modflow-setup and ipykernel
shell: bash -l {0}
run: |
pip install -e .
python -m ipykernel install --user --name mfsetup_ci --display-name "mfsetup_ci"
- name: Install latest PyPI flopy
shell: bash -l {0}
if: ${{ matrix.python-version == 3.10}}
run: pip install flopy --force-reinstall
- name: Conda list
shell: bash -l {0}
run: |
micromamba list
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: Run tests
shell: bash -l {0}
timeout-minutes: 75
run: |
coverage run -m pytest -v --durations=20 --timeout=300
- name: Upload coverage
shell: bash -l {0}
run: |
coverage report -m
codecov