Skip to content

Commit a903c20

Browse files
authored
bugfix: Fix mill script on fish (#3700)
Also fix writeNativeImageScript issues with empty quotes and add test
1 parent 26993db commit a903c20

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

.github/scripts/generate-native-image.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
COMMAND="cli[].base-image.writeNativeImageScript"
4+
COMMAND="cli[].base-image.writeDefaultNativeImageScript"
55

66
# temporary, until we pass JPMS options to native-image,
77
# see https://www.graalvm.org/release-notes/22_2/#native-image
@@ -19,7 +19,7 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
1919
MAX_RETRIES=5
2020
RETRY_COUNT=0
2121
while (( RETRY_COUNT < MAX_RETRIES )); do
22-
./mill.bat -i "$COMMAND" generate-native-image.bat ""
22+
./mill.bat -i "$COMMAND" generate-native-image.bat
2323

2424
if [[ $? -ne 0 ]]; then
2525
echo "Error occurred during 'mill.bat -i $COMMAND generate-native-image.bat' command. Retrying... ($((RETRY_COUNT + 1))/$MAX_RETRIES)"
@@ -45,19 +45,19 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
4545
else
4646
if [ $# == "0" ]; then
4747
if [[ "$OSTYPE" == "linux-gnu" ]]; then
48-
COMMAND="cli[].linux-docker-image.writeNativeImageScript"
48+
COMMAND="cli[].linux-docker-image.writeDefaultNativeImageScript"
4949
CLEANUP=("sudo" "rm" "-rf" "out/cli/linux-docker-image/nativeImageDockerWorkingDir")
5050
else
5151
CLEANUP=("true")
5252
fi
5353
else
5454
case "$1" in
5555
"static")
56-
COMMAND="cli[].static-image.writeNativeImageScript"
56+
COMMAND="cli[].static-image.writeDefaultNativeImageScript"
5757
CLEANUP=("sudo" "rm" "-rf" "out/cli/static-image/nativeImageDockerWorkingDir")
5858
;;
5959
"mostly-static")
60-
COMMAND="cli[].mostly-static-image.writeNativeImageScript"
60+
COMMAND="cli[].mostly-static-image.writeDefaultNativeImageScript"
6161
CLEANUP=("sudo" "rm" "-rf" "out/cli/mostly-static-image/nativeImageDockerWorkingDir")
6262
;;
6363
*)
@@ -67,7 +67,7 @@ else
6767
esac
6868
fi
6969

70-
./mill -i "$COMMAND" generate-native-image.sh ""
70+
./mill -i "$COMMAND" --scriptDest generate-native-image.sh
7171
bash ./generate-native-image.sh
7272
"${CLEANUP[@]}"
7373
fi

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ jobs:
5151
name: test-results-unit-tests
5252
path: test-report.xml
5353

54+
test-fish-shell:
55+
timeout-minutes: 120
56+
runs-on: ubuntu-24.04
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
submodules: true
62+
- uses: VirtusLab/scala-cli-setup@v1
63+
with:
64+
jvm: "temurin:17"
65+
- name: Install fish
66+
run: |
67+
sudo apt-add-repository ppa:fish-shell/release-3
68+
sudo apt update
69+
sudo apt install fish
70+
- name: Test mill script in fish shell
71+
run: |
72+
fish -c './mill __.compile'
73+
5474
jvm-tests-1:
5575
timeout-minutes: 120
5676
runs-on: ubuntu-24.04

mill

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Adapted from
44

55
coursier_version="2.1.24"
6+
COMMAND=$@
7+
8+
# necessary for Windows various shell environments
9+
IS_WINDOWS=$(uname | grep -E 'CYG*|MSYS*|MING*|UCRT*|ClANG*|GIT*')
610

711
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux/17072017#17072017
812
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then
@@ -64,8 +68,7 @@ function to_bash_syntax {
6468
echo "$S" | sed -E -e 's#^set #export #' -e 's#%([A-Z_][A-Z_0-9]*)%#${\1}#g' | tr '\\' '/'
6569
done
6670
}
67-
# necessary for Windows various shell environments
68-
if [[ `uname | grep -E 'CYG*|MSYS*|MING*|UCRT*|ClANG*|GIT*'` ]]; then
71+
if [[ $IS_WINDOWS ]]; then
6972
# needed for coursier version < 2.1.8, harmless otherwise
7073
IFS=$'\n'
7174
eval "$(to_bash_syntax `"$cs" java --env --jvm temurin:17` || to_bash_syntax `"$cs" java --env --jvm openjdk:1.17.0`)"
@@ -80,4 +83,8 @@ export USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false
8083

8184
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
8285

83-
exec "$DIR/millw" "$@"
86+
if [[ $IS_WINDOWS ]]; then
87+
exec "$DIR/millw" "$@"
88+
else
89+
exec "$DIR/millw" $COMMAND
90+
fi

project/settings.sc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ trait CliLaunchers extends SbtModule { self =>
160160
def defaultFilesResourcePath = os.rel / "scala" / "cli" / "commands" / "publish"
161161

162162
trait CliNativeImage extends NativeImage {
163+
164+
def writeDefaultNativeImageScript(scriptDest: String) = T.command {
165+
super.writeNativeImageScript(scriptDest, "")()
166+
}
167+
163168
def launcherKind: String
164169
def nativeImageCsCommand = Seq(cs())
165170
def nativeImagePersist = System.getenv("CI") != null
@@ -363,9 +368,9 @@ trait CliLaunchers extends SbtModule { self =>
363368
.call(cwd = os.pwd / "project" / "musl-image", stdout = os.Inherit)
364369
()
365370
}
366-
def writeNativeImageScript(scriptDest: String, imageDest: String = "") = T.command {
371+
override def writeDefaultNativeImageScript(scriptDest: String) = T.command {
367372
buildHelperImage()
368-
super.writeNativeImageScript(scriptDest, imageDest)()
373+
super.writeDefaultNativeImageScript(scriptDest)()
369374
}
370375
}
371376

0 commit comments

Comments
 (0)