Repository: nf-core/tools

Issue:
Lint for custom configs
At the moment, lint tests pass even when there is no mention of nf-core/configs. We should probably ensure that pipelines are pulling these profiles in.


Discussion:
Basically check that these lines exist in `nextflow.config`:

https://github.com/nf-core/tools/blob/d0a6649cbe7bff98b89a9990955a3fe256e02d55/nf_core/pipeline-template/nextflow.config#L55-L60

And that these config params are defined as these values:

https://github.com/nf-core/tools/blob/d0a6649cbe7bff98b89a9990955a3fe256e02d55/nf_core/pipeline-template/nextflow.config#L31-L32
Would also be nice to check over the linting for required core config params too. I notice that `show_hidden_params` and `schema_ignore_params` should be checked.

Resolving patch:
diff --git a/nf_core/lint/nextflow_config.py b/nf_core/lint/nextflow_config.py
--- a/nf_core/lint/nextflow_config.py
+++ b/nf_core/lint/nextflow_config.py
@@ -1,6 +1,10 @@
 #!/usr/bin/env python
 
 import re
+import os
+import logging
+
+log = logging.getLogger(__name__)
 
 
 def nextflow_config(self):
@@ -51,6 +55,23 @@ def nextflow_config(self):
 
         * ``params.input``: Input data that is not NGS sequencing data
 
+    * ``params.custom_config_version``
+
+        * Should always be set to default value ``master``
+
+    * ``params.custom_config_base``
+
+        * Should always be set to default value:
+        ``https://raw.githubusercontent.com/nf-core/configs/${params.custom_config_version}``
+
+    * ``params.show_hidden_params``
+
+        * Determines whether boilerplate params are showed by schema. Set to ``false`` by default
+
+    * ``params.schema_ignore_params``
+
+        * A comma separated string of inputs the schema validation should ignore.
+
     **The following variables throw warnings if missing:**
 
     * ``manifest.mainScript``: The filename of the main pipeline script (should be ``main.nf``)
@@ -115,6 +136,8 @@ def nextflow_config(self):
         ["process.time"],
         ["params.outdir"],
         ["params.input"],
+        ["params.show_hidden_params"],
+        ["params.schema_ignore_params"],
     ]
     # Throw a warning if these are missing
     config_warn = [
@@ -281,4 +304,46 @@ def nextflow_config(self):
                 )
             )
 
+    # Check if custom profile params are set correctly
+    if self.nf_config.get("params.custom_config_version", "").strip("'") == "master":
+        passed.append("Config `params.custom_config_version` is set to `master`")
+    else:
+        failed.append("Config `params.custom_config_version` is not set to `master`")
+
+    custom_config_base = "https://raw.githubusercontent.com/nf-core/configs/{}".format(
+        self.nf_config.get("params.custom_config_version", "").strip("'")
+    )
+    if self.nf_config.get("params.custom_config_base", "").strip("'") == custom_config_base:
+        passed.append("Config `params.custom_config_base` is set to `{}`".format(custom_config_base))
+    else:
+        failed.append("Config `params.custom_config_base` is not set to `{}`".format(custom_config_base))
+
+    # Check that lines for loading custom profiles exist
+    lines = [
+        r"// Load nf-core custom profiles from different Institutions",
+        r"try {",
+        r'includeConfig "${params.custom_config_base}/nfcore_custom.config"',
+        r"} catch (Exception e) {",
+        r'System.err.println("WARNING: Could not load nf-core/config profiles: ${params.custom_config_base}/nfcore_custom.config")',
+        r"}",
+    ]
+    path = os.path.join(self.wf_path, "nextflow.config")
+    i = 0
+    with open(path, "r") as f:
+        for line in f:
+            if lines[i] in line:
+                i += 1
+                if i == len(lines):
+                    break
+            else:
+                i = 0
+    if i == len(lines):
+        passed.append("Lines for loading custom profiles found")
+    else:
+        lines[2] = f"\t{lines[2]}"
+        lines[4] = f"\t{lines[4]}"
+        failed.append(
+            "Lines for loading custom profiles not found. File should contain: ```groovy\n{}".format("\n".join(lines))
+        )
+
     return {"passed": passed, "warned": warned, "failed": failed, "ignored": ignored}


Test patch: