Skip to content

Support Python3.13, use caching (#47) #202

Support Python3.13, use caching (#47)

Support Python3.13, use caching (#47) #202

Workflow file for this run

name: raven-hydro Testing Suite
on:
push:
branches:
- main
pull_request:
concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on main.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
black:
name: Code linting
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Python3
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"
cache: "pip"
- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
build:
name: Python${{ matrix.python-version }} (${{ matrix.os }}, conda=${{ matrix.conda }}, args=${{ matrix.install_args }})
needs: black
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
os:
- ubuntu-latest
# - macos-latest # macOS with Apple Silicon is not supported yet
conda: [ false ]
install_args: [ "" ]
include:
- python-version: "3.8"
os: windows-latest
conda: true
- python-version: "3.9"
os: ubuntu-latest
conda: true
- python-version: "3.10"
os: ubuntu-latest
conda: true
- python-version: "3.10"
os: windows-latest
conda: true
# - python-version: "3.10" # macOS with Apple Silicon is not supported yet
# os: macos-latest
# conda: true
- python-version: "3.11"
os: ubuntu-latest
conda: false
install_args: "-Ccmake.define.USE_NETCDF=false"
- python-version: "3.12"
os: ubuntu-latest
conda: true
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
submodules: true
- name: Setup Python${{ matrix.python-version }}
if: ${{ !matrix.conda }}
id: pyinstalled
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set up Python${{ matrix.python-version }} with NetCDF4 (conda)
if: ${{ matrix.conda }}
uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
- name: Install NetCDF4 (Ubuntu/apt)
if: (matrix.os == 'ubuntu-latest') && (!matrix.install_args) && (!matrix.conda)
run: |
sudo apt-get update
sudo apt-get install libnetcdf-dev
- name: Install NetCDF4 (macOS/homebrew)
if: (matrix.os == 'macos-latest') && (!matrix.conda)
uses: tecolicom/actions-use-homebrew-tools@b9c066b79607fa3d71e0be05d7003bb75fd9ff34 # v1.3.0
with:
tools: netcdf
cache: yes
- name: Check for OPeNDAP Support
if: (!matrix.install_args)
run: |
nc-config --has-dap
- name: Install raven-hydro
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -m pip install --editable . ${{ matrix.install_args }}
- name: Check versions
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -m pip list
${{ steps.pyinstalled.outputs.python-path }} -m pip check || true
- name: Test raven-hydro
if: ${{ !matrix.conda }}
run: |
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
${{ steps.pyinstalled.outputs.python-path }} -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Install raven-hydro (conda)
if: ${{ matrix.conda }}
run: |
python -m pip install --editable . ${{ matrix.install_args }}
- name: Check versions
if: ${{ matrix.conda }}
run: |
micromamba list
python -m pip list
python -m pip check || true
- name: Test raven-hydro (conda)
if: ${{ matrix.conda }}
run: |
python -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
python -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
python -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
python -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Test raven
run: |
raven -v