Skip to content

Commit

Permalink
Merge pull request #2548 from mashehu/fix-swf-linting-error
Browse files Browse the repository at this point in the history
fix subworkflow tag in template
  • Loading branch information
mashehu authored Nov 30, 2023
2 parents 7f869b1 + 88e8bce commit 20dbeec
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/create-lint-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
MakeTestWorkflow:
runs-on: ubuntu-latest
runs-on: self-hosted
env:
NXF_ANSI_LOG: false
strategy:
Expand Down Expand Up @@ -49,6 +49,8 @@ jobs:

# Install the Prettier linting tools
- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/create-test-lint-wf-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:

# Install the Prettier linting tools
- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier @prettier/plugin-php
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ concurrency:

jobs:
EditorConfig:
runs-on: ubuntu-latest
runs-on: ["self-hosted"]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install editorconfig-checker
run: npm install -g editorconfig-checker
Expand All @@ -28,11 +30,13 @@ jobs:
run: editorconfig-checker -exclude README.md $(git ls-files | grep -v 'test\|.py\|md\|json\|yml\|yaml\|html\|css\|Makefile')

Prettier:
runs-on: ubuntu-latest
runs-on: ["self-hosted"]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier
Expand All @@ -41,7 +45,7 @@ jobs:
run: prettier --check ${GITHUB_WORKSPACE}

PythonBlack:
runs-on: ubuntu-latest
runs-on: ["self-hosted"]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -71,7 +75,7 @@ jobs:
allow-repeats: false

isort:
runs-on: ubuntu-latest
runs-on: ["self-hosted"]
steps:
- name: Check out source-code repository
uses: actions/checkout@v4
Expand All @@ -87,7 +91,7 @@ jobs:
requirementsFiles: "requirements.txt requirements-dev.txt"

static-type-check:
runs-on: ubuntu-latest
runs-on: ["self-hosted"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_dockerhub_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
push_dockerhub:
name: Push new Docker image to Docker Hub (dev)
runs-on: ubuntu-latest
runs-on: self-hosted
# Only run for the nf-core repo, for releases and merged PRs
if: ${{ github.repository == 'nf-core/tools' }}
env:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:

jobs:
setup:
runs-on: ${{ matrix.runner }}
runs-on: ["ubuntu-latest"]
strategy:
matrix:
python-version: ["3.8", "3.12"]
Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:
run-tests: ${{ env.run-tests }}

test:
name: Test with Python ${{ needs.setup.outputs.python-version }} on ${{ needs.setup.outputs.runner }}
needs: setup
if: ${{ needs.setup.outputs.run-tests == 'true' }}
runs-on: ${{ needs.setup.outputs.runner }}
Expand All @@ -77,9 +78,9 @@ jobs:
if: ${{ needs.setup.outputs.runner == 'ubuntu-20.04' && needs.setup.outputs.python-version == '3.8' }}
run: |
sudo apt update
sudo apt remove git git-man
sudo apt remove -y git git-man
sudo add-apt-repository --remove ppa:git-core/ppa
sudo apt install git
sudo apt install -y git
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools-api-docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
jobs:
api-docs:
name: Build & push Sphinx API docs
runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- name: Check out source-code repository
Expand Down
1 change: 1 addition & 0 deletions nf_core/pipeline-template/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ profiles {
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
runOptions = '-u $(id -u):$(id -g)'
}
arm {
docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ nextflow_workflow {

tag "subworkflows"
tag "subworkflows_nfcore"
tag "{{ component_name }}"
tag "subworkflows/{{ component_name }}"
// TODO nf-core: Add tags for all modules used within this subworkflow. Example:
tag "samtools"
Expand Down
1 change: 0 additions & 1 deletion nf_core/subworkflows/lint/subworkflow_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent):
"subworkflows",
f"subworkflows/{subworkflow.component_name}",
"subworkflows_nfcore",
subworkflow.component_name,
]
included_components = []
if subworkflow.main_nf.is_file():
Expand Down
11 changes: 7 additions & 4 deletions tests/subworkflows/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def test_subworkflows_lint_new_subworkflow(self):
"""lint a new subworkflow"""
subworkflow_lint = nf_core.subworkflows.SubworkflowLint(dir=self.nfcore_modules)
subworkflow_lint.lint(print_results=True, all_subworkflows=True)
assert (
len(subworkflow_lint.failed) == 1 # test snap missing after creating a subworkflow
), f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}"
assert len(subworkflow_lint.failed) == 0

assert len(subworkflow_lint.passed) > 0
assert len(subworkflow_lint.warned) >= 0

Expand Down Expand Up @@ -68,7 +67,6 @@ def test_subworkflows_lint_multiple_remotes(self):

def test_subworkflows_lint_snapshot_file(self):
"""Test linting a subworkflow with a snapshot file"""
Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").touch()
subworkflow_lint = nf_core.subworkflows.SubworkflowLint(dir=self.nfcore_modules)
subworkflow_lint.lint(print_results=False, subworkflow="test_subworkflow")
assert len(subworkflow_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}"
Expand All @@ -78,8 +76,10 @@ def test_subworkflows_lint_snapshot_file(self):

def test_subworkflows_lint_snapshot_file_missing_fail(self):
"""Test linting a subworkflow with a snapshot file missing, which should fail"""
Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").unlink()
subworkflow_lint = nf_core.subworkflows.SubworkflowLint(dir=self.nfcore_modules)
subworkflow_lint.lint(print_results=False, subworkflow="test_subworkflow")
Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").touch()
assert len(subworkflow_lint.failed) == 1, f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}"
assert len(subworkflow_lint.passed) > 0
assert len(subworkflow_lint.warned) >= 0
Expand All @@ -96,8 +96,11 @@ def test_subworkflows_lint_snapshot_file_not_needed(self):
Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test"), "w"
) as fh:
fh.write(new_content)

Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").unlink()
subworkflow_lint = nf_core.subworkflows.SubworkflowLint(dir=self.nfcore_modules)
subworkflow_lint.lint(print_results=False, subworkflow="test_subworkflow")
Path(self.nfcore_modules, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").touch()
assert len(subworkflow_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}"
assert len(subworkflow_lint.passed) > 0
assert len(subworkflow_lint.warned) >= 0
19 changes: 8 additions & 11 deletions tests/test_subworkflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import shutil
import unittest
from pathlib import Path

import nf_core.create
import nf_core.modules
Expand All @@ -21,22 +22,18 @@
def create_modules_repo_dummy(tmp_dir):
"""Create a dummy copy of the nf-core/modules repo"""

root_dir = os.path.join(tmp_dir, "modules")
os.makedirs(os.path.join(root_dir, "modules"))
os.makedirs(os.path.join(root_dir, "subworkflows"))
os.makedirs(os.path.join(root_dir, "subworkflows", "nf-core"))
os.makedirs(os.path.join(root_dir, "tests", "modules"))
os.makedirs(os.path.join(root_dir, "tests", "subworkflows"))
os.makedirs(os.path.join(root_dir, "tests", "config"))
with open(os.path.join(root_dir, "tests", "config", "pytest_modules.yml"), "w") as fh:
fh.writelines(["test:", "\n - modules/test/**", "\n - tests/modules/test/**"])
with open(os.path.join(root_dir, ".nf-core.yml"), "w") as fh:
root_dir = Path(tmp_dir, "modules")
Path(root_dir, "modules").mkdir(parents=True, exist_ok=True)
Path(root_dir, "subworkflows").mkdir(parents=True, exist_ok=True)
Path(root_dir, "subworkflows", "nf-core").mkdir(parents=True, exist_ok=True)
Path(root_dir, "tests", "config").mkdir(parents=True, exist_ok=True)
with open(Path(root_dir, ".nf-core.yml"), "w") as fh:
fh.writelines(["repository_type: modules", "\n", "org_path: nf-core", "\n"])

# TODO Add a mock here
subworkflow_create = nf_core.subworkflows.SubworkflowCreate(root_dir, "test_subworkflow", "@author", True)
subworkflow_create.create()

Path(root_dir, "subworkflows", "nf-core", "test_subworkflow", "tests", "main.nf.test.snap").touch()
return root_dir


Expand Down

0 comments on commit 20dbeec

Please sign in to comment.