Skip to content

Commit 67fbfc3

Browse files
committed
fix: Always use semicolon
**Problem** With sbt 2.x, the runner defaults to using sbtn, which interprets sbt foo bar as a single command. **Solution** This injects semicolon as sbt "foo; bar"
1 parent 49f6a4c commit 67fbfc3

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ jobs:
6666

6767
- name: Check that workflows are up to date
6868
shell: bash
69-
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
69+
run: sbt '++ ${{ matrix.scala }}; githubWorkflowCheck'
7070

7171
- if: matrix.java != 'zulu@8'
7272
shell: bash
73-
run: sbt '++ ${{ matrix.scala }}' '+ test' '+ scripted'
73+
run: sbt '++ ${{ matrix.scala }}; + test; + scripted'
7474

7575
- if: matrix.java == 'zulu@8'
7676
shell: bash
77-
run: sbt '++ ${{ matrix.scala }}' test scripted
77+
run: sbt '++ ${{ matrix.scala }}; test; scripted'
7878

7979
- name: Clean up Ivy Local repo
8080
shell: bash

src/main/scala/sbtghactions/GenerativePlugin.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,12 @@ ${indent(rendered.mkString("\n"), 1)}"""
281281
case sbtStep: Sbt =>
282282
import sbtStep.commands
283283

284-
val sbtClientMode = sbt.matches("""sbt.* --client($| .*)""")
285-
val safeCommands = if (sbtClientMode)
286-
s"'${(sbtStepPreamble ::: commands).mkString("; ")}'"
287-
else (sbtStepPreamble ::: commands).map { c =>
288-
if (c.indexOf(' ') >= 0)
289-
s"'$c'"
290-
else
291-
c
292-
}.mkString(" ")
293-
284+
val multi = (sbtStepPreamble ::: commands) match {
285+
case x :: Nil => x
286+
case xs => s"'${xs.mkString("; ")}'"
287+
}
294288
renderRunBody(
295-
commands = List(s"$sbt $safeCommands"),
289+
commands = List(s"$sbt $multi"),
296290
params = sbtStep.params,
297291
renderedShell = renderedShell
298292
)

src/test/scala/sbtghactions/GenerativePluginSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class GenerativePluginSpec extends Specification {
431431
"compile sbt using the command provided" in {
432432
compileStep(
433433
Sbt(List("show scalaVersion", "compile", "test")),
434-
"$SBT") mustEqual s"- run: $$SBT '++ $${{ matrix.scala }}' 'show scalaVersion' compile test"
434+
"$SBT") mustEqual s"- run: $$SBT '++ $${{ matrix.scala }}; show scalaVersion; compile; test'"
435435
}
436436

437437
"compile sbt without switch command" in {
@@ -444,7 +444,7 @@ class GenerativePluginSpec extends Specification {
444444
"compile sbt with parameters" in {
445445
compileStep(
446446
Sbt(List("compile", "test"), params = Map("abc" -> "def", "cafe" -> "@42")),
447-
"$SBT") mustEqual s"""- run: $$SBT '++ $${{ matrix.scala }}' compile test
447+
"$SBT") mustEqual s"""- run: $$SBT '++ $${{ matrix.scala }}; compile; test'
448448
| with:
449449
| abc: def
450450
| cafe: '@42'""".stripMargin
@@ -699,7 +699,7 @@ class GenerativePluginSpec extends Specification {
699699
env:
700700
not: now
701701
steps:
702-
- run: csbt '++ $${{ matrix.scala }}' +compile"""
702+
- run: csbt '++ $${{ matrix.scala }}; +compile'"""
703703
}
704704

705705
"compile a job with an environment" in {

0 commit comments

Comments
 (0)