Skip to content

Commit 9f59fe4

Browse files
authored
Merge pull request #817 from viash-io/fix-backport-nxf
Port PR 812 to Viash 0.8.x
2 parents f56852d + 3cb0c44 commit 9f59fe4

9 files changed

Lines changed: 116 additions & 24 deletions

File tree

.github/workflows/ns_test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111

12-
- name: Set up sbt
12+
- name: Set up java
1313
uses: actions/setup-java@v4
1414
with:
1515
distribution: temurin
1616
java-version: '11'
1717

18+
- name: Set up sbt
19+
uses: sbt/setup-sbt@v1
20+
1821
- name: Build viash
1922
run: |
2023
echo "${HOME}/.local/bin" >> $GITHUB_PATH

.github/workflows/prep_release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Prepare Viash Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-release:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
23+
- name: Set up sbt
24+
uses: sbt/setup-sbt@v1
25+
26+
- name: Set up Scala
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y scala
30+
31+
- name: Build Viash
32+
run: |
33+
./configure
34+
make
35+
make tools
36+
bin/viash export json_schema --format=json --output=bin/schema.json
37+
38+
- name: Get Version
39+
id: get_version
40+
run: |
41+
viash_version=$(bin/viash --version | cut -d ' ' -f 2)
42+
echo "Detected Viash version: $viash_version"
43+
echo "viash_version=$viash_version" >> "$GITHUB_OUTPUT"
44+
45+
# fetch relevant changelog section
46+
changelog_section=$(awk "/# Viash ${viash_version}.*/{flag=1;next}/^# /{flag=0}flag" CHANGELOG.md)
47+
48+
echo "changelog_section<<GITHUB_EOF" >> "$GITHUB_OUTPUT"
49+
echo "$changelog_section" >> "$GITHUB_OUTPUT"
50+
echo "GITHUB_EOF" >> "$GITHUB_OUTPUT"
51+
52+
- name: Create release
53+
uses: softprops/action-gh-release@v2
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
with:
57+
tag_name: ${{ steps.get_version.outputs.viash_version }}
58+
target_commitish: ${{ github.sha }}
59+
name: Viash ${{ steps.get_version.outputs.viash_version }}
60+
body: ${{ steps.get_version.outputs.changelog_section }}
61+
draft: true
62+
fail_on_unmatched_files: true
63+
files: |
64+
bin/viash
65+
bin/schema.json
66+
bin/viash_install

.github/workflows/sbt_test.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ jobs:
1616
java:
1717
- { ver: '11', run_nextflow: true, run_coverage: false, nxf_ver: "22.04.5" }
1818
- { ver: '17', run_nextflow: true, run_coverage: true, nxf_ver: latest }
19-
- { ver: '20', run_nextflow: true, run_coverage: false, nxf_ver: latest-edge }
19+
- { ver: '21', run_nextflow: true, run_coverage: false, nxf_ver: latest-edge }
2020

2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- uses: viash-io/viash-actions/update-docker-engine@v5
24+
- uses: viash-io/viash-actions/project/update-docker-engine@v6
2525
if: runner.os == 'Linux'
2626

27-
- name: Set up Nextflow
28-
if: ${{ runner.os == 'Linux' && matrix.java.run_nextflow }}
29-
uses: nf-core/setup-nextflow@v1
30-
with:
31-
version: ${{ matrix.java.nxf_ver }}
32-
3327
- name: Set up R
3428
uses: r-lib/actions/setup-r@v2
3529
with:
@@ -42,18 +36,14 @@ jobs:
4236
processx
4337
testthat
4438
45-
- name: Set up java & sbt
39+
- name: Set up java
4640
uses: actions/setup-java@v4
4741
with:
4842
distribution: temurin
4943
java-version: ${{ matrix.java.ver }}
5044

51-
- name: Set up sbt specifically on macOS on arm64 if needed
52-
if: ${{ runner.os == 'macOS' && runner.arch == 'ARM64'}}
53-
run: |
54-
if ! command -v sbt &> /dev/null; then
55-
brew install sbt
56-
fi
45+
- name: Set up sbt
46+
uses: sbt/setup-sbt@v1
5747

5848
- name: Set up Scala
5949
run: |
@@ -69,6 +59,12 @@ jobs:
6959
with:
7060
python-version: '3.x'
7161

62+
- name: Set up Nextflow
63+
if: ${{ runner.os == 'Linux' && matrix.java.run_nextflow }}
64+
uses: nf-core/setup-nextflow@v2
65+
with:
66+
version: ${{ matrix.java.nxf_ver }}
67+
7268
- name: Run tests
7369
run: |
7470
if [[ "${{ matrix.config.name }}" =~ ^ubuntu.*$ ]] && [[ "${{ matrix.java.run_coverage }}" == "true" ]]; then

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# Viash 0.x.x (yyyy-MM-dd): TODO Add title
1+
# Viash 0.8.7 (2025-04-01): Backport support upcoming version of Nextflow
22

3-
TODO add summary
3+
The upcoming release of Nextflow introduces a new class for loading scripts and renamed the old class.
4+
This release supports this change by using reflection to detect the available class.
45

56
## BUG FIXES
67

78
* `viash build`: Fix error handling of non-generic errors in the build process or while pushing docker containers (PR #696).
89

10+
* `NextflowRunner`: ScriptParser was renamed to ScriptLoaderV1 in Nextflow 25.02.0-edge (PR #817). Backport from Viash 0.9.3 (PR #812).
11+
This fix uses reflection to detect whether ScriptParser exists -- if not the ScriptLoaderFactory is used instead.
12+
13+
* `NextflowRunner`: Backport path handling for `meta.resources_dir` for when symlinks are used (PR #817).
14+
915
# Viash 0.8.6 (2024-04-26): Bug fixes and improvements for CI
1016

1117
Fix some issues in some edge cases.

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name := "viash"
22

33
version := "0.8.7-dev"
44

5-
scalaVersion := "2.13.10"
5+
scalaVersion := "2.13.12"
66

77
libraryDependencies ++= Seq(
88
"org.scalactic" %% "scalactic" % "3.2.15" % "test",
@@ -74,4 +74,4 @@ generateWorkflowHelper := {
7474
}
7575

7676
assembly := ((assembly) dependsOn generateWorkflowHelper).value
77-
Test / testOptions := ((Test / testOptions) dependsOn generateWorkflowHelper).value
77+
Test / testOptions := ((Test / testOptions) dependsOn generateWorkflowHelper).value

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.6.1
1+
sbt.version=1.9.7

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
2-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.5")
2+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
33
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0")

src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _vdsl3ProcessFactory(Map workflowArgs, Map meta, String rawScript) {
315315
// create process from temp file
316316
def binding = new nextflow.script.ScriptBinding([:])
317317
def session = nextflow.Nextflow.getSession()
318-
def parser = new nextflow.script.ScriptParser(session)
318+
def parser = _getScriptLoader(session)
319319
.setModule(true)
320320
.setBinding(binding)
321321
def moduleScript = parser.runScript(tempFile)
@@ -328,3 +328,24 @@ def _vdsl3ProcessFactory(Map workflowArgs, Map meta, String rawScript) {
328328
// retrieve and return process from meta
329329
return scriptMeta.getProcess(procKey)
330330
}
331+
332+
// use Reflection to get a ScriptParser / ScriptLoader
333+
// <25.02.0-edge: new nextflow.script.ScriptParser(session)
334+
// >=25.02.0-edge: nextflow.script.ScriptLoaderFactory.create(session)
335+
def _getScriptLoader(nextflow.Session session) {
336+
// try using the old method
337+
try {
338+
Class<?> scriptParserClass = Class.forName('nextflow.script.ScriptParser')
339+
return scriptParserClass.getDeclaredConstructor(nextflow.Session).newInstance(session)
340+
} catch (ClassNotFoundException e) {
341+
// else try with the new method
342+
try {
343+
Class<?> scriptLoaderFactoryClass = Class.forName('nextflow.script.ScriptLoaderFactory')
344+
def createMethod = scriptLoaderFactoryClass.getDeclaredMethod('create', nextflow.Session)
345+
return createMethod.invoke(null, session) // null because create is static
346+
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | java.lang.reflect.InvocationTargetException e2) {
347+
// Handle the case where neither class is found
348+
throw new Exception("Neither nextflow.script.ScriptParser nor nextflow.script.ScriptLoaderFactory could be found. Is this a compatible Nextflow version?", e2)
349+
}
350+
}
351+
}

src/main/scala/io/viash/platforms/NextflowPlatform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ case class NextflowPlatform(
256256
|
257257
|// create meta object
258258
|meta = [
259-
| "resources_dir": moduleDir,
259+
| "resources_dir": moduleDir.toRealPath().normalize(),
260260
| "config": ${NextflowHelper.generateConfigStr(config)}
261261
|]
262262
|

0 commit comments

Comments
 (0)