Skip to content

Commit

Permalink
ci: add separate windows workflow that uses miniconda (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs authored Jan 7, 2022
1 parent 2eeaf1d commit 831771d
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 45 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: flopy Windows CI

on:
schedule:
- cron: '0 8 * * *' # run at 8 AM UTC (12 am PST)
push:
branches:
- master
- develop
- 'release*'
pull_request:
branches: [master, develop]

jobs:

flopy_setup:
name: standard installation
runs-on: windows-latest
strategy:
fail-fast: false
defaults:
run:
shell: pwsh

steps:

# check out repo
- name: Checkout flopy repo
uses: actions/checkout@v2.3.4

- name: Setup Python 3.9
uses: actions/setup-python@v2.2.2
with:
python-version: 3.9

- name: Upgrade pip and install wheel
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Base flopy installation
run: |
pip install . --use-feature=in-tree-build
- name: Print flopy version
run: |
python -c "import flopy; print(flopy.__version__)"
flopyCI_windows:
name: autotests
needs: [flopy_setup]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9, 3.8, 3.7]
defaults:
run:
shell: pwsh

steps:
# check out repo
- name: Checkout flopy repo
uses: actions/checkout@v2.3.4

- name: Get branch name
uses: nelonoel/branch-name@v1.0.1

- name: Cache Miniconda
uses: actions/cache@v2.1.0
env:
# Increase this value to reset cache if environment.yml has changed
CACHE_NUMBER: 3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.run-type }}-${{ env.CACHE_NUMBER }}-${{ hashFiles('etc/environment.yml') }}

# Standard python fails on windows without GDAL installation
# Using custom bash shell ("shell: bash -l {0}") with Miniconda
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2.1.1
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge
auto-update-conda: true
activate-environment: flopy
use-only-tar-bz2: true

- name: Add packages to flopy environment using conda
run: |
conda env update --name flopy --file etc/environment.yml
- name: Upgrade pip and install wheel
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Install pymake, xmipy, and flopy
run: |
pip install https://github.com/modflowpy/pymake/zipball/master
pip install xmipy
pip install . --use-feature=in-tree-build
- name: Prepare for the autotests
working-directory: ./autotest
run: |
pytest -v ci_prepare.py
# - name: Add executables directory to path on Windows (bash)
# run: |
# echo "C:\Users\runneradmin\.local\bin" >> $GITHUB_PATH

- name: Add executables directory to path on Windows (pwsh)
run: |
echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Run pytest on autotest scripts
working-directory: ./autotest
run: |
pytest -v -n auto --durations=0 --cov=flopy --cov-report=xml
- name: Print coverage report before upload
working-directory: ./autotest
run: |
coverage report
- name: Upload coverage to Codecov
if:
github.repository_owner == 'modflowpy' && github.event_name == 'push'
uses: codecov/codecov-action@v2.1.0
with:
directory: ./autotest
file: coverage.xml
47 changes: 2 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ jobs:
with:
python-version: 3.9

- name: Upgrade pip
- name: Upgrade pip and install wheel
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Base flopy installation
run: |
Expand All @@ -60,9 +61,6 @@ jobs:
- name: Checkout flopy repo
uses: actions/checkout@v2.3.4

# Standard python fails on windows without GDAL installation. Using
# standard python here since only linting on linux.
# Use standard bash shell with standard python
- name: Setup Python 3.8
uses: actions/setup-python@v2.2.2
with:
Expand Down Expand Up @@ -112,14 +110,6 @@ jobs:
python-version: 3.9
run-type: script
test-path: run_scripts.py
- os: windows-latest
python-version: 3.9
run-type: std
test-path: ""
- os: windows-latest
python-version: 3.8
run-type: std
test-path: ""
defaults:
run:
shell: bash
Expand All @@ -142,37 +132,10 @@ jobs:
python -m pip install --upgrade pip
pip install wheel
- name: Install Python packages on Windows
if: runner.os == 'Windows'
run: |
pip install -r etc/requirements.windows.pip.txt
- name: Install Python packages on Linux and MacOS
if: runner.os != 'Windows'
run: |
pip install -r etc/requirements.full.pip.txt
- name: Download Python packages with GDAL dependencies on Windows
if: runner.os == 'Windows'
shell: python
run: |
import os
from gohlkegrabber import GohlkeGrabber
gg = GohlkeGrabber()
wheel_path = os.path.join(".", "wheels")
os.makedirs(wheel_path, exist_ok=True)
gg.retrieve(wheel_path, "gdal")
gg.retrieve(wheel_path, "rasterio")
gg.retrieve(wheel_path, "fiona")
- name: Install Python packages with GDAL dependencies on Windows
if: runner.os == 'Windows'
run: |
ls -ltr ./wheels/
pip install ./wheels/GDAL*
pip install ./wheels/rasterio*
pip install ./wheels/Fiona*
- name: Add jupyter and jupytext to notebooks run
if: matrix.run-type == 'nb'
run: |
Expand All @@ -190,15 +153,9 @@ jobs:
pytest -v ci_prepare.py
- name: Add executables directory to path on Linux and MacOS
if: runner.os != 'Windows'
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Add executables directory to path on Windows
if: runner.os == 'Windows'
run: |
echo "C:\Users\runneradmin\.local\bin" >> $GITHUB_PATH
- name: Run pytest on autotest scripts
if: matrix.run-type == 'std'
working-directory: ./autotest
Expand Down

0 comments on commit 831771d

Please sign in to comment.