Skip to content

Commit ae8818d

Browse files
authored
Merge pull request #3899 from mashehu/switch-to-trek
2 parents ee4e57e + 9a24784 commit ae8818d

File tree

10 files changed

+28
-39
lines changed

10 files changed

+28
-39
lines changed

.devcontainer/build-devcontainer/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ COPY . /root/nfcore-tools/
99
# install local nf-core tools version, and precommit hooks
1010
RUN cd /root/nfcore-tools/ && \
1111
conda install -y python=3.13 && \
12-
pip install --no-cache-dir --upgrade pip setuptools wheel pre-commit && \
12+
pip install --no-cache-dir --upgrade pip setuptools wheel && \
1313
pip install -r requirements.txt --no-cache-dir -e . && \
14-
pre-commit install --install-hooks && \
1514
rm -rf /root/.cache/pip
1615

1716
# Install nextflow and nf-test via conda and run conda clean

.devcontainer/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ nextflow self-update
1212
# Install specifically the version of tools from the workspace
1313
pip install --upgrade -r requirements.txt -r requirements-dev.txt -e .
1414

15+
# Install pre-commit hooks
16+
prek install --install-hooks
17+
1518
# Update welcome message
1619
echo "Welcome to the nf-core devcontainer!" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt

.github/workflows/changelog.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ jobs:
7272
python-version: "3.14"
7373
cache: "pip"
7474

75-
- name: Install pre-commit
76-
run: pip install pre-commit
77-
78-
- name: Run pre-commit checks
79-
if: steps.file_changed.outputs.changed == 'TRUE'
80-
run: |
81-
pre-commit run --all-files
75+
- name: Run pre-commit rules with prek
76+
uses: j178/prek-action@v1
8277

8378
- name: Commit and push changes
8479
if: steps.file_changed.outputs.changed == 'TRUE'

.github/workflows/fix-linting.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,25 @@ jobs:
3131
env:
3232
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}
3333

34-
# Install and run pre-commit
35-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
34+
# Install and run prek
35+
- name: Run prek
36+
id: prek
37+
uses: j178/prek-action@v1
3638
with:
37-
python-version: "3.14"
38-
39-
- name: Install pre-commit
40-
run: pip install pre-commit
41-
42-
- name: Run pre-commit
43-
id: pre-commit
44-
run: pre-commit run --all-files
39+
extra-args: --config .pre-commit-config.yaml --all-files
4540
continue-on-error: true
4641

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

5550
- name: Commit & push changes
5651
id: commit-and-push
57-
if: steps.pre-commit.outcome == 'failure'
52+
if: steps.prek.outcome == 'failure'
5853
run: |
5954
git config user.email "[email protected]"
6055
git config user.name "nf-core-bot"

.github/workflows/lint-code.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,13 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
Pre-commit:
18+
pre-commit:
1919
runs-on: ubuntu-latest
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
2221
steps:
2322
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6
2423

25-
- name: Set up Python 3.14
26-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
24+
- name: Run prek
25+
uses: j178/prek-action@v1
2726
with:
28-
python-version: "3.14"
29-
cache: "pip"
30-
31-
- name: Install pre-commit
32-
run: pip install pre-commit
33-
34-
- name: Run pre-commit
35-
run: pre-commit run --all-files
27+
extra-args: --config .pre-commit-config.yaml --all-files

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repos:
99
rev: "v3.1.0"
1010
hooks:
1111
- id: prettier
12+
entry: prettier --experimental-cli --write --ignore-unknown --no-cache
1213
additional_dependencies:
1314
1415
- repo: https://github.com/pre-commit/pre-commit-hooks

.prettierrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
printWidth: 120
22
tabWidth: 4
33
overrides:
4-
- files: "*.{md,yml,yaml,html,css,scss,js,cff}"
4+
- files: "**/*.{md,yml,yaml,html,css,scss,js,cff}"
55
options:
66
tabWidth: 2

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### General
66

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

910
### Template
1011

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,24 @@ Ruff has been adopted for linting and formatting in replacement of Black, isort
5656

5757
### pre-commit hooks
5858

59-
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.
59+
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.
6060

61-
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.
61+
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.
6262

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

6565
```bash
66-
pre-commit install --install-hooks
66+
prek install --install-hooks
6767
```
6868

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

7171
```bash
72-
pre-commit run --all
72+
prek run --config .pre-commit-config.yaml --all-files
7373
```
7474

75+
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/`.
76+
7577
## API Documentation
7678

7779
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.

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mypy
22
myst_parser
3+
prek
34
pytest-cov
45
pytest-datafiles
56
responses

0 commit comments

Comments
 (0)