Skip to content

Commit

Permalink
Upgrade nextflow version to 22.08 (#6)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Aguilera <[email protected]>
  • Loading branch information
jorgeaguileraseqera authored Aug 29, 2022
1 parent c567bfa commit 535346e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 14 deletions.
11 changes: 9 additions & 2 deletions plugins/nf-hello/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,31 @@ sourceSets {
test.resources.srcDirs = ['src/testResources']
}

ext{
nextflowVersion = '22.08.1-edge'
}

dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
compileOnly 'io.nextflow:nextflow:22.04.0'
compileOnly "io.nextflow:nextflow:$nextflowVersion"
compileOnly 'org.slf4j:slf4j-api:1.7.10'
compileOnly 'org.pf4j:pf4j:3.4.1'
// add here plugins depepencies

// test configuration
testImplementation "org.codehaus.groovy:groovy:3.0.8"
testImplementation "org.codehaus.groovy:groovy-nio:3.0.8"
testImplementation 'io.nextflow:nextflow:22.04.0'
testImplementation "io.nextflow:nextflow:$nextflowVersion"
testImplementation ("org.codehaus.groovy:groovy-test:3.0.8") { exclude group: 'org.codehaus.groovy' }
testImplementation ("cglib:cglib-nodep:3.3.0")
testImplementation ("org.objenesis:objenesis:3.1")
testImplementation ("org.spockframework:spock-core:2.0-M3-groovy-3.0") { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('org.spockframework:spock-junit4:2.0-M3-groovy-3.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('com.google.jimfs:jimfs:1.1')

testImplementation(testFixtures("io.nextflow:nextflow:$nextflowVersion"))
testImplementation(testFixtures("io.nextflow:nf-commons:$nextflowVersion"))

// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement
modules {
module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") }
Expand Down
17 changes: 12 additions & 5 deletions plugins/nf-hello/src/main/nextflow/hello/HelloExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package nextflow.hello
import groovy.util.logging.Slf4j
import groovyx.gpars.dataflow.DataflowReadChannel
import groovyx.gpars.dataflow.DataflowWriteChannel
import groovyx.gpars.dataflow.expression.DataflowExpression
import nextflow.Channel
import nextflow.Global
import nextflow.Session
import nextflow.extension.ChannelExtensionPoint
import nextflow.extension.CH
import nextflow.NF
import nextflow.extension.DataflowHelper
import nextflow.plugin.Scoped
import nextflow.plugin.extension.Function
import nextflow.plugin.extension.PluginExtensionPoint

import java.util.concurrent.CompletableFuture

Expand All @@ -20,8 +19,7 @@ import java.util.concurrent.CompletableFuture
*
*/
@Slf4j
@Scoped('hello')
class HelloExtension extends ChannelExtensionPoint{
class HelloExtension extends PluginExtensionPoint{

/*
* A session hold information about current execution of the script
Expand Down Expand Up @@ -107,6 +105,15 @@ class HelloExtension extends ChannelExtensionPoint{
future.exceptionally(this.&handlerException)
}

/*
* Generate a random string
* Using @Function annotation we allow this function can be imported into our script
*/
@Function
String randomString(int length=9){
new Random().with {(1..length).collect {(('a'..'z')).join()[ nextInt((('a'..'z')).join().length())]}.join()}
}

/*
* an util class to trace exceptions
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package nextflow.hello
import groovyx.gpars.dataflow.DataflowQueue
import nextflow.Channel
import nextflow.Session
import nextflow.extension.ChannelExtensionDelegate
import spock.lang.Specification


Expand Down
61 changes: 55 additions & 6 deletions plugins/nf-hello/src/test/nextflow/hello/HelloDslTest.groovy
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
package nextflow.hello

import nextflow.Channel
import nextflow.extension.ChannelExtensionDelegate
import nextflow.plugin.Plugins
import spock.lang.Specification
import nextflow.plugin.TestPluginDescriptorFinder
import nextflow.plugin.TestPluginManager
import nextflow.plugin.extension.PluginExtensionProvider
import org.pf4j.PluginDescriptorFinder
import spock.lang.Shared
import spock.lang.Timeout
import test.Dsl2Spec

import java.nio.file.Path


/**
* @author : jorge <[email protected]>
*
*/
@Timeout(10)
class HelloDslTest extends Specification{
class HelloDslTest extends Dsl2Spec{

@Shared String pluginsMode

def setup() {
// reset previous instances
PluginExtensionProvider.reset()
// this need to be set *before* the plugin manager class is created
pluginsMode = System.getProperty('pf4j.mode')
System.setProperty('pf4j.mode', 'dev')
// the plugin root should
def root = Path.of('.').toAbsolutePath().normalize()
def manager = new TestPluginManager(root){
@Override
protected PluginDescriptorFinder createPluginDescriptorFinder() {
return new TestPluginDescriptorFinder(){
@Override
protected Path getManifestPath(Path pluginPath) {
return pluginPath.resolve('build/resources/main/META-INF/MANIFEST.MF')
}
}
}
}
Plugins.init(root, 'dev', manager)
}

def setup () {
ChannelExtensionDelegate.reloadExtensionPoints()
def cleanup() {
Plugins.stop()
PluginExtensionProvider.reset()
pluginsMode ? System.setProperty('pf4j.mode',pluginsMode) : System.clearProperty('pf4j.mode')
}

def 'should perform a hi and create a channel' () {
when:
def SCRIPT = '''
channel.hello.reverse('hi!')
include {reverse} from 'plugin/nf-hello'
channel.reverse('hi!')
'''
and:
def result = new MockScriptRunner([:]).setScript(SCRIPT).execute()
Expand All @@ -33,6 +66,7 @@ class HelloDslTest extends Specification{
def 'should store a goodbye' () {
when:
def SCRIPT = '''
include {goodbye} from 'plugin/nf-hello'
channel
.of('Bye bye folks')
.goodbye()
Expand All @@ -46,4 +80,19 @@ class HelloDslTest extends Specification{
and:
HelloExtension.goodbyeMessage == 'Bye bye folks'.toUpperCase()
}

def 'can use an imported function' () {
when:
def SCRIPT = '''
include {randomString} from 'plugin/nf-hello'
channel
.of( randomString(20) )
'''
and:
def result = new MockScriptRunner([:]).setScript(SCRIPT).execute()
then:
result.val.size() == 20
result.val == Channel.STOP
}

}

0 comments on commit 535346e

Please sign in to comment.