From 18aa6216b2c982f32a56ca6b0c3518c2b6ab36f4 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 20 Jun 2023 13:03:26 +0200 Subject: [PATCH 1/5] add files to ignore if some parts of the tamplet are skipped --- nf_core/create.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/nf_core/create.py b/nf_core/create.py index 9e3b38102f..3e4e7a4212 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -403,6 +403,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 +421,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"]: From 8a86bbc2694336e4f58ed15828e90f682038be45 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 20 Jun 2023 13:24:25 +0200 Subject: [PATCH 2/5] add pytest create a pipeline and skip parts --- tests/data/pipeline_create_template_skip.yml | 7 +++++ tests/test_create.py | 29 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/data/pipeline_create_template_skip.yml 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")) From a32fd94acda55976f14fdd2faaed6866634f2c10 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 20 Jun 2023 14:40:21 +0200 Subject: [PATCH 3/5] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 56ca280d4fd90c13dccaae99c35c2ce24c0888c9 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 20 Jun 2023 14:42:34 +0200 Subject: [PATCH 4/5] run prettier on pipeline_template.yml --- nf_core/create.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nf_core/create.py b/nf_core/create.py index 3e4e7a4212..5836cb172d 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): """ From f5c4f4e2f4198da87a0ff0347da0a50ce3f4c13e Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 20 Jun 2023 14:45:22 +0200 Subject: [PATCH 5/5] ignore bug_report.yml linting if pipeline is unbranded --- nf_core/create.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nf_core/create.py b/nf_core/create.py index 5836cb172d..7416bd8f74 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -470,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