Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt pyproject.toml standard, fast-forward cookiecutter #50

Merged
merged 20 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/Ouranosinc/cookiecutter-pypackage",
"commit": "240a2c784f89cb1e2c5952869413c5582e590345",
"commit": "844fb9600b45d5d51d6e88dfdc4acdf88aa09bac",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -9,11 +9,12 @@
"github_username": "TC-FF",
"project_name": "xHydro",
"project_slug": "xhydro",
"project_short_description": "Hydrological analysis library built with xarray",
"project_short_description": "Hydrological analysis library built with xarray.",
"pypi_username": "TC-FF",
"version": "0.2.4",
"use_pytest": "y",
"use_black": "y",
"use_conda": "y",
"add_pyup_badge": "n",
"make_docs": "y",
"command_line_interface": "No command-line interface",
Expand Down
30 changes: 30 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[flake8]
exclude =
.eggs,
.git,
build,
docs,
tests
ignore =
AZ100,
AZ200,
AZ300,
C,
D,
E,
F,
W503
per-file-ignores =
rst-roles =
doc,
mod,
py:attr,
py:attribute,
py:class,
py:const,
py:data,
py:func,
py:meth,
py:mod,
py:obj,
py:ref
24 changes: 24 additions & 0 deletions .github/workflows/actions-versions-updater.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: GitHub Actions Version Updater

on:
schedule:
# 12:00 AM on the first of every month
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
with:
# This requires a personal access token with the privileges to push directly to `main`
token: ${{ secrets.WORKFLOW_TOKEN }}
persist-credentials: true
- name: Run GitHub Actions Version Updater
uses: saadmk11/github-actions-version-updater@v0.8.1
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
committer_email: 'bumpversion[bot]@ouranos.ca'
committer_username: 'update-github-actions[bot]'
pull_request_title: '[bot] Update GitHub Action Versions'
4 changes: 2 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
run: echo "current_version=$(grep -E '__version__' xhydro/__init__.py | cut -d ' ' -f3)"
- name: Bump Patch Version
run: |
pip install bump2version
pip install bump-my-version
echo "Bumping version"
bump2version patch
bump-my-version bump --tag patch
echo "new_version=$(grep -E '__version__' xhydro/__init__.py | cut -d ' ' -f3)"
- name: Push Changes
uses: ad-m/github-push-action@master
Expand Down
58 changes: 25 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,92 @@ on:
branches:
- main
paths-ignore:
- HISTORY.rst
- MANIFEST.in
- CHANGES.rst
- README.rst
- setup.cfg
- setup.py
- pyproject.toml
- xhydro/__init__.py
pull_request:

jobs:
black:
name: Black (Python${{ matrix.python-version }})
lint:
name: Lint (Python${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.x"
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox
run: |
python -m pip install tox
- name: Run linting suite
run: tox -e black
run: |
python -m tox -e lint

test:
name: Test with Python${{ matrix.python-version }}
needs: black
test-conda:
name: Test with Python${{ matrix.python-version }} (Anaconda)
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.9"
# tox-build: "py39"
- python-version: "3.10"
# tox-build: "py310"
- python-version: "3.11"
# tox-build: "py311"
python-version: ["3.9", "3.10", "3.11"]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- name: Setup Conda (Micromamba) with Python ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
environment-file: environment.yml
environment-file: environment-dev.yml
create-args: >-
coveralls
mamba
python=${{ matrix.python-version }}
pytest
pytest-cov
- name: Conda and Mamba versions
run: |
mamba --version
echo "micromamba $(micromamba --version)"
- name: Install xhydro
run: |
pip install --editable .
python -m pip install --no-deps .
- name: Check versions
run: |
conda list
pip check || true
python -m pip check || true
- name: Test with pytest
run: |
pytest --cov xhydro
python -m pytest --cov xhydro
- name: Report coverage
run: |
coveralls
python -m coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-Python${{ matrix.python-version }}
COVERALLS_FLAG_NAME: run-Python${{ matrix.python-version }}-conda
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

finish:
needs:
- test
- test-conda
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Coveralls Finished
run: |
pip install --upgrade coveralls
coveralls --finish
python -m pip install --upgrade coveralls
python -m coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
7 changes: 4 additions & 3 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:
jobs:
build-n-publish-pypi:
name: Build and publish Python 🐍 distributions 📦 to PyPI
environment: production
runs-on: ubuntu-latest
environment: production
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
Expand All @@ -20,9 +21,9 @@ jobs:
python-version: "3.9"
- name: Install packaging libraries
run: |
pip install setuptools wheel
python -m pip install flit
- name: Build a binary wheel and a source tarball
run: |
python setup.py sdist bdist_wheel
python -m flit build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
29 changes: 24 additions & 5 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,33 @@ name: Publish Python 🐍 distributions 📦 to TestPyPI
on:
push:
tags:
- 'v*.*.*'
- 'v*.*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build-n-publish-testpypi:
release:
name: Create Release from tag
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '.0')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v1
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
draft: true
prerelease: false

deploy-testpypi:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
environment: staging
runs-on: ubuntu-latest
environment: staging
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
Expand All @@ -20,10 +39,10 @@ jobs:
python-version: "3.9"
- name: Install packaging libraries
run: |
pip install setuptools wheel
python -m pip install flit
- name: Build a binary wheel and a source tarball
run: |
python setup.py sdist bdist_wheel
python -m flit build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
34 changes: 15 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ repos:
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: setup.cfg
- id: end-of-file-fixer
- id: debug-statements
- id: check-json
- id: check-toml
- id: pretty-format-json
args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ]
# exclude: .ipynb
- id: check-yaml
args: [ '--allow-multiple-documents' ]
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -28,39 +32,31 @@ repos:
rev: 23.11.0
hooks:
- id: black
args: [ '--target-version=py39' ]
exclude: ^docs/
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [ 'flake8-rst-docstrings' ]
args: ['--config=setup.cfg']
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ['--settings-file=setup.cfg']
exclude: ^docs/
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: pydocstyle
args: [ '--config=setup.cfg' ]
- id: ruff
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [ 'flake8-alphabetize', 'flake8-rst-docstrings' ]
args: [ '--config=.flake8' ]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==23.10.1' ]
additional_dependencies: [ 'black==23.11.0' ]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint
args: ['--config-file', '.yamllint.yaml']
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.1
hooks:
Expand Down
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ build:
python: "mambaforge-22.9"
jobs:
post_create_environment:
# FIXME: this is a workaround for xdatasets until the `xagg-no-xesmf-deps` issue is addressed
- pip install xdatasets
- pip install . --no-deps
pre_build:
- sphinx-apidoc -o docs/apidoc --private --module-first xhydro
Expand Down
Loading