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

Fix linting part 1 #4726

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ indent_size = 2

[*.nf.test]
insert_final_newline = false

# ignore Readme
[README.md]
indent_style = unset
67 changes: 41 additions & 26 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: fix-linting
run-name: fix linting (automated)
name: Fix linting from a comment
on:
issue_comment:
types: [created]
Expand All @@ -14,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ secrets.nf_core_bot_auth_token }}

Expand All @@ -32,40 +31,56 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v4
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4
with:
node-version: 20
- run: npm install --only=dev

# Install and run pre-commit
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5
with:
python-version: 3.11

- name: Install Prettier
run: npm install -g prettier @prettier/plugin-php
- name: Install pre-commit
run: pip install pre-commit

# Check that we actually need to fix something
- name: Run 'prettier --check'
id: prettier_status
run: |
if prettier --check ${GITHUB_WORKSPACE}; then
echo "::set-output name=result::pass"
else
echo "::set-output name=result::fail"
fi
- name: Run 'prettier --write'
if: steps.prettier_status.outputs.result == 'fail'
run: prettier --write ${GITHUB_WORKSPACE}
- name: Run pre-commit
id: pre-commit
run: pre-commit run --all-files
continue-on-error: true

- name: Post nothing-to-do comment
if: steps.prettier_status.outputs.result == 'pass'
# indication that the linting has finished
- name: react if linting finished succesfully
if: ${{ steps.pre-commit.outcome }} == 'success'
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
Nothing for me to do here! :shrug:
This is probably because the linting errors come from `nf-core lint` and have to be fixed manually (or with `nf-core lint --fix`).
comment-id: ${{ github.event.comment.id }}
reactions: green_check_mark

- name: Commit & push changes
if: steps.prettier_status.outputs.result == 'fail'
id: commit-and-push
if: ${{ steps.pre-commit.outcome }} == 'failure'
run: |
git config user.email "[email protected]"
git config user.name "nf-core-bot"
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix linting with Prettier"
git commit -m "[automated] Fix code linting"
git push

- name: react if linting errors were fixed
if: ${{ steps.commit-and-push.outcome }} == 'success'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: pencil2

- name: react if linting errors were not fixed
if: ${{ steps.commit-and-push.outcome }} == 'failure'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: x
body: |
@${{ github.actor }} I tried to fix the linting errors, but it didn't work. Please fix them manually.
92 changes: 36 additions & 56 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c #v5
- name: Fetch master
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*

- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0
# FIXME Flip this off once we get to less than a couple hundred. Adding
# this so it will only run against changed files. It'll make it much
# easier to fix these as they come up rather than everything at once.
with:
extra_args: ""

prettier:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

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

- name: Install Prettier
run: npm install -g [email protected]

- name: Run Prettier --check
run: prettier --check .

editorconfig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Install editorconfig-checker
run: npm install -g editorconfig-checker

- name: Run ECLint check
run: editorconfig-checker -exclude README.md $(git ls-files | grep -v test)

extra_args: " --files $(git diff --name-only master...)"
pytest-changes:
name: pytest-changes
runs-on: ubuntu-latest
Expand Down Expand Up @@ -96,9 +67,6 @@ jobs:
id: get_tags
run: find . -name "tags.yml" -not -path "./.github/*" -exec cat {} + > .github/tags.yml

- name: debug
run: cat .github/tags.yml

# TODO: change back to using dorny/paths-filter when https://github.com/dorny/paths-filter/pull/133 is implemented
- uses: mirpedrol/paths-filter@main
id: filter
Expand All @@ -107,7 +75,7 @@ jobs:
token: ""

nf-core-lint:
runs-on: ubuntu-latest
runs-on: self-hosted
name: nf-core-lint
needs: [pytest-changes, nf-test-changes]
if: ${{ (needs.pytest-changes.outputs.modules != '[]') || (needs.nf-test-changes.outputs.modules != '[]') }}
Expand All @@ -126,13 +94,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.11"

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
cache: "pip"

- name: Install pip
run: python -m pip install --upgrade pip
Expand All @@ -142,7 +104,7 @@ jobs:
distribution: "temurin"
java-version: "17"
- name: Setup Nextflow
uses: nf-core/setup-nextflow@v1
uses: MillironX/setup-nextflow@feature/api-switch

- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/nf-core/tools.git@dev
Expand All @@ -160,7 +122,7 @@ jobs:
if: ${{ startsWith(matrix.tags, 'subworkflows/') }}

pytest:
runs-on: ubuntu-latest
runs-on: self-hosted
name: pytest
needs: [pytest-changes]
if: needs.pytest-changes.outputs.modules != '[]'
Expand Down Expand Up @@ -374,6 +336,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"

- name: Install Python dependencies
run: python -m pip install --upgrade pip pytest-workflow cryptography
Expand All @@ -383,7 +346,7 @@ jobs:
distribution: "temurin"
java-version: "17"
- name: Setup Nextflow ${{ matrix.NXF_VER }}
uses: nf-core/setup-nextflow@v1
uses: MillironX/setup-nextflow@feature/api-switch
with:
version: "${{ matrix.NXF_VER }}"

Expand All @@ -401,6 +364,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
channels: conda-forge,bioconda,defaults
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -459,7 +423,7 @@ jobs:
!${{ github.workspace }}/.singularity

nf-test:
runs-on: ubuntu-latest
runs-on: self-hosted
name: nf-test
needs: [nf-test-changes]
if: needs.nf-test-changes.outputs.modules != '[]'
Expand Down Expand Up @@ -578,20 +542,31 @@ jobs:
with:
distribution: "temurin"
java-version: "17"

- name: Setup Nextflow
uses: nf-core/setup-nextflow@v1
uses: MillironX/setup-nextflow@feature/api-switch

- name: Look if nf-test is already installed and write to env variable
id: check-nftest
run: |
if [ -f /usr/local/bin/nf-test ]; then
echo "nftest_installed=true" >> $GITHUB_ENV
else
echo "nftest_installed=false" >> $GITHUB_ENV
fi

- name: Cache nf-test installation
if: env.nftest_installed != 'true'
id: cache-software
uses: actions/cache@v3
with:
path: |
/usr/local/bin/nf-test
/home/runner/.nf-test/nf-test.jar
key: ${{ runner.os }}-${{ env.NFTEST_VER }}-nftest
key: ${{ runner.os }}-nftest-${{ env.date }}

- name: Install nf-test
if: steps.cache-software.outputs.cache-hit != 'true'
if: steps.cache-software.outputs.cache-hit != 'true' && env.nftest_installed != 'true'
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/
Expand All @@ -606,6 +581,11 @@ jobs:
mkdir -p $NXF_SINGULARITY_CACHEDIR
mkdir -p $NXF_SINGULARITY_LIBRARYDIR

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Set up miniconda
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -619,9 +599,9 @@ jobs:
conda clean -a
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
pip install pdiff
echo $(realpath $CONDA)/condabin >> $GITHUB_PATH
echo $(realpath python) >> $GITHUB_PATH
python -m pip install --upgrade pip pdiff

# Set up secrets
- name: Set up nextflow secrets
Expand Down Expand Up @@ -655,7 +635,7 @@ jobs:

confirm-pass:
runs-on: ubuntu-latest
needs: [prettier, editorconfig, pytest-changes, nf-core-lint, pytest, nf-test-changes, nf-test]
needs: [pre-commit, pytest-changes, nf-core-lint, pytest, nf-test-changes, nf-test]
if: always()
steps:
- name: All tests ok
Expand Down
23 changes: 20 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,35 @@ repos:
rev: "v3.1.0"
hooks:
- id: prettier
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: "2.7.3"
hooks:
- id: editorconfig-checker
alias: ec
exclude: ".*(test).*"
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
hooks:
- id: check-jsonschema
name: check meta.yml's of modules
# match meta.ymls in one of the subdirectories of modules/nf-core
files: ^modules/nf-core/.*/meta\.yml$
args: ["--schemafile", "modules/yaml-schema.json"]
args: ["--schemafile", "modules/meta-schema.json"]
- id: check-jsonschema
name: check environment.yml's of modules
# match environment.ymls in one of the subdirectories of modules/nf-core
files: ^modules/nf-core/.*/environment\.yml$
args: ["--schemafile", "modules/environment-schema.json"]
- id: check-jsonschema
name: check meta.yml's of subworkflows
# match meta.ymls in one of the subdirectories of subworkflows/nf-core
files: ^subworkflows/nf-core/.*/meta\.yml$
args: ["--schemafile", "subworkflows/yaml-schema.json"]
- id: check-github-workflows
args: ["--schemafile", "subworkflows/meta-schema.json"]
- id: check-jsonschema
name: check environment.yml's of subworkflows
# match environment.ymls in one of the subdirectories of subworkflows/nf-core
files: ^subworkflows/nf-core/.*/environment\.yml$
args: ["--schemafile", "subworkflows/environment-schema.json"]
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 37.127.0
hooks:
Expand Down
6 changes: 3 additions & 3 deletions modules/nf-core/ampcombi/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ tools:
homepage: "https://github.com/Darcy220606/AMPcombi"
documentation: "https://github.com/Darcy220606/AMPcombi"
tool_dev_url: "https://github.com/Darcy220606/AMPcombi/tree/dev"
licence: "['MIT']"
licence: ["MIT"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- amp_input:
type: folder or filelist
type: directory
description: The path to the directory containing the results for the AMP tools for each sample processed or a list of files corresponding to each file generated by AMP tools.
- faa_input:
type: folder or file
type: directory
description: The path to the folder or file corresponding to the respective protein fasta files with '.faa' extension. Filenames have to contain the corresponding sample-name, i.e. sample_1.faa
pattern: "*/"
- amp_database:
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/angsd/docounts/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tools:
documentation: "http://www.popgen.dk/angsd/"
tool_dev_url: "https://github.com/ANGSD/angsd"
doi: "10.1186/s12859-014-0356-4"
licence: "['GPL v3, MIT']"
licence: ["GPL v3", "MIT"]
input:
- meta:
type: map
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/annotsv/annotsv/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tools:
homepage: "https://lbgi.fr/AnnotSV/"
documentation: "https://lbgi.fr/AnnotSV/"
tool_dev_url: "https://github.com/lgmgeo/AnnotSV"
licence: "GPL-3.0"
licence: ["GPL-3.0"]
input:
- meta:
type: map
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/annotsv/installannotations/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tools:
homepage: "https://lbgi.fr/AnnotSV/"
documentation: "https://lbgi.fr/AnnotSV/"
tool_dev_url: "https://github.com/lgmgeo/AnnotSV"
licence: "['GPL v3']"
licence: ["GPL v3"]
output:
- versions:
type: file
Expand Down
Loading
Loading