Skip to content

Commit

Permalink
Introduce python pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
soerface committed Sep 21, 2024
1 parent c219d6b commit baffd56
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ jobs:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
DRY_RUN: true
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout
# From https://github.com/actions/checkout/issues/438#issuecomment-1114110354
# Required to fetch enough depth for diffs with master in the pre-commit step.
# Alternative is to use the checkout action with fetch-depth: 0, but that would
# fetch the whole history, potentially slowing down the CI pipeline.
run: |
commits=${{ github.event.pull_request.commits }}
if [[ -n "$commits" ]]; then
# Prepare enough depth for diffs with master
git fetch --depth="$(( commits + 1 ))"
fi
- uses: actions/setup-python@v3
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
with:
extra_args: '--from-ref origin/master --to-ref ${{ github.sha }}'
build:
name: Build
uses: dargmuesli/github-actions/.github/workflows/[email protected]
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: '7.1.1'
hooks:
- id: flake8
language: python
language_version: python3.11
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@ Digital replacement for the drinks tally list featuring a touchscreen, user mana
docker compose -f docker-compose.dev.yml up
```

- Reading mails via mailpit: http://localhost:8025/
Reading mails via mailpit: http://localhost:8025/

The project is using poetry. Install the dependencies with:

```sh
poetry install
```

Python `pre-commit` helps to detect and fix common issues before committing. Install the git hooks with:

```sh
pre-commit install
```

It is also being run in the CI pipeline. If you see any rules that don't make sense for us, feel free
to adjust the `.pre-commit-config.yaml` file or comment out invocation in the `ci.yml` file.

This project is deployed within the [drinks-touch_stack](https://github.com/flipdot/drinks-touch_stack/) in accordance to the [DargStack template](https://github.com/dargstack/dargstack_template/) to make deployment a breeze.

Expand Down
Loading

0 comments on commit baffd56

Please sign in to comment.