Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ybaeus authored Mar 20, 2024
2 parents 176e7f2 + 4716203 commit b26bf28
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 73 deletions.
72 changes: 53 additions & 19 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [created]

jobs:
deploy:
fix-linting:
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
if: >
contains(github.event.comment.html_url, '/pull/') &&
Expand All @@ -13,43 +13,77 @@ jobs:
runs-on: ubuntu-latest
steps:
# Use the @nf-core-bot token to check out so we can push later
- uses: actions/checkout@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ secrets.nf_core_bot_auth_token }}

# indication that the linting is being fixed
- name: React on comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes

# Action runs on the issue comment, so we don't get the PR by default
# Use the gh cli to check out the PR
- name: Checkout Pull Request
run: gh pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}

- uses: actions/setup-node@v2
# 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 pre-commit
id: pre-commit
run: pre-commit run --all-files
continue-on-error: true

- name: Run 'prettier --write'
if: steps.prettier_status.outputs.result == 'fail'
run: prettier --write ${GITHUB_WORKSPACE}
# 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@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ github.event.comment.id }}
reactions: "+1"

- 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 "core@nf-co.re"
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
id: react-if-fixed
if: steps.commit-and-push.outcome == 'success'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ github.event.comment.id }}
reactions: hooray

- name: react if linting errors were not fixed
if: steps.commit-and-push.outcome == 'failure'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ github.event.comment.id }}
reactions: confused

- name: react if linting errors were not fixed
if: steps.commit-and-push.outcome == 'failure'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
issue-number: ${{ github.event.issue.number }}
body: |
@${{ github.actor }} I tried to fix the linting errors, but it didn't work. Please fix them manually.
See [CI log](https://github.com/nf-core/configs/actions/runs/${{ github.run_id }}) for more details.
28 changes: 28 additions & 0 deletions .github/workflows/linting_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 {%- raw %}

on:
workflow_run:
workflows: ["nf-core linting"]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Download lint results
uses: dawidd6/action-download-artifact@f6b0bace624032e30a85a8fd9c1a7f8f611f5737 # v3
with:
workflow: linting.yml
workflow_conclusion: completed

- name: Get PR number
id: pr_number
run: echo "pr_number=$(cat linting-logs/PR_number.txt)" >> $GITHUB_OUTPUT

- name: Post PR comment
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.pr_number.outputs.pr_number }}
path: linting-logs/lint_results.md
11 changes: 8 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Configs tests

on: [pull_request, push]

# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test_all_profiles:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -153,9 +158,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Nextflow
run: |
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
uses: nf-core/setup-nextflow@v2
with:
version: "latest-everything"
- name: Check ${{ matrix.profile }} profile
env:
SCRATCH: "~"
Expand Down
43 changes: 20 additions & 23 deletions conf/incliva.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,28 @@ def getHostname() {
}

// Function to set singularity path according to which host nextflow is running on
def setHostConfig(String hostname) {
if (hostname == 'vlinuxcervantes3srv') {
System.out.println("\nINFO: working on ${hostname}\n")

// Resources details
params.max_memory = 60.GB
params.max_cpus = 15
singularity.cacheDir = "/nfs/home/software/singularity/nf_cacheDir"

} else if (hostname == 'vlinuxcervantes4srv') {
System.out.println("\nINFO: working on ${hostname}.\n")

// Resources details
params.max_memory = 120.GB
params.max_cpus = 19
singularity.cacheDir = "/nfs/home/software/singularity/nf_cacheDir"

} else {
System.err.println("\nERROR: unknown machine. Update incliva.config on nf-core/configs if you are working on another host.\n")
}
}

def hostname = getHostname()
def hostname = { getHostname() }

if (hostname == 'vlinuxcervantes3srv') {
System.out.println("\nINFO: working on ${hostname}\n")

// Resources details
params.max_memory = 60.GB
params.max_cpus = 15
singularity.cacheDir = "/nfs/home/software/singularity/nf_cacheDir"

setHostConfig(hostname)
} else if (hostname == 'vlinuxcervantes4srv') {
System.out.println("\nINFO: working on ${hostname}.\n")

// Resources details
params.max_memory = 120.GB
params.max_cpus = 19
singularity.cacheDir = "/nfs/home/software/singularity/nf_cacheDir"

} else {
System.err.println("\nERROR: unknown machine. Update incliva.config on nf-core/configs if you are working on another host.\n")
}

// Singularity details
singularity {
Expand Down
31 changes: 16 additions & 15 deletions conf/vsc_calcua.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ workDir = "$scratch_dir/work"
// Perform work directory cleanup when the run has succesfully completed.
cleanup = true

// Define function to check if the host machine is the VSC CalcUA.
// Used to skip various steps in this config during github actions.
def host_is_calcua() {
def host = System.getenv("VSC_INSTITUTE")
return ( host == "antwerpen" ) ? true : false
}
def host = System.getenv("VSC_INSTITUTE")

// Check if APPTAINER_TMPDIR/SINGULARITY_TMPDIR environment variables are set.
// If they are available, try to create the tmp directory at the specified location.
// Skip if host is not CalcUA to avoid hindering github actions.
if ( host_is_calcua() ) {
if ( host == "antwerpen" ) {
def apptainer_tmpdir = System.getenv("APPTAINER_TMPDIR") ?: System.getenv("SINGULARITY_TMPDIR") ?: null
if (! apptainer_tmpdir ) {
def tmp_dir = System.getenv("TMPDIR") ?: "/tmp"
Expand All @@ -29,10 +24,10 @@ if ( host_is_calcua() ) {
} else {
apptainer_tmpdir = new File(apptainer_tmpdir)
if (! apptainer_tmpdir.exists() ) {
dir_created = apptainer_tmpdir.mkdirs()
if (! dir_created ) {
try {
dir_created = apptainer_tmpdir.mkdirs()
} catch (java.io.IOException e) {
System.err.println("\nWARNING: Could not create directory at the location specified by APPTAINER_TMPDIR/SINGULARITY_TMPDIR: $apptainer_tmpdir\nPlease check if this is a valid path to which you have write permission. Exiting...\n")
System.exit(1)
}
}
}
Expand All @@ -44,17 +39,23 @@ if ( host_is_calcua() ) {
// warn the user.
def partition_checker(String profile) {
// Skip check if host machine is not CalcUA, in order to not hinder github actions.
if (! host_is_calcua() ) {
if ( host != "antwerpen" ) {
// System.err.println("\nWARNING: Skipping comparison of current partition and requested profile because the current machine is not VSC CalcUA.")
return
}

def current_partition = System.getenv("SLURM_JOB_PARTITION")
if (! current_partition) {

try {
current_partition
} catch (java.io.IOException e) {
System.err.println("\nWARNING: Current partition could not be found in the expected \$SLURM_JOB_PARTITION environment variable. Please make sure that you submit your pipeline via a Slurm job instead of running the nextflow command directly on a login node.\nExiting...\n")
System.exit(1)
} else if ( current_partition != profile) {
}

try {
current_partition = profile
} catch (java.io.IOException e) {
System.err.println("\nWARNING: Slurm job was launched on the \'$current_partition\' partition, but the selected nextflow profile points to the $profile partition instead ('${profile}_local'). When using one of the local node execution profiles, please launch the job on the corresponding partition in Slurm.\nE.g., Slurm job submission command:\n sbatch --account <project_account> --partition=broadwell script.slurm\nand job script containing a nextflow command with matching profile section:\n nextflow run <pipeline> -profile vsc_calcua,broadwell_local\nExiting...\n")
System.exit(1)
}
}

Expand Down
24 changes: 11 additions & 13 deletions conf/wustl_htcf.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Forked from https://github.com/nf-core/configs/blob/master/conf/prince.config

def singularityDir = set_singularity_path()
def labEnvVar = System.getenv("LAB")

if (labEnvVar) {
System.out.println("Lab: " + labEnvVar)
singularityDir = "/ref/$LAB/data/singularity_images_nextflow" // If $LAB is set, use that
} else {
def id = "id -nG".execute().text
def labAutodetect = id.split(" ").last()
System.out.println("Lab: " + labAutodetect)
singularityDir = "/ref/" + labAutodetect + "/data/singularity_images_nextflow"
}

params {
config_profile_description = """
Expand Down Expand Up @@ -29,15 +39,3 @@ process {
beforeScript = "exec \$( spack load --sh singularity )"
executor = "slurm"
}

def set_singularity_path() {
def labEnvVar = System.getenv("LAB")
if (labEnvVar) {
System.out.println("Lab: " + labEnvVar)
return "/ref/$LAB/data/singularity_images_nextflow" // If $LAB is set, use that
}
def id = "id -nG".execute().text
def labAutodetect = id.split(" ").last()
System.out.println("Lab: " + labAutodetect)
return "/ref/" + labAutodetect + "/data/singularity_images_nextflow"
}

0 comments on commit b26bf28

Please # to comment.