Skip to content

Commit

Permalink
Make pre-commit-hooks more consistent across projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgaudecker committed Aug 10, 2023
1 parent df8f825 commit 598ebf5
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 97 deletions.
22 changes: 4 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,53 @@
---
name: main
on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- '*'

- '*'
# Automatically cancel a previous run.
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

run-tests:

name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda

- name: Run pytest.
shell: bash -l {0}
run: tox -e pytest -- -m "not slow" --cov-report=xml --cov=./

- name: Upload coverage report.
if: runner.os == 'Linux' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

docs:

name: Run documentation.
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.9

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda

- name: Build docs
shell: bash -l {0}
run: tox -e sphinx
51 changes: 24 additions & 27 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
---
name: PyPI

on: push

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
44 changes: 17 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
---
repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
# - id: identity # Prints all files passed to pre-commits. Debugging.
- repo: https://github.com/lyz-code/yamlfix
rev: 1.13.0
hooks:
- id: yamlfix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args:
- --maxkb=1300
args: [--maxkb=1300]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: fix-byte-order-marker
types:
- text
types: [text]
- id: forbid-submodules
- id: mixed-line-ending
args:
- --fix=lf
args: [--fix=lf]
description: Forces to replace line ending by the UNIX 'lf' character.
- id: name-tests-test
args:
- --pytest-test-first
args: [--pytest-test-first]
- id: no-commit-to-branch
args:
- --branch
- main
args: [--branch, main]
- id: trailing-whitespace
- id: check-ast
- id: check-docstring-first
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand All @@ -43,17 +47,6 @@ repos:
rev: 1.15.0
hooks:
- id: blacken-docs
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args:
- --in-place
- --wrap-summaries
- '88'
- --wrap-descriptions
- '88'
- --blank
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
hooks:
Expand All @@ -71,10 +64,7 @@ repos:
rev: '0.49'
hooks:
- id: check-manifest
args:
- --no-build-isolation
additional_dependencies:
- setuptools-scm
- toml
args: [--no-build-isolation]
additional_dependencies: [setuptools-scm, toml]
ci:
autoupdate_schedule: monthly
4 changes: 1 addition & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
version: 2

build:
image: latest

python:
version: 3.8

conda:
environment: docs/rtd_environment.yml
11 changes: 4 additions & 7 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
---
codecov:
notify:
require_ci_to_pass: yes

require_ci_to_pass: true
coverage:
precision: 2
round: down
range: "50...100"
range: 50...100
status:
patch:
default:
target: 80%
project:
default:
target: 80%

ignore:
- ".tox/**/*"
- "setup.py"
ignore: [.tox/**/*, setup.py]
10 changes: 3 additions & 7 deletions docs/rtd_environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
channels:
- conda-forge
- nodefaults

---
channels: [conda-forge, nodefaults]
dependencies:
- python=3.9
- pip
Expand All @@ -17,6 +15,4 @@ dependencies:
- sphinx-copybutton
- sphinx-panels
- pydata-sphinx-theme>=0.3.0

- pip:
- ../
- pip: [../]
11 changes: 3 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: dags

channels:
- conda-forge
- nodefaults

channels: [conda-forge, nodefaults]
dependencies:
- python >=3.9
- pip
Expand All @@ -30,6 +27,4 @@ dependencies:
# Development
- jupyterlab
- nbsphinx

- pip:
- -e .
- pip: [-e .]

0 comments on commit 598ebf5

Please sign in to comment.