Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Java 17 domain socket support exclusively #529

Merged
merged 22 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .github/scripts/check_docs.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#!/usr/bin/env bash

set -e

dest=$(pwd)/.scala/bin
dest="$(pwd)/out/sclicheck/bin"

./mill copyTo cli.launcher "$dest/scala-cli.sh"

./mill -i copyTo cli.launcher $dest/scala-cli
# work around sh issues (sh ignores PATH entries with '+' or '%', and the cs-provided Java 17 entry has one)
# so we try to run the scala-cli launcher with bash instead
cat > "$dest/scala-cli" << EOF
#!/usr/bin/env bash
exec bash "$dest/scala-cli.sh"
EOF
chmod +x "$dest/scala-cli"

export PATH=$dest:$PATH
echo Adding $dest to classpath
ls $dest
echo "Adding $dest to PATH"
export PATH="$dest:$PATH"
ls "$dest"

if [ $# -eq 0 ]
then
toCheck="website/docs/cookbooks website/docs/commands"
toCheck=("website/docs/cookbooks" "website/docs/commands")
else
toCheck=$@
toCheck=("$@")
fi

# adding --resource-dirs is a hack to get file watching for free on .md files
scala-cli sclicheck/sclicheck.scala --resource-dirs docs -- $toCheck
scala-cli sclicheck/sclicheck.scala --resource-dirs docs -- "${toCheck[@]}"
53 changes: 53 additions & 0 deletions .github/scripts/generate-native-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -e

COMMAND="cli.base-image.writeNativeImageScript"

# Using 'mill -i' so that the Mill process doesn't outlive this invocation

if [[ "$OSTYPE" == "msys" ]]; then
./mill.bat -i "$COMMAND" generate-native-image.bat
# Ideally, the generated script should create that directory itself
mkdir -p out/cli/base-image/nativeImage/dest
./generate-native-image.bat
# Ideally, the generated script should write the generated launcher there
cp out/cli/base-image/nativeImageScript/dest/scala-cli.exe out/cli/base-image/nativeImage/dest/scala-cli.exe
else
if [ $# == "0" ]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
COMMAND="cli.linux-docker-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/linux-docker-image/nativeImageDockerWorkingDir")
# Ideally, the generated script should create that directory itself
mkdir -p out/cli/linux-docker-image/nativeImage/dest/
else
CLEANUP=("true")
# Ideally, the generated script should create that directory itself
mkdir -p out/cli/base-image/nativeImage/dest
fi
else
case "$1" in
"static")
COMMAND="cli.static-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/static-image/nativeImageDockerWorkingDir")
# Ideally, the generated script should create that directory itself
mkdir -p out/cli/static-image/nativeImage/dest
;;
"mostly-static")
COMMAND="cli.mostly-static-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/mostly-static-image/nativeImageDockerWorkingDir")
# Ideally, the generated script should create that directory itself
mkdir -p out/cli/mostly-static-image/nativeImage/dest
;;
*)
echo "Invalid image name: $1" 1>&2
exit 1
;;
esac
fi

./mill -i "$COMMAND" generate-native-image-0.sh
# Small mill-native-image issue
sed 's/nativeImageScript/nativeImage/g' < generate-native-image-0.sh > generate-native-image.sh
bash ./generate-native-image.sh
"${CLEANUP[@]}"
fi
57 changes: 30 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Copy launcher
run: ./mill -i copyJvmLauncher artifacts/
if: runner.os == 'Linux'
Expand Down Expand Up @@ -59,11 +59,12 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Generate native launcher
run: ./mill -i show defaultNativeImage
run: .github/scripts/generate-native-image.sh
shell: bash
- name: Build OS packages
run: .github/scripts/generate-os-packages.sh
shell: bash
Expand All @@ -89,11 +90,12 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Generate native launcher
run: ./mill -i show cli.nativeImageMostlyStatic
run: .github/scripts/generate-native-image.sh mostly-static
shell: bash
- name: Copy artifacts
run: ./mill -i copyMostlyStaticLauncher artifacts/
- name: Build slim docker image
Expand Down Expand Up @@ -127,11 +129,12 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Generate native launcher
run: ./mill -i show cli.nativeImageStatic
run: .github/scripts/generate-native-image.sh static
shell: bash
- name: Copy artifacts
run: ./mill -i copyStaticLauncher artifacts/
- name: Build docker image
Expand Down Expand Up @@ -165,9 +168,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Test documentation
run: .github/scripts/check_docs.sh
- name: Test gifs
Expand All @@ -182,9 +185,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Check native-image config format
run: ./mill -i __.checkNativeImageConfFormat
- name: Check Ammonite availability
Expand All @@ -206,9 +209,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
apps: scalafmt:3.0.0
- run: scalafmt --check

Expand All @@ -221,9 +224,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: Check that reference doc is up-to-date
run: |
./mill -i generate-reference-doc.run --check || (
Expand All @@ -243,9 +246,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- run: ./mill -i ci.copyVcRedist
- uses: actions/upload-artifact@v2.3.1
with:
Expand All @@ -264,9 +267,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- name: GPG setup
run: .github/scripts/gpg-setup.sh
env:
Expand Down Expand Up @@ -298,9 +301,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- run: ./mill -i ci.setShouldPublish
- uses: actions/download-artifact@v2
if: env.SHOULD_PUBLISH == 'true'
Expand All @@ -323,9 +326,9 @@ jobs:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.3
- uses: coursier/setup-action@v1.1.2
- uses: coursier/setup-action@v1.2.0-M1
with:
jvm: 11
jvm: "temurin:17"
- uses: actions/download-artifact@v2
with:
name: launchers
Expand Down
2 changes: 1 addition & 1 deletion .mill-jvm-opts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-Xmx512m
-Xmx768m
-Xms128m
-Xss8m
-Dxsbt.skip.cp.lookup=true
28 changes: 18 additions & 10 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $ivy.`io.get-coursier::coursier-launcher:2.0.16+73-gddc6d9cc9`
import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.12`
import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.13`
import $file.project.deps, deps.{Deps, Docker, Scala, TestDeps}
import $file.project.publish, publish.{ghOrg, ghName, ScalaCliPublishModule}
import $file.project.settings, settings.{
Expand All @@ -10,6 +10,7 @@ import $file.project.settings, settings.{
HasTests,
LocalRepo,
PublishLocalNoFluff,
ScalaCliCrossSbtModule,
ScalaCliScalafixModule,
localRepoResourcePath,
platformExecutableJarExtension
Expand Down Expand Up @@ -150,7 +151,8 @@ object dummy extends Module {
}
}

class BuildMacros(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
class BuildMacros(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with ScalaCliScalafixModule {
def scalacOptions = T {
super.scalacOptions() ++ Seq("-Ywarn-unused")
Expand All @@ -163,7 +165,8 @@ class BuildMacros(val crossScalaVersion: String) extends CrossSbtModule with Sca
}

class Build(val crossScalaVersion: String)
extends CrossSbtModule with ScalaCliPublishModule with HasTests with ScalaCliScalafixModule {
extends ScalaCliCrossSbtModule with ScalaCliPublishModule with HasTests
with ScalaCliScalafixModule {
def moduleDeps = Seq(
`bloop-rifle`(),
`build-macros`(),
Expand Down Expand Up @@ -314,6 +317,9 @@ trait Cli extends SbtModule with CliLaunchers with ScalaCliPublishModule with Fo
def scalacOptions = T {
super.scalacOptions() ++ Seq("-Xasync", "-Ywarn-unused", "-deprecation")
}
def javacOptions = T {
super.javacOptions() ++ Seq("--release", "16")
}
def moduleDeps = Seq(
build(Scala.defaultInternal),
`test-runner`(Scala.defaultInternal)
Expand Down Expand Up @@ -474,7 +480,8 @@ trait JvmIntegration extends CliIntegration {
def cliKind = "jvm"
}

class Runner(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
class Runner(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with ScalaCliScalafixModule {
def scalacOptions = T {
super.scalacOptions() ++ {
Expand Down Expand Up @@ -514,7 +521,8 @@ class Runner(val crossScalaVersion: String) extends CrossSbtModule with ScalaCli
}
}

class TestRunner(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
class TestRunner(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with ScalaCliScalafixModule {
def scalacOptions = T {
super.scalacOptions() ++ {
Expand All @@ -530,7 +538,8 @@ class TestRunner(val crossScalaVersion: String) extends CrossSbtModule with Scal
def mainClass = Some("scala.build.testrunner.DynamicTestRunner")
}

class BloopRifle(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
class BloopRifle(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with HasTests
with ScalaCliScalafixModule {
def scalacOptions = T {
Expand All @@ -539,9 +548,7 @@ class BloopRifle(val crossScalaVersion: String) extends CrossSbtModule with Scal
def ivyDeps = super.ivyDeps() ++ Agg(
Deps.bsp4j,
Deps.collectionCompat,
Deps.ipcSocket,
Deps.libdaemonjvm
.exclude(("org.scala-sbt.ipcsocket", "ipcsocket")),
Deps.libdaemonjvm,
Deps.snailgun
)
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
Expand Down Expand Up @@ -570,7 +577,8 @@ class BloopRifle(val crossScalaVersion: String) extends CrossSbtModule with Scal
object test extends Tests with ScalaCliScalafixModule
}

class TastyLib(val crossScalaVersion: String) extends CrossSbtModule with ScalaCliPublishModule
class TastyLib(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with ScalaCliScalafixModule {
def scalacOptions = T(
super.scalacOptions() ++ {
Expand Down
4 changes: 2 additions & 2 deletions examples/scala-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ scala-cli package --docker HelloDocker.scala --docker-image-repository hello-doc
```

<!-- Expected:
Started building docker image with your application, it would take some time
Started building docker image with your application, it might take some time
Built docker image, run it with
docker run hello-docker:latest
-->
Expand All @@ -44,7 +44,7 @@ It is also supported to package your app in `JS` or `Native` environments.
scala-cli package --js --docker HelloDocker.scala --docker-image-repository hello-docker
```
<!-- Expected:
Started building docker image with your application, it would take some time
Started building docker image with your application, it might take some time
Built docker image, run it with
docker run hello-docker:latest
-->
Expand Down
Loading