Skip to content

Commit

Permalink
Merge pull request #29 from csdms/mdpiper/update-ci-workflows
Browse files Browse the repository at this point in the history
Update CI workflows
  • Loading branch information
mdpiper authored Aug 17, 2024
2 parents 3ef7911 + 79735a3 commit 9b737cf
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 44 deletions.
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
exclude = docs, build, .nox
ignore =
E203
E501
W503
W605
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
8 changes: 6 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Documentation

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:

build:
Expand All @@ -13,9 +17,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: 3.11
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/format.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Format
name: Lint

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:

format:
Expand All @@ -12,9 +16,9 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: 3.11
Expand All @@ -24,4 +28,4 @@ jobs:
run: pip install nox

- name: Format code
run: nox -s format -- --check --verbose --diff
run: nox -s lint
44 changes: 44 additions & 0 deletions .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Notebooks

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
test-notebooks:
name: Check notebooks
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Miniforge3
miniforge-version: latest
auto-update-conda: true

- name: Install nox
run: pip install nox

- name: Test Jupyter notebooks
env:
MPLBACKEND: "Agg"
run: |
nox --verbose -s test-notebooks --force-pythons="${{ matrix.python-version }}"
21 changes: 8 additions & 13 deletions .github/workflows/build-test-ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Build/Test CI
name: Test

on: [push, pull_request]

jobs:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

build-and-test:
jobs:

test:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository
Expand All @@ -28,18 +31,10 @@ jobs:
with:
miniforge-variant: Mambaforge
miniforge-version: latest
environment-file: environment.yml
activate-environment: geotiff
python-version: ${{ matrix.python-version }}
auto-activate-base: false

- name: Show conda installation info
run: |
conda info
conda list

- name: Install package
run: pip install -e .
- name: Install nox
run: pip install nox

- name: Test
run: |
Expand Down
98 changes: 98 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
repos:
- repo: local
hooks:
- id: unnecessary_doctest_directives
name: Check for redundant doctest directives
description:
"Check for inline doctest directives that are specified globally through pyproject.toml"
types: [python]
entry: >
(?x)(
\+IGNORE_EXCEPTION_DETAIL|
\+NORMALIZE_WHITESPACE
)
language: pygrep

- repo: https://github.com/psf/black
rev: 24.4.0
hooks:
- id: black
name: black
description: "Black: The uncompromising Python code formatter"
entry: black
language: python
language_version: python3
minimum_pre_commit_version: 2.9.2
require_serial: true
types_or: [python, pyi]
- id: black-jupyter
name: black-jupyter
description:
"Black: The uncompromising Python code formatter (with Jupyter Notebook support)"
entry: black
language: python
minimum_pre_commit_version: 2.9.2
require_serial: true
types_or: [python, pyi, jupyter]
additional_dependencies: [".[jupyter]"]

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
description: "Black for doctests"
additional_dependencies: ["black==24.4.0"]
- id: blackdoc-autoupdate-black

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
# - flake8-bugbear!=24.4.21
# - flake8-comprehensions
- flake8-simplify

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
hooks:
- id: nbqa-pyupgrade
args: ["--py310-plus"]
# - id: nbqa-isort
- id: nbqa-flake8
args: ["--extend-ignore=E402"]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
description: Strip output from jupyter notebooks
args: [--drop-empty-cells]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py310-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
# args: [--force-single-line-imports]
types: [python]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8327418.svg)](https://doi.org/10.5281/zenodo.8327418)
[![PyPI](https://img.shields.io/pypi/v/bmi-geotiff)](https://pypi.org/project/bmi-geotiff)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/bmi-geotiff.svg)](https://anaconda.org/conda-forge/bmi-geotiff)
[![Build/Test CI](https://github.com/csdms/bmi-geotiff/actions/workflows/build-test-ci.yml/badge.svg)](https://github.com/csdms/bmi-geotiff/actions/workflows/build-test-ci.yml)
[![Test](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml/badge.svg)](https://github.com/csdms/bmi-geotiff/actions/workflows/test.yml)
[![Documentation Status](https://readthedocs.org/projects/bmi-geotiff/badge/?version=latest)](https://bmi-geotiff.readthedocs.io/en/latest/?badge=latest)

# bmi-geotiff
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
version = pkg_resources.get_distribution("bmi_geotiff").version
release = version
this_year = datetime.date.today().year
copyright = "{}, {}".format(this_year, author)
copyright = f"{this_year}, {author}"


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions examples/bmi-geotiff.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"metadata": {},
"outputs": [],
"source": [
"ls"
"!ls"
]
},
{
Expand All @@ -150,7 +150,7 @@
"metadata": {},
"outputs": [],
"source": [
"cat config.yaml"
"!cat config.yaml"
]
},
{
Expand Down
31 changes: 20 additions & 11 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,28 @@ def test_bmi(session: nox.Session) -> None:
)


@nox.session
def format(session: nox.Session) -> None:
"""Clean lint and assert style."""
session.install(".[dev]")
@nox.session(name="test-notebooks", python=PYTHON_VERSIONS[-1])
def test_notebooks(session: nox.Session) -> None:
"""Test the notebooks."""
session.install(".[testing,examples]")
session.install("nbmake")

if session.posargs:
black_args = session.posargs
else:
black_args = []
args = [
"examples",
"--nbmake",
"--nbmake-kernel=python3",
"--nbmake-timeout=3000",
"-vvv",
] + session.posargs

session.run("black", *black_args, *PATHS)
session.run("isort", *PATHS)
session.run("flake8", *PATHS)
session.run("pytest", *args)


@nox.session
def lint(session: nox.Session) -> None:
"""Clean lint and assert style."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")


@nox.session(name="prepare-docs")
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ Changelog = "https://github.com/csdms/bmi-geotiff/blob/main/CHANGES.md"

[project.optional-dependencies]
dev = [
"black",
"flake8",
"isort",
"nox",
]
build = [
Expand Down Expand Up @@ -95,6 +92,7 @@ addopts = """
--durations 16
--doctest-modules
-vvv
--ignore-glob=examples/*.py
"""
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
Expand Down
7 changes: 0 additions & 7 deletions setup.cfg

This file was deleted.

0 comments on commit 9b737cf

Please sign in to comment.