diff --git a/.github/workflows/branch-checks.yaml b/.github/workflows/branch-checks.yaml new file mode 100644 index 0000000..0d1c2bb --- /dev/null +++ b/.github/workflows/branch-checks.yaml @@ -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" diff --git a/.github/workflows/pip_installation.yml b/.github/workflows/pip_installation.yml index de8e839..0edff52 100644 --- a/.github/workflows/pip_installation.yml +++ b/.github/workflows/pip_installation.yml @@ -9,7 +9,7 @@ on: push: branches: [ main, development ] pull_request: - branches: [ main, development ] + branches: [ main ] workflow_dispatch: name: Pip installation and tests @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..60d6476 --- /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 12ffc1c..743d7b4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/extra_requirements/development.txt b/extra_requirements/development.txt index 5d4b0f8..7351420 100644 --- a/extra_requirements/development.txt +++ b/extra_requirements/development.txt @@ -24,3 +24,5 @@ furo alphabase>=1.1.0 alphatims + +pre-commit==3.7.0