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

Template: handle template features with a yaml file #3108

Merged
merged 12 commits into from
Aug 13, 2024
Merged
76 changes: 24 additions & 52 deletions .github/workflows/create-test-lint-wf-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,41 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
prepare-matrix:
name: Retrieve all template features
runs-on: ubuntu-latest
outputs:
all_features: ${{ steps.create_matrix.outputs.matrix }}
steps:
- name: 🏗 Set up yq
uses: frenck/action-setup-yq@v1
- name: checkout
uses: actions/checkout@v3
- name: Create Matrix
id: create_matrix
run: echo "matrix=$(yq 'keys' ${{ github.workspace }}/nf_core/pipelines/create/templatefeatures.yml | awk '{print $2}' | paste -sd "," - | awk '{print "[" $0 "]"}')" >> $GITHUB_OUTPUT

RunTestWorkflow:
runs-on: ${{ matrix.runner }}
env:
NXF_ANSI_LOG: false
strategy:
matrix:
TEMPLATE:
- "template_skip_github_badges.yml"
- "template_skip_igenomes.yml"
- "template_skip_ci.yml"
- "template_skip_code_linters.yml"
- "template_skip_citations.yml"
- "template_skip_gitpod.yml"
- "template_skip_codespaces.yml"
- "template_skip_multiqc.yml"
- "template_skip_changelog.yml"
TEMPLATE: ${{ needs.prepare-matrix.outputs.all_features }}
runner:
# use the runner given by the input if it is dispatched manually, run on github if it is a rerun or on self-hosted by default
- ${{ github.event.inputs.runners || github.run_number > 1 && 'ubuntu-latest' || 'self-hosted' }}
profile: ["self_hosted_runner"]
include:
- TEMPLATE: "template_skip_all.yml"
- TEMPLATE: all
runner: ubuntu-latest
profile: "docker"
- TEMPLATE: "template_skip_nf_core_configs.yml"
- TEMPLATE: nf_core_configs
runner: ubuntu-latest
profile: "docker"
exclude:
- TEMPLATE: github
- TEMPLATE: is_nfcore
fail-fast: false

steps:
Expand Down Expand Up @@ -90,53 +98,17 @@ jobs:
run: |
mkdir create-test-lint-wf
export NXF_WORK=$(pwd)
printf "org: my-prefix\nskip: ['ci', 'github_badges', 'igenomes', 'nf_core_configs']" > create-test-lint-wf/template_skip_all.yml

- name: Create template skip github_badges
run: |
printf "org: my-prefix\nskip: github_badges" > create-test-lint-wf/template_skip_github_badges.yml

- name: Create template skip igenomes
run: |
printf "org: my-prefix\nskip: igenomes" > create-test-lint-wf/template_skip_igenomes.yml

- name: Create template skip ci
run: |
printf "org: my-prefix\nskip: ci" > create-test-lint-wf/template_skip_ci.yml

- name: Create template skip nf_core_configs
run: |
printf "org: my-prefix\nskip: nf_core_configs" > create-test-lint-wf/template_skip_nf_core_configs.yml

- name: Create template skip code_linters
run: |
printf "org: my-prefix\nskip: code_linters" > create-test-lint-wf/template_skip_code_linters.yml

- name: Create template skip citations
run: |
printf "org: my-prefix\nskip: citations" > create-test-lint-wf/template_skip_citations.yml

- name: Create template skip gitpod
run: |
printf "org: my-prefix\nskip: gitpod" > create-test-lint-wf/template_skip_gitpod.yml

- name: Create template skip multiqc
run: |
printf "org: my-prefix\nskip: multiqc" > create-test-lint-wf/template_skip_multiqc.yml

- name: Create template skip changelog
run: |
printf "org: my-prefix\nskip: changelog" > create-test-lint-wf/template_skip_changelog.yml
printf "org: my-prefix\nskip: ${{ needs.prepare-matrix.outputs.all_features }}" > create-test-lint-wf/template_skip_all.yml

- name: Create template skip codespaces
- name: Create template skip {{ matrix.TEMPLATE }}
run: |
printf "org: my-prefix\nskip: codespaces" > create-test-lint-wf/template_skip_codespaces.yml
printf "org: my-prefix\nskip: {{ matrix.TEMPLATE }}" > create-test-lint-wf/template_skip_{{ matrix.TEMPLATE }}.yml

# Create a pipeline from the template
- name: create a pipeline from the template ${{ matrix.TEMPLATE }}
run: |
cd create-test-lint-wf
nf-core --log-file log.txt pipelines create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface" --template-yaml ${{ matrix.TEMPLATE }}
nf-core --log-file log.txt pipelines create -n testpipeline -d "This pipeline is for testing" -a "Testing McTestface" --template-yaml template_skip_${{ matrix.TEMPLATE }}.yml

- name: run the pipeline
run: |
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ nf_core/module-template/meta.yml
nf_core/pipeline-template/nextflow_schema.json
nf_core/pipeline-template/modules.json
nf_core/pipeline-template/tower.yml
tests/data/pipeline_create_template_skip.yml
# don't run on things handled by ruff
*.py
*.pyc
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- add option to exclude codespaces from pipeline template ([#3105](https://github.com/nf-core/tools/pull/3105))
- add option to exclude multiqc from pipeline template ([#3103](https://github.com/nf-core/tools/pull/3103))
- add option to exclude changelog from custom pipeline template ([#3104](https://github.com/nf-core/tools/pull/3104))
- handle template features with a yaml file ([#3108](https://github.com/nf-core/tools/pull/3108))

### Linting

Expand Down
6 changes: 6 additions & 0 deletions nf_core/pipelines/create/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""A Textual app to create a pipeline."""

import logging
from pathlib import Path

import click
import yaml
from textual.app import App
from textual.widgets import Button

import nf_core
from nf_core.pipelines.create import utils
from nf_core.pipelines.create.basicdetails import BasicDetails
from nf_core.pipelines.create.custompipeline import CustomPipeline
Expand Down Expand Up @@ -68,6 +71,9 @@ class PipelineCreateApp(App[utils.CreateConfig]):
# Logging state
LOGGING_STATE = None

# Template features
template_features_yml = utils.load_features_yaml()

def on_mount(self) -> None:
self.push_screen("welcome")

Expand Down
Loading
Loading