Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/build-devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ COPY . /root/nfcore-tools/
# install local nf-core tools version, and precommit hooks
RUN cd /root/nfcore-tools/ && \
conda install -y python=3.13 && \
pip install --no-cache-dir --upgrade pip setuptools wheel pre-commit && \
pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install -r requirements.txt --no-cache-dir -e . && \
pre-commit install --install-hooks && \
rm -rf /root/.cache/pip

# Install nextflow and nf-test via conda and run conda clean
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ nextflow self-update
# Install specifically the version of tools from the workspace
pip install --upgrade -r requirements.txt -r requirements-dev.txt -e .

# Install pre-commit hooks
prek install --install-hooks

# Update welcome message
echo "Welcome to the nf-core devcontainer!" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt
9 changes: 2 additions & 7 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,8 @@ jobs:
python-version: "3.14"
cache: "pip"

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit checks
if: steps.file_changed.outputs.changed == 'TRUE'
run: |
pre-commit run --all-files
- name: Run pre-commit rules with prek
uses: j178/prek-action@v1

- name: Commit and push changes
if: steps.file_changed.outputs.changed == 'TRUE'
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,25 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

# Install and run pre-commit
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
# Install and run prek
- name: Run prek
id: prek
uses: j178/prek-action@v1
with:
python-version: "3.14"

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit
id: pre-commit
run: pre-commit run --all-files
extra-args: --config .pre-commit-config.yaml --all-files
continue-on-error: true

# indication that the linting has finished
- name: react if linting finished succesfully
if: steps.pre-commit.outcome == 'success'
if: steps.prek.outcome == 'success'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
comment-id: ${{ github.event.comment.id }}
reactions: "+1"

- name: Commit & push changes
id: commit-and-push
if: steps.pre-commit.outcome == 'failure'
if: steps.prek.outcome == 'failure'
run: |
git config user.email "[email protected]"
git config user.name "nf-core-bot"
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ concurrency:
cancel-in-progress: true

jobs:
Pre-commit:
pre-commit:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6

- name: Set up Python 3.14
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
- name: Run prek
uses: j178/prek-action@v1
with:
python-version: "3.14"
cache: "pip"

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files
extra-args: --config .pre-commit-config.yaml --all-files
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repos:
rev: "v3.1.0"
hooks:
- id: prettier
entry: prettier --experimental-cli --write --ignore-unknown --no-cache
additional_dependencies:
- [email protected]
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
printWidth: 120
tabWidth: 4
overrides:
- files: "*.{md,yml,yaml,html,css,scss,js,cff}"
- files: "**/*.{md,yml,yaml,html,css,scss,js,cff}"
options:
tabWidth: 2
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### General

- Update actions/setup-python digest to 83679a8 ([#3928](https://github.com/nf-core/tools/pull/3928))
- Switch from pre-commit to prek for pre-commit hooks in development([#3899](https://github.com/nf-core/tools/pull/3899))

### Template

Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,24 @@ Ruff has been adopted for linting and formatting in replacement of Black, isort

### pre-commit hooks

This repository comes with [pre-commit](https://pre-commit.com/) hooks for ruff and Prettier. pre-commit automatically runs checks before a commit is committed into the git history. If all checks pass, the commit is made, if files are changed by the pre-commit hooks, the user is informed and has to stage the changes and attempt the commit again.
This repository comes with pre-commit hooks for ruff and Prettier, managed by [prek](https://github.com/j178/prek). Pre-commit hooks automatically run checks before a commit is committed into the git history. If all checks pass, the commit is made, if files are changed by the pre-commit hooks, the user is informed and has to stage the changes and attempt the commit again.

You can use the pre-commit hooks if you like, but you don't have to. The CI on Github will run the same checks as the tools installed with pre-commit. If the pre-commit checks pass, then the same checks in the CI will pass, too.
You can use the pre-commit hooks if you like, but you don't have to. The CI on Github will run the same checks as the tools installed with prek. If the pre-commit checks pass, then the same checks in the CI will pass, too.

You can install the pre-commit hooks into the development environment by running the following command in the root directory of the repository.

```bash
pre-commit install --install-hooks
prek install --install-hooks
```

You can also run all pre-commit hooks without making a commit:

```bash
pre-commit run --all
prek run --config .pre-commit-config.yaml --all-files
```

Note: The `--config` flag is important in this repository to ensure prek uses the root configuration file and not the template configs in `nf_core/pipeline-template/`.

## API Documentation

We aim to write function docstrings according to the [Google Python style-guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings). These are used to automatically generate package documentation on the nf-core website using Sphinx.
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mypy
myst_parser
prek
pytest-cov
pytest-datafiles
responses
Expand Down