Skip to content

Commit

Permalink
Added a noxfile and removed lint (#83)
Browse files Browse the repository at this point in the history
* add a noxfile

* add a pre-commit config file

* remove all the lint

* update requirements; add requirements.py to extract requirements

* update path to the docs

* update readthedocs config file

* move black workflow into lint workflow

* add a workflow to test that the docs build

* add session to build the languages and test them

* add make and pip to the external requirements

* remove old and deprecated wrap module

* install pydocstyl[toml]

* require coverage[toml]

* simplify calls to subprocess.run using partial

* fix typos

* run tests with nox

* add pytest-xdist as a requirement for testing

* require setuptools < 60 for the build system

* use python -m pip

* clean up noxfile.py, parametrize python versions

* specify the python version

* use setup-python action

* remove conda backend from regular tests

* run the language tests in a separate step

* use --python option

* fix typos

* ignore nox virtual envs in the .nox folder

* print some debugging messages

* run with --verbose

* run setup.py build_ext

* print more debugging messages

* run the language tests with nox, not pytest

* install tomli for ci tests

* more debugging messages

* limit to just c

* forget linux for now

* reinstall the compilers

* install compilers before running nox

* test on linux again; clean up the nox file

* print the environment before compiling

* disable linux again

* install cmake along with compilers

* try linux again

* try an older version of gfortran

* try to install gcc9 on linux

* try gcc less than 10

* try installing older version of all the compilers

* try native compilers on linux

* install bmi-fortran along with the fortran compiler

* try the new build of bmi-fortran

* add towncrier as a dev requirement

* add news fragments

* auto-generate the api documentation

* move the cli doc page out of the api docs

* update extension settings in conf.py

* move the tomli import

* add a GitHub action to check for news fragments

* update requirements file

* remove the makefile

* install cmake to build the examples
  • Loading branch information
mcflugen authored Nov 28, 2022
1 parent 5c40eaa commit 56ce18b
Show file tree
Hide file tree
Showing 63 changed files with 1,443 additions and 1,078 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/black.yml

This file was deleted.

66 changes: 13 additions & 53 deletions .github/workflows/build-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -36,60 +40,16 @@ jobs:
channel-priority: true

- name: Install dependencies
run: |
pip install coverage[toml]
mamba install --file=requirements.txt --file=requirements-testing.txt --file=external/requirements.txt
conda list
- name: Install build system
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'
run: |
mamba install cython numpy setuptools wheel
- name: Install babelizer
run: |
pip install .
- name: Run diagnostics
run: |
babelize --version
babelize --help
babelize init --help
babelize update --help
babelize generate --help
babelize generate
python -c 'import babelizer; print(babelizer.__version__)'
- name: Make C example
run: |
mkdir buildc && pushd buildc
cmake ../external/bmi-example-c -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
make install
popd
- name: Make C++ example
run: |
mkdir buildcxx && pushd buildcxx
cmake ../external/bmi-example-cxx -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
make install
popd
run: python -m pip install nox tomli

- name: Make Fortran example
run: |
mkdir buildf && pushd buildf
cmake ../external/bmi-example-fortran -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
make install
popd
- name: Install compilers
run: mamba install c-compiler cxx-compiler fortran-compiler cmake

- name: Make Python example
run: |
pushd ./external/bmi-example-python
make install
popd
- name: Run the tests
run: nox --session test test-cli --python ${{ matrix.python-version }} --verbose

- name: Test babelizer + language examples and generate coverage report
run: |
pytest --cov=babelizer --cov-report=xml:./coverage.xml -vvv babelizer tests external/tests
- name: Run the language tests
run: nox --non-interactive --error-on-missing-interpreter --session test-langs --python ${{ matrix.python-version }} --verbose

- name: Coveralls
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
check-changelog-entry:
name: changelog entry
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
# `towncrier check` runs `git diff --name-only origin/main...`, which
# needs a non-shallow clone.
fetch-depth: 0

- name: Check changelog
if: "!contains(github.event.pull_request.labels.*.name, 'Skip Changelog')"
run: |
if ! pipx run towncrier check --compare-with origin/${{ github.base_ref }}; then
echo "Please see https://landlab.readthedocs.io/en/master/development/contribution/index.html?highlight=towncrier#news-entries for guidance."
false
fi
15 changes: 5 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}
Expand All @@ -43,16 +43,11 @@ jobs:
channel-priority: true

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

- name: Install dependencies
run: |
conda install mamba
mamba install --file=requirements.txt
pip install -r requirements-docs.txt
pip install -e .
pip install nox
- name: Build documentation
run: make -C docs clean html
run: nox -s build-docs
11 changes: 6 additions & 5 deletions .github/workflows/flake8.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Flake8
name: Lint

on: [push, pull_request]

jobs:

lint:
name: Check for lint
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
Expand All @@ -15,12 +16,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Lint
run: |
pip install flake8
flake8
pip install nox tomli
nox -s lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ ENV/

# mypy
.mypy_cache/

# nox virtual envs
.nox/
84 changes: 84 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.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]
exclude: ^babelizer/data
- 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]"]
exclude: ^babelizer/data

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-simplify
exclude: ^babelizer/data

- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: pyupgrade
args: [--py38-plus]
exclude: ^babelizer/data

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$
exclude: ^babelizer/data

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-builtin-literals
exclude: ^babelizer/data
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
exclude: ^babelizer/data
- id: check-yaml
exclude: ^babelizer/data
- id: debug-statements
exclude: ^babelizer/data
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: trailing-whitespace

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
files: babelizer/.*\.py$
args:
- --convention=numpy
- --add-select=D417
exclude: ^babelizer/data
additional_dependencies: [".[toml]"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
additional_dependencies: [types-all]
exclude: ^babelizer/data
8 changes: 6 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ formats:
- htmlzip

python:
version: 3.8
install:
- requirements: requirements-docs.txt
- requirements: requirements.txt
Expand All @@ -18,4 +17,9 @@ python:
system_packages: false

build:
image: latest
os: ubuntu-22.04
tools:
python: "3.9"
jobs:
pre_build:
- sphinx-apidoc -e -force --no-toc --module-first -o docs/source/api babelizer
9 changes: 2 additions & 7 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
Changelog
=========

.. towncrier release notes start
0.3.10 (unreleased)
-------------------

- Nothing changed yet.
.. towncrier-draft-entries:: Not yet released

.. towncrier release notes start
0.3.9 (2022-03-04)
------------------
Expand Down Expand Up @@ -242,4 +238,3 @@ Improved Documentation
------------------

- Initial release

1 change: 0 additions & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Loading

0 comments on commit 56ce18b

Please sign in to comment.