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

Update cookiecutter, adopt pyproject.toml #292

Merged
merged 23 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "/home/tjs/git/cookiecutter-pypackage",
"commit": "2fc25aaaf59ce346529c90c032c34baa30a45def",
"commit": "e67ba8180e050ffd1c29e38cf2ad3929004fdd8f",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -14,6 +14,7 @@
"version": "0.7.20-beta",
"use_pytest": "y",
"use_black": "y",
"use_conda": "y",
"add_pyup_badge": "n",
"make_docs": "y",
"command_line_interface": "Click",
Expand Down
32 changes: 32 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[flake8]
exclude =
.eggs,
.git,
build,
docs/conf.py,
tests
ignore =
AZ100,
AZ200,
AZ300,
C,
D,
E,
F,
W503
W504
per-file-ignores =
tests/*:E402
rst-roles =
doc,
mod,
py:attr,
py:attribute,
py:class,
py:const,
py:data,
py:func,
py:meth,
py:mod,
py:obj,
py:ref
1 change: 1 addition & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CI:
- .cruft.json
- .editorconfig
- .flake8
- .gitignore
- .pre-commit-config.yaml
- .readthedocs.yml
Expand Down
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/[email protected]
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/[email protected]
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'
20 changes: 12 additions & 8 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ on:
paths-ignore:
- .cruft.json
- .editorconfig
- .flake8
- .github/**.yml
- .gitignore
- .gitlab-ci.yml
- .gitmodules
- .pre-commit-config.yaml
- .secrets.baseline
- .yamllint.yaml
- AUTHORS.rst
- CHANGES.rst
- CONTRIBUTING.rst
- docs/notebooks
- MANIFEST.in
- Makefile
- conda/xscen/*.yaml
- docs/*.py
- docs/*.rst
- docs/notebooks
- environment-dev.yml
- environment.yml
- HISTORY.rst
- Makefile
- MANIFEST.in
- requirements_upstream.txt
- pyproject.toml
- setup.cfg
- setup.py
- tests/**.py
- templates
- tests/*.py
- tox.ini
- xscen/__init__.py

Expand All @@ -48,9 +52,9 @@ jobs:
run: echo "current_version=$(grep -E '__version__' xscen/__init__.py | cut -d ' ' -f3)"
- name: Bump Patch Version
run: |
python -m pip install bump2version
python -m pip install bump-my-version
echo "Bumping version"
python -m bump2version patch
python -m bump-my-version bump patch
echo "new_version=$(grep -E '__version__' xscen/__init__.py | cut -d ' ' -f3)"
- name: Push Changes
uses: ad-m/github-push-action@master
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ on:
branches:
- main
paths-ignore:
- HISTORY.rst
- CHANGES.rst
- README.rst
- pyproject.toml
- setup.cfg
- setup.py
- xscen/__init__.py
pull_request:

jobs:
black:
name: Code Style Compliance
lint:
name: Lint (Python${{ matrix.python-version }})
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version:
- "3.x"
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
Expand All @@ -26,17 +29,17 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.x"
- name: Install tox
run: |
python -m pip install tox
- name: Run linting suite
run: |
python -m tox -e black
python -m tox -e lint

testing-tox:
test-pypi:
name: Test with Python${{ matrix.python-version }} (PyPI/tox)
needs: black
needs: lint
runs-on: ubuntu-latest
env:
COVERALLS_PARALLEL: true
Expand Down Expand Up @@ -100,9 +103,9 @@ jobs:
# COVERALLS_PARALLEL: true
# COVERALLS_SERVICE_NAME: github

testing-conda:
test-conda:
name: Test with Python${{ matrix.python-version }} (Anaconda)
needs: black
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -127,14 +130,14 @@ jobs:
- name: Compile catalogs and install xscen
run: |
make translate
python -m pip install --no-deps --editable .
python -m pip install --no-deps .
- name: Check versions
run: |
conda list
python -m pip check || true
- name: Test with pytest
run: |
python -m pytest tests
python -m pytest --cov xscen
- name: Report coverage
run: |
python -m coveralls
Expand All @@ -146,15 +149,15 @@ jobs:

finish:
needs:
- testing-tox
- testing-conda
- test-pypi
- 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
12 changes: 7 additions & 5 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ jobs:
build-n-publish-pypi:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
environment: production
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python3
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install packaging libraries
run: |
python -m pip install build wheel
python -m pip install babel build setuptools wheel
- name: Build a binary wheel and a source tarball
run: |
make translate
python -m build --sdist --wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
33 changes: 27 additions & 6 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,49 @@ name: "Publish Python 🐍 distributions 📦 to TestPyPI"
on:
push:
tags:
- '*'
- '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
runs-on: ubuntu-latest
environment: staging
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python3
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install packaging libraries
run: |
python -m pip install build wheel
python -m pip install babel build setuptools wheel
- name: Build a binary wheel and a source tarball
run: |
make translate
python -m build --sdist --wheel
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
36 changes: 19 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,38 @@ repos:
- id: pretty-format-json
args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ]
exclude: .ipynb
- id: check-toml
- id: check-yaml
args: [ '--allow-multiple-documents' ]
exclude: conda/xscen/meta.yaml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-inline-touching-normal
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
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.1.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:
Expand All @@ -70,7 +73,6 @@ repos:
args: [ '--target-version=py39' ]
additional_dependencies: [ 'black==23.11.0' ]
- id: nbqa-isort
args: [ "--settings-file=setup.cfg" ]
additional_dependencies: [ 'isort==5.12.0' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
Expand All @@ -83,11 +85,11 @@ repos:
- id: detect-secrets
exclude: .cruft.json|docs/notebooks
args: [ '--baseline=.secrets.baseline' ]
# Currently commented because Git needs to be updated on our work environment.
# - 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:
- id: check-github-workflows
- id: check-readthedocs
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
Loading
Loading