Skip to content

Commit

Permalink
Merge pull request #46 from MannLabs/39-pre-commit-hook
Browse files Browse the repository at this point in the history
39 pre commit hook
  • Loading branch information
mschwoer authored May 17, 2024
2 parents 850114e + a18c0f7 commit f13fe29
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/branch-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# checks to run on branches for each pull request
name: branch-checks

on:
pull_request:

jobs:
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
# For feature branches, we don't test the full matrix (os x [stable, loose]) in order to save time & resources.
run-tests-loose:
name: Test loose pip installation on ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
uses: ./.github/workflows/_run_tests.yml
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
install-script: "loose_pip_install.sh"
3 changes: 1 addition & 2 deletions .github/workflows/pip_installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
push:
branches: [ main, development ]
pull_request:
branches: [ main, development ]
branches: [ main ]
workflow_dispatch:

name: Pip installation and tests
Expand All @@ -29,7 +29,6 @@ jobs:

loose_installation:
name: Test loose pip installation on ${{ matrix.os }}
# runs-on: ${{ matrix.os }} # `runs-on` conflicts with `uses`, see https://github.com/orgs/community/discussions/62320
strategy:
matrix:
# macos-latest is now arm64, which cannot install mono
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ For an even more interactive participation, check out the
[discussions](https://github.com/MannLabs/alpharaw/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
pre-commit install
```
You can run the checks yourself using:
```bash
pre-commit run --all-files
```
------------------------------------------------------------------------

## Changelog
Expand Down
2 changes: 2 additions & 0 deletions extra_requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ furo

alphabase>=1.1.0
alphatims

pre-commit==3.7.0

0 comments on commit f13fe29

Please sign in to comment.