Skip to content

Commit 2ccb064

Browse files
authored
Merge pull request #708 from nf-core/dev
Version 1.10.1 patch release
2 parents 3b62ee1 + 765d84e commit 2ccb064

File tree

7 files changed

+93
-61
lines changed

7 files changed

+93
-61
lines changed

.github/workflows/create-lint-wf.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ jobs:
2727
2828
- name: Run nf-core/tools
2929
run: |
30-
nf-core create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface"
31-
nf-core lint nf-core-testpipeline
32-
nf-core list
33-
nf-core licences nf-core-testpipeline
34-
nf-core sync nf-core-testpipeline/
35-
nf-core schema build nf-core-testpipeline/ --no-prompts
36-
nf-core bump-version nf-core-testpipeline/ 1.1
37-
nf-core modules install nf-core-testpipeline/ fastqc
30+
nf-core --log-file log.txt create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface"
31+
nf-core --log-file log.txt lint nf-core-testpipeline
32+
nf-core --log-file log.txt list
33+
nf-core --log-file log.txt licences nf-core-testpipeline
34+
nf-core --log-file log.txt sync nf-core-testpipeline/
35+
nf-core --log-file log.txt schema build nf-core-testpipeline/ --no-prompts
36+
nf-core --log-file log.txt bump-version nf-core-testpipeline/ 1.1
37+
nf-core --log-file log.txt modules install nf-core-testpipeline/ fastqc
38+
39+
- name: Upload log file artifact
40+
uses: actions/upload-artifact@v2
41+
with:
42+
name: nf-core-log-file
43+
path: log.txt

.github/workflows/sync.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ jobs:
2929
wget -qO- get.nextflow.io | bash
3030
sudo ln -s /tmp/nextflow/nextflow /usr/local/bin/nextflow
3131
32-
- name: Configure git
33-
run: |
34-
git config user.email "[email protected]"
35-
git config user.name "nf-core-bot"
36-
3732
- name: Run synchronisation
3833
if: github.repository == 'nf-core/tools'
3934
env:
4035
AUTH_TOKEN: ${{ secrets.nf_core_bot_auth_token }}
41-
run: nf-core sync --all --username nf-core-bot --auth-token $AUTH_TOKEN
36+
run: |
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "nf-core-bot"
39+
nf-core --log-file sync_log.txt sync --all --username nf-core-bot --auth-token $AUTH_TOKEN
40+
41+
- name: Upload sync log file artifact
42+
uses: actions/upload-artifact@v2
43+
with:
44+
name: sync-log-file
45+
path: sync_log.txt

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# nf-core/tools: Changelog
22

3+
## [v1.10.1](https://github.com/nf-core/tools/releases/tag/1.10.1) - [2020-07-30]
4+
5+
Patch release to fix the automatic template synchronisation, which failed in the v1.10 release.
6+
7+
* Improved logging: `nf-core --log-file log.txt` now saves a verbose log to disk.
8+
* GitHub actions sync now uploads verbose log as an artifact.
9+
* Sync - fixed several minor bugs, improved logging.
10+
* Python Rich library updated to `>=4.2.1`
11+
312
## [v1.10 - Copper Camel](https://github.com/nf-core/tools/releases/tag/1.10) - [2020-07-30]
413

514
### Pipeline schema

nf_core/__main__.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import nf_core.sync
2525
import nf_core.utils
2626

27-
log = logging.getLogger(__name__)
27+
# Set up logging as the root logger
28+
# Submodules should all traverse back to this
29+
log = logging.getLogger()
2830

2931

3032
def run_nf_core():
@@ -101,16 +103,30 @@ def decorator(f):
101103

102104
@click.group(cls=CustomHelpOrder)
103105
@click.version_option(nf_core.__version__)
104-
@click.option("-v", "--verbose", is_flag=True, default=False, help="Verbose output (print debug statements).")
105-
def nf_core_cli(verbose):
106-
stderr = rich.console.Console(file=sys.stderr)
107-
logging.basicConfig(
108-
level=logging.DEBUG if verbose else logging.INFO,
109-
format="%(message)s",
110-
datefmt=" ",
111-
handlers=[rich.logging.RichHandler(console=stderr, markup=True)],
106+
@click.option("-v", "--verbose", is_flag=True, default=False, help="Print verbose output to the console.")
107+
@click.option("-l", "--log-file", help="Save a verbose log to a file.", metavar="<filename>")
108+
def nf_core_cli(verbose, log_file):
109+
110+
# Set the base logger to output DEBUG
111+
log.setLevel(logging.DEBUG)
112+
113+
# Set up logs to the console
114+
log.addHandler(
115+
rich.logging.RichHandler(
116+
level=logging.DEBUG if verbose else logging.INFO,
117+
console=rich.console.Console(file=sys.stderr),
118+
show_time=False,
119+
markup=True,
120+
)
112121
)
113122

123+
# Set up logs to a file if we asked for one
124+
if log_file:
125+
log_fh = logging.FileHandler(log_file, encoding="utf-8")
126+
log_fh.setLevel(logging.DEBUG)
127+
log_fh.setFormatter(logging.Formatter("[%(asctime)s] %(name)-20s [%(levelname)-7s] %(message)s"))
128+
log.addHandler(log_fh)
129+
114130

115131
# nf-core list
116132
@nf_core_cli.command(help_priority=1)
@@ -274,9 +290,10 @@ def create(name, description, author, new_version, no_git, force, outdir):
274290
and not os.environ.get("GITHUB_REPOSITORY", "") == "nf-core/tools",
275291
help="Execute additional checks for release-ready workflows.",
276292
)
293+
@click.option("-p", "--show-passed", is_flag=True, help="Show passing tests on the command line.")
277294
@click.option("--markdown", type=str, metavar="<filename>", help="File to write linting results to (Markdown)")
278295
@click.option("--json", type=str, metavar="<filename>", help="File to write linting results to (JSON)")
279-
def lint(pipeline_dir, release, markdown, json):
296+
def lint(pipeline_dir, release, show_passed, markdown, json):
280297
"""
281298
Check pipeline code against nf-core guidelines.
282299
@@ -286,7 +303,7 @@ def lint(pipeline_dir, release, markdown, json):
286303
"""
287304

288305
# Run the lint tests!
289-
lint_obj = nf_core.lint.run_linting(pipeline_dir, release, markdown, json)
306+
lint_obj = nf_core.lint.run_linting(pipeline_dir, release, show_passed, markdown, json)
290307
if len(lint_obj.failed) > 0:
291308
sys.exit(1)
292309

nf_core/lint.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
logging.getLogger("urllib3").setLevel(logging.WARNING)
4040

4141

42-
def run_linting(pipeline_dir, release_mode=False, md_fn=None, json_fn=None):
42+
def run_linting(pipeline_dir, release_mode=False, show_passed=False, md_fn=None, json_fn=None):
4343
"""Runs all nf-core linting checks on a given Nextflow pipeline project
4444
in either `release` mode or `normal` mode (default). Returns an object
4545
of type :class:`PipelineLint` after finished.
@@ -65,7 +65,7 @@ def run_linting(pipeline_dir, release_mode=False, md_fn=None, json_fn=None):
6565
return lint_obj
6666

6767
# Print the results
68-
lint_obj.print_results()
68+
lint_obj.print_results(show_passed)
6969

7070
# Save results to Markdown file
7171
if md_fn is not None:
@@ -238,6 +238,7 @@ def lint_pipeline(self, release_mode=False):
238238
)
239239
for fun_name in check_functions:
240240
progress.update(lint_progress, advance=1, func_name=fun_name)
241+
log.debug("Running lint test: {}".format(fun_name))
241242
getattr(self, fun_name)()
242243
if len(self.failed) > 0:
243244
log.error("Found test failures in `{}`, halting lint run.".format(fun_name))
@@ -1225,8 +1226,7 @@ def check_schema_lint(self):
12251226
""" Lint the pipeline schema """
12261227

12271228
# Only show error messages from schema
1228-
if log.getEffectiveLevel() == logging.INFO:
1229-
logging.getLogger("nf_core.schema").setLevel(logging.ERROR)
1229+
logging.getLogger("nf_core.schema").setLevel(logging.ERROR)
12301230

12311231
# Lint the schema
12321232
self.schema_obj = nf_core.schema.PipelineSchema()
@@ -1273,7 +1273,9 @@ def check_schema_params(self):
12731273
if len(removed_params) == 0 and len(added_params) == 0:
12741274
self.passed.append((15, "Schema matched params returned from nextflow config"))
12751275

1276-
def print_results(self):
1276+
def print_results(self, show_passed=False):
1277+
1278+
log.debug("Printing final results")
12771279
console = Console()
12781280

12791281
# Helper function to format test links nicely
@@ -1294,7 +1296,7 @@ def _s(some_list):
12941296
return ""
12951297

12961298
# Table of passed tests
1297-
if len(self.passed) > 0 and log.getEffectiveLevel() == logging.DEBUG:
1299+
if len(self.passed) > 0 and show_passed:
12981300
table = Table(style="green", box=rich.box.ROUNDED)
12991301
table.add_column(
13001302
"[[\u2714]] {} Test{} Passed".format(len(self.passed), _s(self.passed)), no_wrap=True,

nf_core/sync.py

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def sync(self):
100100
self.make_pull_request()
101101
except PullRequestException as e:
102102
self.reset_target_dir()
103-
raise PullRequestException(pr_exception)
103+
raise PullRequestException(e)
104104

105105
self.reset_target_dir()
106106

@@ -140,7 +140,7 @@ def get_wf_config(self):
140140
# Try to check out target branch (eg. `origin/dev`)
141141
try:
142142
if self.from_branch and self.repo.active_branch.name != self.from_branch:
143-
log.info("Checking out workflow branch '{}'".format(self.from_branch))
143+
log.debug("Checking out workflow branch '{}'".format(self.from_branch))
144144
self.repo.git.checkout(self.from_branch)
145145
except git.exc.GitCommandError:
146146
raise SyncException("Branch `{}` not found!".format(self.from_branch))
@@ -173,7 +173,7 @@ def get_wf_config(self):
173173
)
174174

175175
# Fetch workflow variables
176-
log.info("Fetching workflow config variables")
176+
log.debug("Fetching workflow config variables")
177177
self.wf_config = nf_core.utils.fetch_wf_config(self.pipeline_dir)
178178

179179
# Check that we have the required variables
@@ -201,7 +201,7 @@ def delete_template_branch_files(self):
201201
Delete all files in the TEMPLATE branch
202202
"""
203203
# Delete everything
204-
log.info("Deleting all files in TEMPLATE branch")
204+
log.debug("Deleting all files in TEMPLATE branch")
205205
for the_file in os.listdir(self.pipeline_dir):
206206
if the_file == ".git":
207207
continue
@@ -219,11 +219,10 @@ def make_template_pipeline(self):
219219
"""
220220
Delete all files and make a fresh template using the workflow variables
221221
"""
222-
log.info("Making a new template pipeline using pipeline variables")
222+
log.debug("Making a new template pipeline using pipeline variables")
223223

224224
# Only show error messages from pipeline creation
225-
if log.getEffectiveLevel() == logging.INFO:
226-
logging.getLogger("nf_core.create").setLevel(logging.ERROR)
225+
logging.getLogger("nf_core.create").setLevel(logging.ERROR)
227226

228227
nf_core.create.PipelineCreate(
229228
name=self.wf_config["manifest.name"].strip('"').strip("'"),
@@ -247,7 +246,7 @@ def commit_template_changes(self):
247246
self.repo.git.add(A=True)
248247
self.repo.index.commit("Template update for nf-core/tools version {}".format(nf_core.__version__))
249248
self.made_changes = True
250-
log.info("Committed changes to TEMPLATE branch")
249+
log.debug("Committed changes to TEMPLATE branch")
251250
except Exception as e:
252251
raise SyncException("Could not commit changes to TEMPLATE:\n{}".format(e))
253252
return True
@@ -257,7 +256,7 @@ def push_template_branch(self):
257256
and try to make a PR. If we don't have the auth token, try to figure out a URL
258257
for the PR and print this to the console.
259258
"""
260-
log.info("Pushing TEMPLATE branch to remote")
259+
log.debug("Pushing TEMPLATE branch to remote: '{}'".format(os.path.basename(self.pipeline_dir)))
261260
try:
262261
self.repo.git.push()
263262
except git.exc.GitCommandError as e:
@@ -287,23 +286,18 @@ def make_pull_request(self):
287286
)
288287
raise PullRequestException("No GitHub authentication token set - cannot make PR")
289288

290-
log.info("Submitting a pull request via the GitHub API")
289+
log.debug("Submitting a pull request via the GitHub API")
291290

292-
pr_body_text = """
293-
A new release of the main template in nf-core/tools has just been released.
294-
This automated pull-request attempts to apply the relevant updates to this pipeline.
295-
296-
Please make sure to merge this pull-request as soon as possible.
297-
Once complete, make a new minor release of your pipeline.
298-
299-
For instructions on how to merge this PR, please see
300-
[https://nf-co.re/developers/sync](https://nf-co.re/developers/sync#merging-automated-prs).
301-
302-
For more information about this release of [nf-core/tools](https://github.com/nf-core/tools),
303-
please see the [nf-core/tools v{tag} release page](https://github.com/nf-core/tools/releases/tag/{tag}).
304-
""".format(
305-
tag=nf_core.__version__
306-
)
291+
pr_body_text = (
292+
"A new release of the main template in nf-core/tools has just been released. "
293+
"This automated pull-request attempts to apply the relevant updates to this pipeline.\n\n"
294+
"Please make sure to merge this pull-request as soon as possible. "
295+
"Once complete, make a new minor release of your pipeline. "
296+
"For instructions on how to merge this PR, please see "
297+
"[https://nf-co.re/developers/sync](https://nf-co.re/developers/sync#merging-automated-prs).\n\n"
298+
"For more information about this release of [nf-core/tools](https://github.com/nf-core/tools), "
299+
"please see the [nf-core/tools v{tag} release page](https://github.com/nf-core/tools/releases/tag/{tag})."
300+
).format(tag=nf_core.__version__)
307301

308302
pr_content = {
309303
"title": "Important! Template update for nf-core/tools v{}".format(nf_core.__version__),
@@ -360,6 +354,7 @@ def sync_all_pipelines(gh_username=None, gh_auth_token=None):
360354
# Let's do some updating!
361355
for wf in wfs.remote_workflows:
362356

357+
log.info("-" * 30)
363358
log.info("Syncing {}".format(wf.full_name))
364359

365360
# Make a local working directory
@@ -373,8 +368,7 @@ def sync_all_pipelines(gh_username=None, gh_auth_token=None):
373368
assert repo
374369

375370
# Only show error messages from pipeline creation
376-
if log.getEffectiveLevel() == logging.INFO:
377-
logging.getLogger("nf_core.create").setLevel(logging.ERROR)
371+
logging.getLogger("nf_core.create").setLevel(logging.ERROR)
378372

379373
# Sync the repo
380374
log.debug("Running template sync")
@@ -395,7 +389,7 @@ def sync_all_pipelines(gh_username=None, gh_auth_token=None):
395389
failed_syncs.append(wf.name)
396390
else:
397391
log.info(
398-
"[green]Sync successful for {}:[/] [blue][link={1}]{1}[/link]".format(
392+
"[green]Sync successful for {0}:[/] [blue][link={1}]{1}[/link]".format(
399393
wf.full_name, sync_obj.gh_pr_returned_data.get("html_url")
400394
)
401395
)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44
import sys
55

6-
version = "1.10"
6+
version = "1.10.1"
77

88
with open("README.md") as f:
99
readme = f.read()
@@ -40,7 +40,7 @@
4040
"pyyaml",
4141
"requests",
4242
"requests_cache",
43-
"rich>=4.0.0",
43+
"rich>=4.2.1",
4444
"tabulate",
4545
],
4646
setup_requires=["twine>=1.11.0", "setuptools>=38.6."],

0 commit comments

Comments
 (0)