Skip to content

Commit

Permalink
Merge pull request #4 from datarootsio/feature/replace_poetry_with_rye
Browse files Browse the repository at this point in the history
Feature/replace poetry with rye
  • Loading branch information
bart6114 authored Sep 10, 2024
2 parents 441a6a5 + 9ceab0d commit 1fbeca6
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 504 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/python-basic-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Multiple Python Versions CI boilerplate

on:
push:
pull_request:

jobs:
linter_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- uses: eifinger/setup-rye@v2
- run: rye sync
- run: rye fmt
- run: rye lint
- run: rye test
- run: rye run mypy src
24 changes: 0 additions & 24 deletions .github/workflows/tests.yaml

This file was deleted.

73 changes: 38 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@

repos:
- repo: local
- repo: local
hooks:
- id: isort
name: isort
stages: [commit]
types: [python]
entry: poetry run isort .
language: system
pass_filenames: false
always_run: true
- id: black
name: black
stages: [commit]
types: [python]
entry: poetry run black .
language: system
pass_filenames: false
always_run: true
- id: ruff
name: ruff
stages: [commit]
types: [python]
entry: poetry run ruff .
language: system
pass_filenames: false
always_run: true
fail_fast: true
- id: pytest
name: pytest
stages: [commit]
types: [python]
entry: poetry run pytest
language: system
pass_filenames: false
always_run: true
fail_fast: true
- id: rye-lint
name: rye-lint
description: "Lint Python via 'rye lint'"
entry: rye lint --fix
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- id: rye-format
name: rye-format
description: "Format Python via 'rye fmt'"
entry: rye fmt
language: system
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- id: rye-test
name: rye-test
description: "Test Python via 'rye test'"
entry: rye test
language: system
types_or: [python, pyi]
args: []
pass_filenames: false
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.10.1'
hooks:
- id: mypy
files: src
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
## Project title
# Minimal Python Boilerplate

This boilerplate project contains the following setup ready for you to go:
This boilerplate project contains the following setup ready for you to go.

* package/environment management
* `poetry`
* code validation
* `black`
* `ruff`
* `pytest`
* `rye`
* linting & formatting
* `ruff` (triggered by `rye`)
* testing framework
* `pytest` (triggered by `rye`)
* see `tests` directory
* type checking
* `mypy`
* pre-commit hooks
* GitHub Actions workflow in `.github/workflows`

# Setup
This boilerplate prefers a [src layout](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) over a flat layout.

## Setup

1. Clone this repo
2. Make sure to [install Poetry](https://python-poetry.org/docs/#installation)
2. Make sure to [install Rye](https://rye.astral.sh/guide/installation/)
3. In your project directory run
1. `poetry shell`
2. `poetry install`
3. `pre-commit install`
1. `rye sync`
2. `pre-commit install`
3. Optionally run `pre-commit run --all-files` (this will be triggered automatically on each commit)
4. On each `git commit` the code validation packages will be run before the actual commit.
5. Explore the setup in the folder structure of this package.
6. Profit.
5. GitHub Action workflows will be triggered on `push` and `pull_request` events.
6. Explore the setup in the folder structure of this package.
7. Profit.
Loading

0 comments on commit 1fbeca6

Please sign in to comment.