Skip to content

Commit

Permalink
Add pre commit CI (#16)
Browse files Browse the repository at this point in the history
* Add pre commit CI

* cache pre-commit venvs + dependabot

* update pre commit invocation
https://tobiasmcnulty.com/posts/caching-pre-commit/

* add pre-commit as dev dependency
  • Loading branch information
kylebarron authored Oct 2, 2023
1 parent a15cd15 commit 9357716
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Python test

# On every pull request, but only on push to master
on:
push:
branches:
- main
pull_request:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install root project
run: poetry install --no-interaction

# - name: Run tests
# run: pytest

- name: Cache pre-commit virtualenvs
uses: actions/cache@v3
if: matrix.python-version == 3.9
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}

# TODO: switch this to run on e.g. 3.11 (how to get the if statement to
# work?)
# Run pre-commit (only for python-3.9)
- name: run pre-commit
if: matrix.python-version == 3.9
run: |
poetry run pre-commit run --show-diff-on-failure --color=always --all-files
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

# Default to Python 3
default_language_version:
python: python3

# Optionally both commit and push
default_stages: [commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python3

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
hooks:
- id: ruff
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ npm install esbuild
npm run build
poetry install
```

2 changes: 1 addition & 1 deletion lonboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .widget import PointLayer, LineStringLayer, PolygonLayer
from .widget import LineStringLayer, PointLayer, PolygonLayer
122 changes: 121 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
description = "Extremely fast geospatial data visualization in Python."
authors = ["Kyle Barron <[email protected]>"]
readme = "README.md"
packages = [{include = "lonboard"}]
packages = [{ include = "lonboard" }]

[tool.poetry.dependencies]
python = "^3.8"
Expand All @@ -18,11 +18,22 @@ comm = "^0.1.4"


[tool.poetry.group.dev.dependencies]
anywidget = {version = "^0.6.3", extras = ["dev"]}
anywidget = { version = "^0.6.3", extras = ["dev"] }
jupyterlab = "^4.0.5"
watchfiles = "^0.20.0"
pre-commit = "^3.4.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"

[tool.ruff]

[tool.ruff.extend-per-file-ignores]
"__init__.py" = [
"F401", # Allow unused imports in __init__.py files
]

0 comments on commit 9357716

Please sign in to comment.