From 269dde9e3934b065c251e056a0fd7a38236b628e Mon Sep 17 00:00:00 2001 From: mashehu Date: Thu, 23 Feb 2023 10:30:16 +0100 Subject: [PATCH 1/2] add pre-commit docs for modules --- markdown/developers/modules.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/markdown/developers/modules.md b/markdown/developers/modules.md index bfe03e8d51..7b4c603a61 100644 --- a/markdown/developers/modules.md +++ b/markdown/developers/modules.md @@ -45,11 +45,17 @@ If the module doesn't exist on `nf-core/modules`: We have implemented a number of commands in the `nf-core/tools` package to make it incredibly easy for you to create and contribute your own modules to nf-core/modules. -1. Install the latest version of [`nf-core/tools`](https://github.com/nf-core/tools#installation) (`>=2.3`) +1. Install the latest version of [`nf-core/tools`](https://github.com/nf-core/tools#installation) (`>=2.7`) 2. Install [`Nextflow`](https://www.nextflow.io/docs/latest/getstarted.html#installation) (`>=21.04.0`) 3. Install any of [`Docker`](https://docs.docker.com/engine/installation/), [`Singularity`](https://www.sylabs.io/guides/3.0/user-guide/) or [`Conda`](https://conda.io/miniconda.html) -4. [Fork and clone the nf-core/modules repo locally](#uploading-to-nf-coremodules) -5. Set up git on your computer by adding a new git remote of the main nf-core git repo called `upstream` +4. Setup up [pre-commit](https://pre-commit.com/) (comes packaged with [`nf-core/tools`](https://github.com/nf-core/tools#installation), watch the [pre-commit bytesize talk](https://www.youtube.com/watch?v=08d6zv6zvdM&t=215) if you want to know more about it) to ensure that your code is linted and formatted correctly before you commit it to the repository + + ```bash + pre-commit install + ``` + +5. [Fork and clone the nf-core/modules repo locally](#uploading-to-nf-coremodules) +6. Set up git on your computer by adding a new git remote of the main nf-core git repo called `upstream` ```bash git remote add upstream https://github.com/nf-core/modules.git @@ -61,7 +67,7 @@ We have implemented a number of commands in the `nf-core/tools` package to make git checkout -b fastqc ``` -6. Create a module using the [nf-core DSL2 module template](https://github.com/nf-core/tools/blob/master/nf_core/module-template/modules/main.nf): +7. Create a module using the [nf-core DSL2 module template](https://github.com/nf-core/tools/blob/master/nf_core/module-template/modules/main.nf): ```console $ nf-core modules create fastqc --author @joebloggs --label process_low --meta @@ -95,7 +101,7 @@ We have implemented a number of commands in the `nf-core/tools` package to make 2. [`./modules/fastqc/meta.yml`](https://github.com/nf-core/modules/blob/master/modules/fastqc/meta.yml) - This file will be used to store general information about the module and author details - the majority of which will already be auto-filled. However, you will need to add a brief description of the files defined in the `input` and `output` section of the main script since these will be unique to each module. + This file will be used to store general information about the module and author details - the majority of which will already be auto-filled. However, you will need to add a brief description of the files defined in the `input` and `output` section of the main script since these will be unique to each module. We check it's formatting and validity based on a [JSON schema](https://github.com/nf-core/modules/blob/master/.yaml-schema.json) during linting (and in the pre-commit hook). 3. [`./tests/modules/fastqc/main.nf`](https://github.com/nf-core/modules/blob/master/tests/modules/fastqc/main.nf) From 8271a328cbfb664713fa545464791e1869c42496 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Thu, 23 Feb 2023 09:38:00 +0000 Subject: [PATCH 2/2] [automated] Fix linting with Prettier --- markdown/developers/modules.md | 94 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/markdown/developers/modules.md b/markdown/developers/modules.md index 7b4c603a61..917545c6e3 100644 --- a/markdown/developers/modules.md +++ b/markdown/developers/modules.md @@ -128,7 +128,7 @@ We have implemented a number of commands in the `nf-core/tools` package to make `md5sum` checks are the preferable choice of test to determine file changes, however, this may not be possible for all outputs generated by some tools e.g. if they include time stamps or command-related headers. Please do your best to avoid just checking for the file being present e.g. it may still be possible to check that the file contains the appropriate text snippets. -7. Create a yaml file containing information required for module unit testing +8. Create a yaml file containing information required for module unit testing ```console $ nf-core modules create-test-yml @@ -161,52 +161,52 @@ We have implemented a number of commands in the `nf-core/tools` package to make > NB: See docs for [running tests manually](#running-tests-manually) if you would like to run the tests manually. -8. Check that the new module you've added follows the [new module guidelines](#new-module-guidelines-and-pr-review-checklist) - -9. Lint the module locally to check that it adheres to nf-core guidelines before submission - - ```console - $ nf-core modules lint fastqc --dir . - - ,--./,-. - ___ __ __ __ ___ /,-._.--~\ - |\ | |__ __ / ` / \ |__) |__ } { - | \| | \__, \__/ | \ |___ \`-._,-`-, - `._,._,' - - nf-core/tools version 2.3dev0 - https://nf-co.re - - INFO Linting modules repo: . __init__.py:15 - INFO Linting module: fastqc __init__.py:163 - - ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ - │ [!] 3 Test Warnings │ - ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ - ╭──────────────┬──────────────────────────────────────────────────────────────┬──────────────────────────────────╮ - │ Module name │ Test message │ File path │ - ├──────────────┼──────────────────────────────────────────────────────────────┼──────────────────────────────────┤ - │ fastqc │ TODO string in meta.yml: #Add a description of the module... │ modules/nf-core/modules/fastqc/ │ - │ fastqc │ TODO string in meta.yml: #Add a description and other det... │ modules/nf-core/modules/fastqc/ │ - │ fastqc │ TODO string in meta.yml: #Add a description of all of the... │ modules/nf-core/modules/fastqc/ │ - ╰──────────────┴──────────────────────────────────────────────────────────────┴──────────────────────────────────╯ - ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ - │ [!] 1 Test Failed │ - ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ - ╭──────────────┬──────────────────────────────────────────────────────────────┬──────────────────────────────────╮ - │ Module name │ Test message │ File path │ - ├──────────────┼──────────────────────────────────────────────────────────────┼──────────────────────────────────┤ - │ fastqc │ 'meta' map not emitted in output channel(s) │ modules/nf-core/modules/fastqc/ │ - ╰──────────────┴──────────────────────────────────────────────────────────────┴──────────────────────────────────╯ - ╭──────────────────────╮ - │ LINT RESULTS SUMMARY │ - ├──────────────────────┤ - │ [✔] 38 Tests Passed │ - │ [!] 3 Test Warning │ - │ [✗] 1 Test Failed │ - ╰──────────────────────╯ - ``` - -10. Once ready, the code can be pushed and a pull request (PR) created +9. Check that the new module you've added follows the [new module guidelines](#new-module-guidelines-and-pr-review-checklist) + +10. Lint the module locally to check that it adheres to nf-core guidelines before submission + + ```console + $ nf-core modules lint fastqc --dir . + + ,--./,-. + ___ __ __ __ ___ /,-._.--~\ + |\ | |__ __ / ` / \ |__) |__ } { + | \| | \__, \__/ | \ |___ \`-._,-`-, + `._,._,' + + nf-core/tools version 2.3dev0 - https://nf-co.re + + INFO Linting modules repo: . __init__.py:15 + INFO Linting module: fastqc __init__.py:163 + + ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + │ [!] 3 Test Warnings │ + ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + ╭──────────────┬──────────────────────────────────────────────────────────────┬──────────────────────────────────╮ + │ Module name │ Test message │ File path │ + ├──────────────┼──────────────────────────────────────────────────────────────┼──────────────────────────────────┤ + │ fastqc │ TODO string in meta.yml: #Add a description of the module... │ modules/nf-core/modules/fastqc/ │ + │ fastqc │ TODO string in meta.yml: #Add a description and other det... │ modules/nf-core/modules/fastqc/ │ + │ fastqc │ TODO string in meta.yml: #Add a description of all of the... │ modules/nf-core/modules/fastqc/ │ + ╰──────────────┴──────────────────────────────────────────────────────────────┴──────────────────────────────────╯ + ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + │ [!] 1 Test Failed │ + ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + ╭──────────────┬──────────────────────────────────────────────────────────────┬──────────────────────────────────╮ + │ Module name │ Test message │ File path │ + ├──────────────┼──────────────────────────────────────────────────────────────┼──────────────────────────────────┤ + │ fastqc │ 'meta' map not emitted in output channel(s) │ modules/nf-core/modules/fastqc/ │ + ╰──────────────┴──────────────────────────────────────────────────────────────┴──────────────────────────────────╯ + ╭──────────────────────╮ + │ LINT RESULTS SUMMARY │ + ├──────────────────────┤ + │ [✔] 38 Tests Passed │ + │ [!] 3 Test Warning │ + │ [✗] 1 Test Failed │ + ╰──────────────────────╯ + ``` + +11. Once ready, the code can be pushed and a pull request (PR) created On a regular basis you can pull upstream changes into this branch and it is recommended to do so before pushing and creating a pull request - see below. Rather than merging changes directly from upstream the rebase strategy is recommended so that your changes are applied on top of the latest master branch from the nf-core repo. This can be performed as follows