From 1b78bc99707e4d4f9376de689078f2b332cec985 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 23 Aug 2024 13:56:27 -0500 Subject: [PATCH 01/11] feat: Add pre-commit hooks for lint commands --- .pre-commit-hooks.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000000..ac9bf27f58 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,18 @@ +- id: lint-modules + name: Lint nf-core modules + # description: This hook trims trailing whitespace. + entry: nf-core modules lint + language: python + types: [text] + files: "modules/**/*.nf" + pass_filenames: true + # args: [] +- id: lint-subworkflows + name: Lint nf-core subworkflows + # description: This hook trims trailing whitespace. + entry: nf-core subworkflows lint + language: python + types: [text] + files: "subworkflows/**/*.nf" + pass_filenames: true + # args: [] From ef592e3619b206b86da5709d656e2976218e9f4e Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 23 Aug 2024 14:07:59 -0500 Subject: [PATCH 02/11] fix: Use a valid python regex --- .pre-commit-hooks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index ac9bf27f58..ded6d2f059 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -4,7 +4,7 @@ entry: nf-core modules lint language: python types: [text] - files: "modules/**/*.nf" + files: ^modules/.*/.*/.*\.nf$ pass_filenames: true # args: [] - id: lint-subworkflows @@ -13,6 +13,6 @@ entry: nf-core subworkflows lint language: python types: [text] - files: "subworkflows/**/*.nf" + files: ^subworkflows/.*/.*/.*\.nf$ pass_filenames: true # args: [] From 8d463bcdfb1e029bd0d4ab6a22ff8667d62305d0 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 23 Aug 2024 14:28:46 -0500 Subject: [PATCH 03/11] fix: Add --hide-progress --- .pre-commit-hooks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index ded6d2f059..3a2070e64d 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,7 +1,7 @@ - id: lint-modules name: Lint nf-core modules # description: This hook trims trailing whitespace. - entry: nf-core modules lint + entry: nf-core --hide-progress modules lint language: python types: [text] files: ^modules/.*/.*/.*\.nf$ @@ -10,7 +10,7 @@ - id: lint-subworkflows name: Lint nf-core subworkflows # description: This hook trims trailing whitespace. - entry: nf-core subworkflows lint + entry: nf-core --hide-progress subworkflows lint language: python types: [text] files: ^subworkflows/.*/.*/.*\.nf$ From 413ebd1e639bf960ec765e38b4e7dba2afcc2b0b Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Mon, 26 Aug 2024 16:28:34 +0000 Subject: [PATCH 04/11] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a16435057..67af20ccec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,6 +187,7 @@ - Update pre-commit hook pre-commit/mirrors-mypy to v1.11.1 ([#3091](https://github.com/nf-core/tools/pull/3091)) - Update to pytest v8 and move it to dev dependencies ([#3058](https://github.com/nf-core/tools/pull/3058)) - Update minimal textual version and snapshots ([#2998](https://github.com/nf-core/tools/pull/2998)) +- Create pre-commit hooks ([#3141](https://github.com/nf-core/tools/pull/3141)) ## [v2.14.1 - Tantalum Toad - Patch](https://github.com/nf-core/tools/releases/tag/2.14.1) - [2024-05-09] From 2a05abaa525256e3e7ee8fda7008699b6e41bc3b Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 27 Aug 2024 10:45:58 -0500 Subject: [PATCH 05/11] feat: Add pre-commit hooks to pipeline template Co-authored-by: mashehu --- .pre-commit-hooks.yaml | 1 + nf_core/pipeline-template/.pre-commit-config.yaml | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3a2070e64d..2bfe873592 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -16,3 +16,4 @@ files: ^subworkflows/.*/.*/.*\.nf$ pass_filenames: true # args: [] +# TODO lint-pipeline diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index 9e9f0e1c4e..7e2862e74e 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -11,3 +11,9 @@ repos: hooks: - id: editorconfig-checker alias: ec + - repo: https://github.com/nf-core/tools + rev: "2.14.1" + hooks: + - id: lint-modules + - id: lint-subworkflows + # TODO lint-pipeline From 044adba2ddc218f71487ec7bde5f00850b2d0d9e Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 27 Aug 2024 10:49:46 -0500 Subject: [PATCH 06/11] feat: Add lint-pipeline test --- .pre-commit-hooks.yaml | 8 +++++++- nf_core/pipeline-template/.pre-commit-config.yaml | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 2bfe873592..da043ce09c 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -16,4 +16,10 @@ files: ^subworkflows/.*/.*/.*\.nf$ pass_filenames: true # args: [] -# TODO lint-pipeline +- id: lint-pipeline + name: Lint nf-core pipeline + description: Check pipeline code against nf-core guidelines. + entry: nf-core --hide-progress lint + language: python + types: [text] + # args: [] diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index 7e2862e74e..d350cfd5b5 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -14,6 +14,4 @@ repos: - repo: https://github.com/nf-core/tools rev: "2.14.1" hooks: - - id: lint-modules - - id: lint-subworkflows - # TODO lint-pipeline + - id: lint-pipeline From e4a2f4c9cf17405125a9e0ad9a3e0750507dcdb7 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 25 Nov 2024 12:31:14 -0600 Subject: [PATCH 07/11] fix: Just run linting on all the subworkflows --- .pre-commit-hooks.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index da043ce09c..b894f7387f 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -7,14 +7,16 @@ files: ^modules/.*/.*/.*\.nf$ pass_filenames: true # args: [] + # NOTE See https://github.com/nf-core/modules/pull/7084 for reasoning - id: lint-subworkflows name: Lint nf-core subworkflows - # description: This hook trims trailing whitespace. - entry: nf-core --hide-progress subworkflows lint + description: Runs linting on all the subworkflows + entry: nf-core --hide-progress subworkflows lint -a language: python types: [text] - files: ^subworkflows/.*/.*/.*\.nf$ - pass_filenames: true + files: ^subworkflows/[^/]+$ + alias: sw + pass_filenames: false # args: [] - id: lint-pipeline name: Lint nf-core pipeline From 579328049d202d5d80da61967129f934ebbf4446 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 25 Nov 2024 12:42:59 -0600 Subject: [PATCH 08/11] chore: Mark nf-core modules lint hook as TODO --- .pre-commit-hooks.yaml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index b894f7387f..63c0004e52 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,13 +1,14 @@ -- id: lint-modules - name: Lint nf-core modules - # description: This hook trims trailing whitespace. - entry: nf-core --hide-progress modules lint - language: python - types: [text] - files: ^modules/.*/.*/.*\.nf$ - pass_filenames: true - # args: [] - # NOTE See https://github.com/nf-core/modules/pull/7084 for reasoning +# TODO https://github.com/nf-core/tools/issues/3140 +# - id: lint-modules +# name: Lint nf-core modules +# # description: This hook trims trailing whitespace. +# entry: nf-core --hide-progress modules lint +# language: python +# types: [text] +# files: ^modules/[^/]+$ +# pass_filenames: true +# args: [] +# NOTE See https://github.com/nf-core/modules/pull/7084 for reasoning - id: lint-subworkflows name: Lint nf-core subworkflows description: Runs linting on all the subworkflows From 0d9700beb7e3e3f9effe4cf910663dc3273e3d61 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 25 Nov 2024 12:51:43 -0600 Subject: [PATCH 09/11] fix: nf-core lint => pipelines lint --- .pre-commit-hooks.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 63c0004e52..5b9db5fb83 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -22,7 +22,8 @@ - id: lint-pipeline name: Lint nf-core pipeline description: Check pipeline code against nf-core guidelines. - entry: nf-core --hide-progress lint + entry: nf-core --hide-progress pipelines lint language: python types: [text] - # args: [] + pass_filenames: false + # args: ["--fix"] From 3ef781e3a26936c14f8a20eadec5969fe439eee1 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 25 Nov 2024 12:51:57 -0600 Subject: [PATCH 10/11] fix: Only run nf-core pipelines lint on pre-push and manual --- .pre-commit-hooks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 5b9db5fb83..30e619afd3 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -26,4 +26,5 @@ language: python types: [text] pass_filenames: false + stages: [pre-push, manual] # args: ["--fix"] From 7bed55fa25534dfd61131b131ff91aeb369a7ba5 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 25 Nov 2024 12:56:22 -0600 Subject: [PATCH 11/11] fix: Update version to be release 3.1.0 --- nf_core/pipeline-template/.pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index d350cfd5b5..aeb7ab00a8 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -12,6 +12,6 @@ repos: - id: editorconfig-checker alias: ec - repo: https://github.com/nf-core/tools - rev: "2.14.1" + rev: "3.1.0" hooks: - id: lint-pipeline