Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customisation option to remove all GitHub support with nf-core create #1766

Merged
merged 22 commits into from
Aug 29, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
708a9b0
add option to remove git hosting from pipeline template
mirpedrol Aug 25, 2022
a6d223e
add file bug_report.yml to files_exist when github hosting is not add…
mirpedrol Aug 25, 2022
8b7e1b1
update CHANGELOG
mirpedrol Aug 25, 2022
2277d2e
Merge branch 'dev' into no-git
mirpedrol Aug 25, 2022
cff1717
Generate new screengrabs with rich-codex
github-actions[bot] Aug 25, 2022
21565bd
disable progress bars in `nf-core (modules) lint` with `--hide-progress`
Aug 25, 2022
103325a
Generate new screengrabs with rich-codex
github-actions[bot] Aug 25, 2022
d55f089
fix argument order
Aug 25, 2022
6d020ae
Merge branch 'disable-lint-progress-bar' of https://github.com/masheh…
Aug 25, 2022
65735ea
update readme
Aug 25, 2022
1619574
Generate new screengrabs with rich-codex
github-actions[bot] Aug 25, 2022
cf31f5e
enable env variables for options, move hide-progress into decorator g…
Aug 29, 2022
39caa9f
Merge branch 'disable-lint-progress-bar' of https://github.com/masheh…
Aug 29, 2022
e30ebb4
include #1765 in this PR
mashehu Aug 29, 2022
f4449ea
Generate new screengrabs with rich-codex
github-actions[bot] Aug 29, 2022
6df2717
Merge pull request #1769 from mashehu/disable-lint-progress-bar
mashehu Aug 29, 2022
8a2317b
add option to remove git hosting from pipeline template
mirpedrol Aug 25, 2022
1980d81
add file bug_report.yml to files_exist when github hosting is not add…
mirpedrol Aug 25, 2022
1e3efde
update CHANGELOG
mirpedrol Aug 25, 2022
0597be6
merge conflicts
mirpedrol Aug 29, 2022
e64d248
merge conflicts
mirpedrol Aug 29, 2022
4ce9a75
Generate new screengrabs with rich-codex
github-actions[bot] Aug 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/rich-codex.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Generate images for docs
on: [push]
on:
push:
branches-ignore:
- "master"
- "dev"
workflow_dispatch:
jobs:
rich_codex:
runs-on: ubuntu-latest
@@ -22,6 +27,10 @@ jobs:

- name: Generate terminal images with rich-codex
uses: ewels/rich-codex@v1
env:
COLUMNS: 100
NFCORE_LINT_HIDE_PROGRESS: true
NFCORE_MODULES_LINT_HIDE_PROGRESS: true
with:
commit_changes: "true"
clean_img_paths: docs/images/*.svg
@@ -31,4 +40,3 @@ jobs:
which nf-core &&
nextflow -version &&
nf-core --version
PY_COLORS=true
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
- Make `nf-core create` fail if Git default branch name is dev or TEMPLATE ([#1705](https://github.com/nf-core/tools/pull/1705))
- Convert `console` snippets to `bash` snippets in the template where applicable ([#1729](https://github.com/nf-core/tools/pull/1729))
- Add `branch` field to module entries in `modules.json` to record what branch a module was installed from ([#1728](https://github.com/nf-core/tools/issues/1728))
- Add customisation option to remove all GitHub support with `nf-core create` ([#1766](https://github.com/nf-core/tools/pull/1766))

### Linting

@@ -49,6 +50,7 @@
- Replace use of the deprecated `distutils` Version object with that from `packaging` ([#1735](https://github.com/nf-core/tools/pull/1735))
- Add code to cancel CI run if a new run starts ([#1760](https://github.com/nf-core/tools/pull/1760))
- CI for the API docs generation now uses the ubuntu-latest base image ([#1762](https://github.com/nf-core/tools/pull/1762))
- Add option to hide progress bars in `nf-core lint` and `nf-core modules lint` with `--hide-progress`.

### Modules

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -287,6 +287,10 @@ working_dir: tmp

Once downloaded, you will see something like the following file structure for the downloaded pipeline:

<!-- RICH-CODEX
working_dir: tmp
-->

![`tree -L 2 nf-core-rnaseq/`](docs/images/nf-core-download-tree.svg)

You can run the pipeline by simply providing the directory path for the `workflow` folder to your `nextflow run` command:
128 changes: 64 additions & 64 deletions docs/images/nf-core-bump-version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
218 changes: 95 additions & 123 deletions docs/images/nf-core-create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 136 additions & 16 deletions docs/images/nf-core-download-tree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 63 additions & 63 deletions docs/images/nf-core-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 59 additions & 59 deletions docs/images/nf-core-launch-rnaseq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
194 changes: 95 additions & 99 deletions docs/images/nf-core-licences.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
368 changes: 141 additions & 227 deletions docs/images/nf-core-lint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 85 additions & 85 deletions docs/images/nf-core-list-rna.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 74 additions & 74 deletions docs/images/nf-core-list-stars.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 77 additions & 77 deletions docs/images/nf-core-list.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 76 additions & 76 deletions docs/images/nf-core-modules-bump-version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
184 changes: 86 additions & 98 deletions docs/images/nf-core-modules-create-test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 90 additions & 106 deletions docs/images/nf-core-modules-create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
312 changes: 150 additions & 162 deletions docs/images/nf-core-modules-info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 58 additions & 58 deletions docs/images/nf-core-modules-install.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
310 changes: 112 additions & 198 deletions docs/images/nf-core-modules-lint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 95 additions & 95 deletions docs/images/nf-core-modules-list-local.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 95 additions & 95 deletions docs/images/nf-core-modules-list-remote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 56 additions & 60 deletions docs/images/nf-core-modules-mulled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
214 changes: 105 additions & 109 deletions docs/images/nf-core-modules-patch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 51 additions & 51 deletions docs/images/nf-core-modules-remove.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 54 additions & 54 deletions docs/images/nf-core-modules-test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 63 additions & 63 deletions docs/images/nf-core-modules-update.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 58 additions & 58 deletions docs/images/nf-core-schema-build.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 54 additions & 54 deletions docs/images/nf-core-schema-lint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 57 additions & 57 deletions docs/images/nf-core-schema-validate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 59 additions & 67 deletions docs/images/nf-core-sync.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 20 additions & 4 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
@@ -90,7 +90,19 @@ def run_nf_core():
stderr.print("\n")

# Lanch the click cli
nf_core_cli()
nf_core_cli(auto_envvar_prefix="NFCORE")


# taken from https://github.com/pallets/click/issues/108#issuecomment-194465429
_common_options = [
click.option("--hide-progress", is_flag=True, default=False, help="Don't show progress bars."),
]


def common_options(func):
for option in reversed(_common_options):
func = option(func)
return func


@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
@@ -304,7 +316,8 @@ def create(name, description, author, version, no_git, force, outdir, template_y
@click.option("-w", "--fail-warned", is_flag=True, help="Convert warn tests to failures")
@click.option("--markdown", type=str, metavar="<filename>", help="File to write linting results to (Markdown)")
@click.option("--json", type=str, metavar="<filename>", help="File to write linting results to (JSON)")
def lint(dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json):
@common_options
def lint(dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json, hide_progress):
"""
Check pipeline code against nf-core guidelines.
@@ -326,7 +339,7 @@ def lint(dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdow
# Run the lint tests!
try:
lint_obj, module_lint_obj = nf_core.lint.run_linting(
dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json
dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json, hide_progress
)
if len(lint_obj.failed) + len(module_lint_obj.failed) > 0:
sys.exit(1)
@@ -666,7 +679,8 @@ def create_test_yml(ctx, tool, run_tests, output, force, no_prompts):
@click.option("--local", is_flag=True, help="Run additional lint tests for local modules")
@click.option("--passed", is_flag=True, help="Show passed tests")
@click.option("--fix-version", is_flag=True, help="Fix the module version if a newer version is available")
def lint(ctx, tool, dir, key, all, fail_warned, local, passed, fix_version):
@common_options
def lint(ctx, tool, dir, key, all, fail_warned, local, passed, fix_version, hide_progress):
"""
Lint one or more modules in a directory.
@@ -683,11 +697,13 @@ def lint(ctx, tool, dir, key, all, fail_warned, local, passed, fix_version):
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
hide_progress,
)
module_lint.lint(
module=tool,
key=key,
all_modules=all,
hide_progress=hide_progress,
print_results=True,
local=local,
show_passed=passed,
25 changes: 21 additions & 4 deletions nf_core/create.py
Original file line number Diff line number Diff line change
@@ -58,6 +58,10 @@ def __init__(
)

skippable_paths = {
"github": [
".github/",
".gitignore",
],
"ci": [".github/workflows/"],
"igenomes": ["conf/igenomes.config"],
"branded": [
@@ -74,7 +78,9 @@ def __init__(
self.name = self.template_params["name"]

# Set fields used by the class methods
self.no_git = no_git
self.no_git = (
no_git if self.template_params["github"] else True
) # Set to True if template was configured without github hosting
self.force = force
if outdir is None:
outdir = os.path.join(os.getcwd(), self.template_params["name_noslash"])
@@ -110,6 +116,7 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa
# Define the different template areas, and what actions to take for each
# if they are skipped
template_areas = {
"github": {"name": "GitHub hosting", "file": True, "content": False},
"ci": {"name": "GitHub CI", "file": True, "content": False},
"github_badges": {"name": "GitHub badges", "file": False, "content": True},
"igenomes": {"name": "iGenomes config", "file": True, "content": True},
@@ -313,9 +320,10 @@ def render_template(self):
# Make a logo and save it, if it is a nf-core pipeline
self.make_pipeline_logo()
else:
# Remove field mentioning nf-core docs
# in the github bug report template
self.remove_nf_core_in_bug_report_template()
if self.template_params["github"]:
# Remove field mentioning nf-core docs
# in the github bug report template
self.remove_nf_core_in_bug_report_template()

# Update the .nf-core.yml with linting configurations
self.fix_linting()
@@ -395,6 +403,15 @@ def fix_linting(self):
"multiqc_config": ["report_comment"],
}

# Add GitHub hosting specific configurations
if not self.template_params["github"]:
lint_config["files_exist"].extend(
[
".github/ISSUE_TEMPLATE/bug_report.yml",
]
)
lint_config["files_unchanged"] = [".github/ISSUE_TEMPLATE/bug_report.yml"]

# Add CI specific configurations
if not self.template_params["ci"]:
lint_config["files_exist"].extend(
11 changes: 8 additions & 3 deletions nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ def run_linting(
fail_warned=False,
md_fn=None,
json_fn=None,
hide_progress=False,
):
"""Runs all nf-core linting checks on a given Nextflow pipeline project
in either `release` mode or `normal` mode (default). Returns an object
@@ -77,15 +78,15 @@ def run_linting(
pipeline_keys = None

# Create the lint object
lint_obj = PipelineLint(pipeline_dir, release_mode, fix, pipeline_keys, fail_ignored, fail_warned)
lint_obj = PipelineLint(pipeline_dir, release_mode, fix, pipeline_keys, fail_ignored, fail_warned, hide_progress)

# Load the various pipeline configs
lint_obj._load_lint_config()
lint_obj._load_pipeline_config()
lint_obj._list_files()

# Create the modules lint object
module_lint_obj = nf_core.modules.lint.ModuleLint(pipeline_dir)
module_lint_obj = nf_core.modules.lint.ModuleLint(pipeline_dir, hide_progress=hide_progress)

# Verify that the pipeline is correctly configured and has a modules.json file
module_lint_obj.has_valid_directory()
@@ -182,7 +183,9 @@ class PipelineLint(nf_core.utils.Pipeline):
from .template_strings import template_strings
from .version_consistency import version_consistency

def __init__(self, wf_path, release_mode=False, fix=(), key=None, fail_ignored=False, fail_warned=False):
def __init__(
self, wf_path, release_mode=False, fix=(), key=None, fail_ignored=False, fail_warned=False, hide_progress=False
):
"""Initialise linting object"""

# Initialise the parent object
@@ -192,6 +195,7 @@ def __init__(self, wf_path, release_mode=False, fix=(), key=None, fail_ignored=F
self.release_mode = release_mode
self.fail_ignored = fail_ignored
self.fail_warned = fail_warned
self.hide_progress = hide_progress
self.failed = []
self.ignored = []
self.fixed = []
@@ -307,6 +311,7 @@ def _lint_pipeline(self):
rich.progress.BarColumn(bar_width=None),
"[magenta]{task.completed} of {task.total}[reset] » [bold yellow]{task.fields[test_name]}",
transient=True,
disable=self.hide_progress,
)
with self.progress_bar:
lint_progress = self.progress_bar.add_task(
16 changes: 14 additions & 2 deletions nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
@@ -64,7 +64,15 @@ class ModuleLint(ModuleCommand):
from .module_todos import module_todos
from .module_version import module_version

def __init__(self, dir, fail_warned=False, remote_url=None, branch=None, no_pull=False):
def __init__(
self,
dir,
fail_warned=False,
remote_url=None,
branch=None,
no_pull=False,
hide_progress=False,
):
self.dir = dir
try:
self.dir, self.repo_type = nf_core.modules.module_utils.get_repo_type(self.dir)
@@ -75,7 +83,8 @@ def __init__(self, dir, fail_warned=False, remote_url=None, branch=None, no_pull
self.passed = []
self.warned = []
self.failed = []
self.modules_repo = ModulesRepo(remote_url, branch, no_pull)
self.hide_progress = hide_progress
self.modules_repo = ModulesRepo(remote_url, branch, no_pull, hide_progress)
self.lint_tests = self.get_all_lint_tests(self.repo_type == "pipeline")

if self.repo_type == "pipeline":
@@ -131,6 +140,7 @@ def lint(
module=None,
key=(),
all_modules=False,
hide_progress=False,
print_results=True,
show_passed=False,
local=False,
@@ -153,6 +163,7 @@ def lint(
:param print_results: Whether to print the linting results
:param show_passed: Whether passed tests should be shown as well
:param fix_version: Update the module version if a newer version is available
:param hide_progress: Don't show progress bars
:returns: A ModuleLint object containing information of
the passed, warned and failed tests
@@ -261,6 +272,7 @@ def lint_modules(self, modules, local=False, fix_version=False):
"[magenta]{task.completed} of {task.total}[reset] » [bold yellow]{task.fields[test_name]}",
transient=True,
console=console,
disable=self.hide_progress,
)
with progress_bar:
lint_progress = progress_bar.add_task(
2 changes: 1 addition & 1 deletion nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ def determine_module_branches_and_shas(self, repo_name, remote_url, modules):
break
# Create a new modules repo with the selected branch, and retry find the sha
modules_repo = nf_core.modules.modules_repo.ModulesRepo(
remote_url=remote_url, branch=branch, no_pull=True, no_progress=True
remote_url=remote_url, branch=branch, no_pull=True, hide_progress=True
)
else:
found_sha = True
54 changes: 25 additions & 29 deletions nf_core/modules/modules_repo.py
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ def get_remote_branches(remote_url):
branches[sha] = branch_name
return set(branches.values())

def __init__(self, remote_url=None, branch=None, no_pull=False, no_progress=False):
def __init__(self, remote_url=None, branch=None, no_pull=False, hide_progress=False):
"""
Initializes the object and clones the git repository if it is not already present
"""
@@ -127,7 +127,7 @@ def __init__(self, remote_url=None, branch=None, no_pull=False, no_progress=Fals

self.fullname = nf_core.modules.module_utils.path_from_remote(self.remote_url)

self.setup_local_repo(remote_url, branch, no_progress)
self.setup_local_repo(remote_url, branch, hide_progress)

# Verify that the repo seems to be correctly configured
if self.fullname != NF_CORE_MODULES_NAME or self.branch:
@@ -138,7 +138,7 @@ def __init__(self, remote_url=None, branch=None, no_pull=False, no_progress=Fals

self.avail_module_names = None

def setup_local_repo(self, remote, branch, no_progress=True):
def setup_local_repo(self, remote, branch, hide_progress=True):
"""
Sets up the local git repository. If the repository has been cloned previously, it
returns a git.Repo object of that clone. Otherwise it tries to clone the repository from
@@ -152,21 +152,19 @@ def setup_local_repo(self, remote, branch, no_progress=True):
self.local_repo_dir = os.path.join(NFCORE_DIR, self.fullname)
if not os.path.exists(self.local_repo_dir):
try:
if no_progress:
self.repo = git.Repo.clone_from(remote, self.local_repo_dir)
else:
pbar = rich.progress.Progress(
"[bold blue]{task.description}",
rich.progress.BarColumn(bar_width=None),
"[bold yellow]{task.fields[state]}",
transient=True,
pbar = rich.progress.Progress(
"[bold blue]{task.description}",
rich.progress.BarColumn(bar_width=None),
"[bold yellow]{task.fields[state]}",
transient=True,
disable=hide_progress,
)
with pbar:
self.repo = git.Repo.clone_from(
remote,
self.local_repo_dir,
progress=RemoteProgressbar(pbar, self.fullname, self.remote_url, "Cloning"),
)
with pbar:
self.repo = git.Repo.clone_from(
remote,
self.local_repo_dir,
progress=RemoteProgressbar(pbar, self.fullname, self.remote_url, "Cloning"),
)
ModulesRepo.update_local_repo_status(self.fullname, True)
except GitCommandError:
raise LookupError(f"Failed to clone from the remote: `{remote}`")
@@ -179,19 +177,17 @@ def setup_local_repo(self, remote, branch, no_progress=True):
ModulesRepo.update_local_repo_status(self.fullname, True)
# If the repo is already cloned, fetch the latest changes from the remote
if not ModulesRepo.local_repo_synced(self.fullname):
if no_progress:
self.repo.remotes.origin.fetch()
else:
pbar = rich.progress.Progress(
"[bold blue]{task.description}",
rich.progress.BarColumn(bar_width=None),
"[bold yellow]{task.fields[state]}",
transient=True,
pbar = rich.progress.Progress(
"[bold blue]{task.description}",
rich.progress.BarColumn(bar_width=None),
"[bold yellow]{task.fields[state]}",
transient=True,
disable=hide_progress,
)
with pbar:
self.repo.remotes.origin.fetch(
progress=RemoteProgressbar(pbar, self.fullname, self.remote_url, "Pulling")
)
with pbar:
self.repo.remotes.origin.fetch(
progress=RemoteProgressbar(pbar, self.fullname, self.remote_url, "Pulling")
)
ModulesRepo.update_local_repo_status(self.fullname, True)

# Before verifying the branch, fetch the changes