diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2c755e55..c0fa29549e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - Error if module container specification has quay.io as prefix when it shouldn't have ([#2278])(https://github.com/nf-core/tools/pull/2278/files) - Detect if container is 'simple name' and try to contact quay.io server by default ([#2281](https://github.com/nf-core/tools/pull/2281)) - Warn about null/None/empty default values in `nextflow_schema.json` ([#3328](https://github.com/nf-core/tools/pull/2328)) +- Fix linting when creating a pipeline skipping some parts of the template and add CI test ([#2330](https://github.com/nf-core/tools/pull/2330)) ### Modules diff --git a/nf_core/create.py b/nf_core/create.py index 9e3b38102f..7416bd8f74 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -352,6 +352,7 @@ def render_template(self): if self.template_yaml: with open(self.outdir / "pipeline_template.yml", "w") as fh: yaml.safe_dump(self.template_yaml, fh) + run_prettier_on_file(self.outdir / "pipeline_template.yml") def update_nextflow_schema(self): """ @@ -403,6 +404,12 @@ def fix_linting(self): ".github/workflows/awstest.yml", ".github/workflows/awsfulltest.yml", ], + "files_unchanged": [ + "CODE_OF_CONDUCT.md", + f"assets/nf-core-{short_name}_logo_light.png", + f"docs/images/nf-core-{short_name}_logo_light.png", + f"docs/images/nf-core-{short_name}_logo_dark.png", + ], "nextflow_config": [ "manifest.name", "manifest.homePage", @@ -415,9 +422,26 @@ def fix_linting(self): lint_config["files_exist"].extend( [ ".github/ISSUE_TEMPLATE/bug_report.yml", + ".github/ISSUE_TEMPLATE/feature_request.yml", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/CONTRIBUTING.md", + ".github/.dockstore.yml", + ".gitignore", + ] + ) + lint_config["files_unchanged"].extend( + [ + ".github/ISSUE_TEMPLATE/bug_report.yml", + ".github/ISSUE_TEMPLATE/config.yml", + ".github/ISSUE_TEMPLATE/feature_request.yml", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/workflows/branch.yml", + ".github/workflows/linting_comment.yml", + ".github/workflows/linting.yml", + ".github/CONTRIBUTING.md", + ".github/.dockstore.yml", ] ) - lint_config["files_unchanged"] = [".github/ISSUE_TEMPLATE/bug_report.yml"] # Add CI specific configurations if not self.template_params["ci"]: @@ -446,6 +470,10 @@ def fix_linting(self): if not self.template_params["github_badges"] or not self.template_params["github"]: lint_config["readme"] = ["nextflow_badge"] + # If the pipeline is unbranded + if not self.template_params["branded"]: + lint_config["files_unchanged"].extend([".github/ISSUE_TEMPLATE/bug_report.yml"]) + # Add the lint content to the preexisting nf-core config config_fn, nf_core_yml = nf_core.utils.load_tools_config(self.outdir) nf_core_yml["lint"] = lint_config diff --git a/tests/data/pipeline_create_template_skip.yml b/tests/data/pipeline_create_template_skip.yml new file mode 100644 index 0000000000..b69175e0bb --- /dev/null +++ b/tests/data/pipeline_create_template_skip.yml @@ -0,0 +1,7 @@ +prefix: testprefix +skip: + - github + - ci + - github_badges + - igenomes + - nf_core_configs diff --git a/tests/test_create.py b/tests/test_create.py index cc6bf8ba47..298eeecde5 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -13,6 +13,7 @@ TEST_DATA_DIR = Path(__file__).parent / "data" PIPELINE_TEMPLATE_YML = TEST_DATA_DIR / "pipeline_create_template.yml" +PIPELINE_TEMPLATE_YML_SKIP = TEST_DATA_DIR / "pipeline_create_template_skip.yml" class NfcoreCreateTest(unittest.TestCase): @@ -107,3 +108,31 @@ def test_pipeline_creation_initiation_customize_template(self, mock_questionary, assert os.path.exists(pipeline_template) with open(pipeline_template) as fh: assert fh.read() == PIPELINE_TEMPLATE_YML.read_text() + + @with_temporary_folder + def test_pipeline_creation_with_yml_skip(self, tmp_path): + pipeline = nf_core.create.PipelineCreate( + name=self.pipeline_name, + description=self.pipeline_description, + author=self.pipeline_author, + version=self.pipeline_version, + no_git=False, + force=True, + outdir=tmp_path, + template_yaml_path=PIPELINE_TEMPLATE_YML_SKIP, + plain=True, + default_branch=self.default_branch, + ) + pipeline.init_pipeline() + assert not os.path.isdir(os.path.join(pipeline.outdir, ".git")) + + # Check pipeline yml has been dumped and matches input + pipeline_template = os.path.join(pipeline.outdir, "pipeline_template.yml") + assert os.path.exists(pipeline_template) + with open(pipeline_template) as fh: + assert fh.read() == PIPELINE_TEMPLATE_YML_SKIP.read_text() + + # Check that some of the skipped files are not present + assert not os.path.exists(os.path.join(pipeline.outdir, "CODE_OF_CONDUCT.md")) + assert not os.path.exists(os.path.join(pipeline.outdir, ".github")) + assert not os.path.exists(os.path.join(pipeline.outdir, "conf", "igenomes.config"))