Skip to content

Commit

Permalink
Merge pull request #20 from MultifokalHirn/tox-and-docs
Browse files Browse the repository at this point in the history
Lots of changes
  • Loading branch information
MultifokalHirn authored Dec 7, 2023
2 parents 25c66ba + b3bbedc commit 5a8f386
Show file tree
Hide file tree
Showing 36 changed files with 1,269 additions and 783 deletions.
38 changes: 27 additions & 11 deletions .github/workflows/python-checks.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: All Checks
name: Python Checks

on:
push:
Expand All @@ -21,34 +21,50 @@ permissions:

jobs:
build:
name: Lint & Test for ${{ matrix.python-version }}
# name: Build and Test
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: true
# max-parallel: 1
fail-fast: false
matrix:
python-version: [3.8, 3.11, 3.12]
python-version: [3.11, 3.12]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set Variables
id: set_variables
shell: bash
run: |
echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_OUTPUT
echo "PIP_CACHE=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache PIP
uses: actions/cache@v3
with:
path: ${{ steps.set_variables.outputs.PIP_CACHE }}
key: ${{ runner.os }}-pip-${{ steps.set_variables.outputs.PY }}
- name: Cache venv
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pdm.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ matrix.python-version }}-
- name: Setup environment
run: make bootstrap
- name: Install dependencies
run: make dev

- name: Test with pytest
- name: Run tests
run: make test
- name: Run typechecks
run: make mypy
- name: Lint
run: make lint
# - uses: actions/checkout@v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: pdm-project/setup-pdm@v3
# with:
# python-version: ${{ matrix.python-version }}

# - name: Install dependencies
# run: |
# python -m pip install --upgrade tox .
Expand Down
102 changes: 46 additions & 56 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# please, regularly run `pre-commit autoupdate`
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand All @@ -13,29 +18,19 @@ repos:
- id: destroyed-symlinks
# - id: check-json
- id: detect-private-key
# - repo: https://github.com/pycqa/isort
# rev: "5.12.0"
# hooks:
# - id: isort
# name: isort (python)
# additional_dependencies: [toml]
# - repo: https://github.com/hhatto/autopep8
# rev: "v2.0.4"
# hooks:
# - id: autopep8
# - repo: https://github.com/PyCQA/flake8
# rev: "6.1.0"
# hooks:
# - id: flake8
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
args: [--fix, --config=./pyproject.toml]
# Run the formatter.
- id: ruff-format
args: [--config=./pyproject.toml]
# - id: ruff-format
# args:
# [
# --fix,
# --exit-non-zero-on-fix,
# --show-fixes,
# --config=./pyproject.toml,
# ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
hooks:
Expand All @@ -44,57 +39,29 @@ repos:
# ignore-missing-imports: true
# disallow_any_unimported: false
args: [--config-file=./pyproject.toml]
- repo: https://github.com/IamTheFij/docker-pre-commit
rev: v3.0.1
hooks:
- id: docker-compose-check
files: docker-compose.*.y[a]{0,1}ml$
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject
# export python requirements
- repo: https://github.com/pdm-project/pdm
rev: 2.10.4
hooks:
- id: pdm-lock-check
- id: pdm-export
# pdm export -o requirements.txt --without-hashes --prod
args: ["-o", "requirements.txt", "--without-hashes", "--prod"]
files: ^pdm.lock$
- repo: https://github.com/pdm-project/pdm
rev: 2.10.4
hooks:
- id: pdm-export
args: ["-o", "requirements-dev.txt", "--without-hashes", "--dev"]
files: ^pdm.lock$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/guilatrova/tryceratops # requires python>=3.8
rev: v2.3.2
hooks:
- id: tryceratops
# - repo: https://github.com/guilatrova/tryceratops # requires python>=3.8
# rev: v2.3.2
# hooks:
# - id: tryceratops
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py311-plus]
# - repo: https://github.com/jendrikseipp/vulture
# rev: v2.3
# hooks:
# - id: vulture
- repo: https://github.com/dosisod/refurb # requires python>=3.10
rev: "v1.25.0"
hooks:
- id: refurb
# - repo: https://github.com/dosisod/refurb # requires python>=3.10
# rev: "v1.25.0"
# hooks:
# - id: refurb
- repo: https://codeberg.org/frnmst/md-toc
rev: "8.2.2" # or a specific git tag from md-toc
hooks:
Expand All @@ -104,3 +71,26 @@ repos:
# rev: "0.49"
# hooks:
# - id: check-manifest
# - repo: https://github.com/IamTheFij/docker-pre-commit
# rev: v3.0.1
# hooks:
# - id: docker-compose-check
# files: docker-compose.*.y[a]{0,1}ml$
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject
- repo: https://github.com/pdm-project/pdm
rev: 2.10.4
hooks:
- id: pdm-lock-check
- id: pdm-export
# pdm export -o requirements.txt --without-hashes --prod
args: ["-o", "requirements.txt", "--without-hashes", "--prod"]
files: ^pdm.lock$
- repo: https://github.com/pdm-project/pdm
rev: 2.10.4
hooks:
- id: pdm-export
args: ["-o", "requirements-dev.txt", "--without-hashes", "--dev"]
files: ^pdm.lock$
15 changes: 15 additions & 0 deletions .readthedocks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3"
python:
install:
- method: pip
path: .
extra_requirements:
- docs
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: true
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Unreleased

### Feat

- add devcontainer.json, cnfigure dependabot, minor fixes

### Fix

- template shouldnt give access to itself

## 1.0.0 (2023-11-15)

### Feat

- adds pdm based dependencies

### Fix

- more trying to get makefile to work in github actions; ruff replaces flake8 and "autopep8"
- misc fixes, starting to work in tox.ini
- dont install pdm again after bootstrapping; fix import bug
- try to get tests to work for 3.8
- pdm cofniguration did not work on systems without a system wide pdm
- readme
- update vscode workspace settings to reflect deprecations
- getting app module to be callable
- import logic in submodules, fixed linting issues
62 changes: 25 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Most of the setup is automated with `make`. Check the [`Makefile`](./Makefile) t

### Requirements

* Python>=3.8
* Make:
* `Python>=3.11`
* `make`:
* macOS: `xcode-select --install`
* Linux: visit [gnu.org](https://www.gnu.org/software/make)
* Windows: `choco install make` or check [chocolatey.org](https://chocolatey.org/install)
Expand All @@ -19,26 +19,36 @@ make bootstrap
make doctor
``` -->

### Installation
### Installing Dependencies

`Make` will take care of setting a the virtual environment (it will be located in `.venv`). It will also install `pdm` and with it all dependencies.
`make` will take care of setting a the virtual environment (it will be located in `.venv`). It will also install `pdm` and with it all dependencies.

``` bash
make install
make bootstrap
make dev
```

<!-- ### Data
### Setting up pre-commit hooks

[`pre-commit`](https://github.com/pre-commit/pre-commit) should be used to run checks on staged changes before each commit and to enforce the commit message style.

To automatically create test accounts, update `.envrc` with your own information and run `direnv allow`. Then, generate new seed data for local development:
Before you start development, please install the hooks like so:

``` bash
make data
``` -->
pre-commit install && pre-commit install --hook-type commit-msg
```

## Development Tasks
## Development
>
> In order to have notifications in your terminal on macOS, you can install a package for that like so:
> `brew install terminal-notifier`
To run all of the checks below (formatting, testing, linting, typechecks) run:

``` bash
make ci
```

### Testing

To trigger `pytest` (TODO: and `coverage`):
Expand All @@ -47,39 +57,17 @@ To trigger `pytest` (TODO: and `coverage`):
make test
```

<!-- or keep them running on change:
``` bash
make dev
``` -->

### Static Analysis

By default this project is set up to lint with `flake8` and `mypy`, while `autopep8` and `isort` take care of autofixing. To run linters and static analyzers:

``` bash
make lint-fix # autopep8 and isort
make lint # flake8 and mypy
```

## Continuous Integration & Deployment

To run the same checks as in CI, which are a combination of the above tasks (testing, linting, static analysis) run:

``` bash
make ci
```

### pre-commit hooks

[`pre-commit`](https://github.com/pre-commit/pre-commit) should be used to run checks on staged changes before each commit and to enforce the commit message style.
Before you start development, please install the hooks like so:

``` bash
pre-commit install && pre-commit install --hook-type commit-msg
make format # ruff fixes
make lint # ruff checks
make mypy # mypy
```

### Commit Message Style
## Commit Message Style

A [uniform commit message style](https://commitizen-tools.github.io/commitizen/tutorials/writing_commits/)
and [here](https://www.conventionalcommits.org/en/v1.0.0/). for better readibilty shall be enforced to be able to generate a [changelog](./CHANGELOG.md).
Expand All @@ -88,7 +76,7 @@ Commit message should be prefixed with one of the following:

`fix:` | `feat:` | `docs:` | `style:` | `refactor:` | `perf:` | `test:` | `build:` | `ci:` | `chore:` | `revert:`.

#### Example
### Example

``` bash
git commit -m "feat: adds support for new feature"
Expand Down
Loading

0 comments on commit 5a8f386

Please sign in to comment.