Skip to content

Commit

Permalink
Try to move templating logic to make YAML files valid.
Browse files Browse the repository at this point in the history
This means that we can run prettier directly on the entire codebase, without ignoring the template.
Will probably need quite a lot of sanity checking to make sure that I didn't break stuff!
  • Loading branch information
ewels committed Mar 17, 2022
1 parent 181c9bb commit 8e6bbd8
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 41 deletions.
4 changes: 0 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
docs/api/_build
testing

# Skip the templates as the Jinja2 tags confuse prettier
# Don't worry - we run prettier on the compiled pipeline in create-lint-wf.yml
nf_core/pipeline-template/
nf_core/module-template/
22 changes: 11 additions & 11 deletions nf_core/module-template/modules/meta.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: {{ tool_name_underscore }}
name: "{{ tool_name_underscore }}"
## TODO nf-core: Add a description of the module and list keywords
description: write your description here
keywords:
- sort
tools:
- {{ tool }}:
- { { tool } }:
## TODO nf-core: Add a description and other details for the software below
description: {{ tool_description }}
homepage: {{ tool_doc_url }}
documentation: {{ tool_doc_url }}
tool_dev_url: {{ tool_dev_url }}
description: { { tool_description } }
homepage: { { tool_doc_url } }
documentation: { { tool_doc_url } }
tool_dev_url: { { tool_dev_url } }
doi: ""
licence: {{ tool_licence }}
licence: { { tool_licence } }

## TODO nf-core: Add a description of all of the variables used as input
input:
{% if has_meta -%}
#{% if has_meta %} Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
{% endif -%}
# {% endif %}
## TODO nf-core: Delete / customise this example input
- bam:
type: file
Expand All @@ -30,13 +30,13 @@ input:

## TODO nf-core: Add a description of all of the variables used as output
output:
{% if has_meta -%}
#{% if has_meta -%} Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
{% endif -%}
# {% endif -%}
- versions:
type: file
description: File containing software versions
Expand Down
12 changes: 6 additions & 6 deletions nf_core/module-template/tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## TODO nf-core: Please run the following command to build this file:
# nf-core modules create-test-yml {{ tool }}{%- if subtool %}/{{ subtool }}{%- endif %}
- name: {{ tool }}{{ ' '+subtool if subtool else '' }}
- name: "{{ tool }}{{ ' '+subtool if subtool else '' }}"
command: nextflow run ./tests/modules/{{ tool_dir }} -entry test_{{ tool_name_underscore }} -c ./tests/config/nextflow.config -c ./tests/modules/{{ tool_dir }}/nextflow.config
tags:
- {{ tool }}
{%- if subtool %}
- {{ tool }}/{{ subtool }}
{%- endif %}
- "{{ tool }}"
# {%- if subtool %}
- "{{ tool }}/{{ subtool }}"
# {%- endif %}
files:
- path: output/{{ tool }}/test.bam
- path: "output/{{ tool }}/test.bam"
md5sum: e667c7caad0bc4b7ac383fd023c654fc
3 changes: 1 addition & 2 deletions nf_core/pipeline-template/.github/workflows/awsfulltest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
uses: nf-core/tower-action@v3
# TODO nf-core: You can customise AWS full pipeline tests as required
# Add full size test data (but still relatively small datasets for few samples)
# on the `test_full.config` test runs with only one set of parameters
{%- raw %}
# on the `test_full.config` test runs with only one set of parameters {% raw %}
with:
workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }}
access_token: ${{ secrets.TOWER_ACCESS_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/.github/workflows/awstest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
if: github.repository == '{{ name }}'
runs-on: ubuntu-latest
steps:
# Launch workflow using Tower CLI tool action {%- raw %}
- name: Launch workflow via tower
uses: nf-core/tower-action@v3
{%- raw %}
with:
workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }}
access_token: ${{ secrets.TOWER_ACCESS_TOKEN }}
Expand Down
11 changes: 6 additions & 5 deletions nf_core/pipeline-template/.github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ on:
pull_request_target:
branches: [master]

env:
REPO_NAME: "{{ name }}"

jobs:
test:
runs-on: ubuntu-latest
steps:
# PRs to the nf-core repo master branch are only ok if coming from the nf-core repo `dev` or any `patch` branches
# PRs to the nf-core repo master branch are only ok if coming from the nf-core repo `dev` or any `patch` branches. {% raw %}
- name: Check PRs
if: github.repository == '{{ name }}'
if: github.repository == env.REPO_NAME
run: |
{ [[ {% raw %}${{github.event.pull_request.head.repo.full_name }}{% endraw %} == {{ name }} ]] && [[ $GITHUB_HEAD_REF = "dev" ]]; } || [[ $GITHUB_HEAD_REF == "patch" ]]
{ [[ ${{github.event.pull_request.head.repo.full_name }} == env.REPO_NAME ]] && [[ $GITHUB_HEAD_REF = "dev" ]]; } || [[ $GITHUB_HEAD_REF == "patch" ]]
{%- raw %}
# If the above check failed, post a comment on the PR explaining the failure
# NOTE - this doesn't currently work if the PR is coming from a fork, due to limitations in GitHub actions secrets
- name: Post PR comment
Expand Down Expand Up @@ -43,4 +45,3 @@ jobs:
Thanks again for your contribution!
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false
{%- endraw %}
7 changes: 3 additions & 4 deletions nf_core/pipeline-template/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ on:
env:
NXF_ANSI_LOG: false
CAPSULE_LOG: none
REPO_NAME: "{{ name }}"

jobs:
test:
name: Run pipeline with test data
# Only run on push if this is the nf-core dev branch (merged PRs)
if: {% raw %}${{{% endraw %} github.event_name != 'push' || (github.event_name == 'push' && github.repository == '{{ name }}') {% raw %}}}{% endraw %}
# Only run on push if this is the nf-core dev branch (merged PRs) {% raw %}
if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == env.REPO_NAME) }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -34,12 +35,10 @@ jobs:

- name: Install Nextflow
env:
{% raw -%}
NXF_VER: ${{ matrix.NXF_VER }}
# Uncomment only if the edge release is more recent than the latest stable release
# See https://github.com/nextflow-io/nextflow/issues/2467
# NXF_EDGE: ${{ matrix.NXF_EDGE }}
{%- endraw %}
run: |
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
Expand Down
7 changes: 3 additions & 4 deletions nf_core/pipeline-template/.github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{% raw %}name: nf-core linting
name: nf-core linting
# This workflow is triggered on pushes and PRs to the repository.
# It runs the `nf-core lint` and markdown lint tests to ensure that the code meets the nf-core guidelines
# It runs the `nf-core lint` and markdown lint tests to ensure
# that the code meets the nf-core guidelines. {% raw %}
on:
push:
pull_request:
release:
types: [published]

jobs:

EditorConfig:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -78,4 +78,3 @@ jobs:
lint_log.txt
lint_results.md
PR_number.txt
{%- endraw %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% raw -%}
name: nf-core linting comment
# This workflow is triggered after the linting action is complete
# It posts an automated comment to the PR, even if the PR is coming from a fork
# It posts an automated comment to the PR, even if the PR is coming from a fork {% raw -%}

on:
workflow_run:
Expand All @@ -27,4 +26,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.pr_number.outputs.pr_number }}
path: linting-logs/lint_results.md
{%- endraw %}
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/assets/multiqc_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ report_comment: >
report_section_order:
software_versions:
order: -1000
{{ name.lower().replace('/', '-') }}-summary:
"{{ name.lower().replace('/', '-') }}-summary":
order: -1001

export_plots: true

0 comments on commit 8e6bbd8

Please sign in to comment.