Repository: MannLabs/alphapeptstats (language: python)

Issue:
Code formatting
WHO
Developers
WHAT
Have properly formatted code in alphapeptstats
WHY
Best practises, less overhead when developing

AC
-    Code is formatted once using ruff
-    pre-commit hook is in place that takes care about the formatting
 -   pre-commit hook runs in CI pipeline
cf. [#153](https://github.com/MannLabs/alphabase/issues/153)


Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..60d64761
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,14 @@
+# 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: v2.3.0
+  hooks:
+    - id: check-yaml
+    - id: end-of-file-fixer
+    - id: trailing-whitespace
+- repo: https://github.com/astral-sh/ruff-pre-commit
+  rev: v0.4.0
+  hooks:
+    - id: ruff-format
+#    - id: ruff
diff --git a/README.md b/README.md
index 96805e27..2d70f05b 100644
--- a/README.md
+++ b/README.md
@@ -116,6 +116,24 @@ AlphaStats was developed by the [Mann Group at the University of Copenhagen](htt
 
 If you like this software, you can give us a [star](https://github.com/MannLabs/alphapeptstats/stargazers) to boost our visibility! All direct contributions are also welcome. Feel free to post a new [issue](https://github.com/MannLabs/alphapeptstats/issues) or clone the repository and create a [pull request](https://github.com/MannLabs/alphapeptstats/pulls) with a new branch. For an even more interactive participation, check out the [discussions](https://github.com/MannLabs/alphapeptstats/discussions) and the [the Contributors License Agreement](misc/CLA.md).
 
+
+### Notes for developers
+#### pre-commit hooks
+It is highly recommended to use the provided pre-commit hooks, as the CI pipeline enforces all checks therein to
+pass in order to merge a branch.
+
+The hooks need to be installed once by
+```bash
+pip install -r requirements_dev.txt
+pre-commit install
+```
+You can run the checks yourself using:
+```bash
+pre-commit run --all-files
+```
+
+
+
 ---
 ## Changelog
 
diff --git a/requirements_dev.txt b/requirements_dev.txt
new file mode 100644
index 00000000..ff5aba65
--- /dev/null
+++ b/requirements_dev.txt
@@ -0,0 +1,2 @@
+# only needed for local development
+pre-commit==3.5.0


Test patch:
diff --git a/.github/workflows/python-package.yml b/.github/workflows/build_and_test.yml
similarity index 73%
rename from .github/workflows/python-package.yml
rename to .github/workflows/build_and_test.yml
index 4ad23470..7c717d7a 100644
--- a/.github/workflows/python-package.yml
+++ b/.github/workflows/build_and_test.yml
@@ -2,24 +2,27 @@
 # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
 
 
-name: CI
+name: Build and run tests
 
-
-on: [push, pull_request]
-#  push:
-#    branches: [ "main", "developer"]
-#  pull_request:
-#    branches: [ "main", "developer"]
+on:
+  push:
+    branches: [ main, development ]
+  pull_request:
 
 jobs:
-  build:
-
+  pre-commit:
+    name: Run all pre-commit hooks
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-python@v3
+      - uses: pre-commit/action@v3.0.1
+  build-and-test:
     runs-on: ubuntu-latest
     strategy:
       fail-fast: false
       matrix:
         python-version: ["3.8", "3.9", "3.10"]
-
     steps:
     - uses: actions/checkout@v3
     - name: Set up Python ${{ matrix.python-version }}
@@ -34,7 +37,7 @@ jobs:
         pip install dictdiffer
     - name: Test installation
       run: |
-        pip install -e.
+        pip install -e .
     - name: Run tests
       run: |
         coverage run -m unittest