Skip to content

Commit

Permalink
Merge pull request #2752 from Gedochao/maintenance/lts-cross-next
Browse files Browse the repository at this point in the history
Use Scala LTS as the default version while cross compiling all Scala 3 modules on both LTS & Next
  • Loading branch information
Gedochao authored Feb 26, 2024
2 parents 37bba70 + 548a51b commit f3369c2
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/build-linux-aarch64-from-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ eval "$(cs java --env --jvm temurin:17 --jvm-index https://github.com/coursier/j

git config --global --add safe.directory "$(pwd)"

./mill -i show cli.nativeImage
./mill -i show 'cli[]'.nativeImage
./mill -i copyDefaultLauncher ./artifacts
if "true" == $(./mill -i ci.shouldPublish); then
.github/scripts/generate-os-packages.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/generate-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
WORKDIR="$ROOT/out/docker-workdir"

mkdir -p "$WORKDIR"
./mill -i copyTo cli.nativeImageStatic "$WORKDIR/scala-cli" 1>&2
./mill -i copyTo 'cli[]'.nativeImageStatic "$WORKDIR/scala-cli" 1>&2

cd "$WORKDIR"
docker build -t scala-cli -f "$ROOT/.github/scripts/docker/ScalaCliDockerFile" .
8 changes: 4 additions & 4 deletions .github/scripts/generate-native-image.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

COMMAND="cli.base-image.writeNativeImageScript"
COMMAND="cli[].base-image.writeNativeImageScript"

# temporary, until we pass JPMS options to native-image,
# see https://www.graalvm.org/release-notes/22_2/#native-image
Expand All @@ -20,19 +20,19 @@ if [[ "$OSTYPE" == "msys" ]]; then
else
if [ $# == "0" ]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
COMMAND="cli.linux-docker-image.writeNativeImageScript"
COMMAND="cli[].linux-docker-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/linux-docker-image/nativeImageDockerWorkingDir")
else
CLEANUP=("true")
fi
else
case "$1" in
"static")
COMMAND="cli.static-image.writeNativeImageScript"
COMMAND="cli[].static-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/static-image/nativeImageDockerWorkingDir")
;;
"mostly-static")
COMMAND="cli.mostly-static-image.writeNativeImageScript"
COMMAND="cli[].mostly-static-image.writeNativeImageScript"
CLEANUP=("sudo" "rm" "-rf" "out/cli/mostly-static-image/nativeImageDockerWorkingDir")
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/generate-os-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packager() {
}

launcher() {
local launcherMillCommand="cli.nativeImage"
local launcherMillCommand="cli[].nativeImage"
local launcherName

if [[ "${OS-}" == "Windows_NT" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/generate-slim-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
WORKDIR="$ROOT/out/docker-slim-workdir"

mkdir -p "$WORKDIR"
./mill -i copyTo cli.nativeImageMostlyStatic "$WORKDIR/scala-cli" 1>&2
./mill -i copyTo 'cli[]'.nativeImageMostlyStatic "$WORKDIR/scala-cli" 1>&2

cd "$WORKDIR"
docker build -t scala-cli-slim -f "$ROOT/.github/scripts/docker/ScalaCliSlimDockerFile" .
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ jobs:
- name: Build documentation
run: .github/scripts/build-website.sh
- name: Test documentation
run: ./mill -i docs-tests.test
run: ./mill -i 'docs-tests[]'.test
- name: Convert Mill test reports to JUnit XML format
if: success() || failure()
run: .github/scripts/generate-junit-reports.sc docs-tests 'Scala CLI Docs Tests' test-report.xml out/
Expand Down Expand Up @@ -975,9 +975,9 @@ jobs:
jvm: "temurin:17"
- name: Check that reference doc is up-to-date
run: |
./mill -i generate-reference-doc.run --check || (
./mill -i 'generate-reference-doc[]'.run --check || (
echo "Reference doc is not up-to-date. Run"
echo " ./mill -i generate-reference-doc.run"
echo " ./mill -i 'generate-reference-doc[]'.run"
echo "to update it, then commit the result."
exit 1
)
Expand Down
2 changes: 1 addition & 1 deletion .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ updates.ignore = [
{ groupId = "com.github.plokhotnyuk.jsoniter-scala", artifactId="jsoniter-scala-core", version="2.13.5.2" }
]
postUpdateHooks = [{
command = ["./mill", "-i", "generate-reference-doc.run"],
command = ["./mill", "-i", "'generate-reference-doc[]'.run"],
commitMessage = "Generate the reference doc"
}]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ will save you from getting a load of comments and speed up the code review.
- ensure everything compiles at every commit (`./mill -i __.compile`);
- ensure everything is well formatted at every commit (`scala-cli fmt .` or `scalafmt`);
- ensure imports are well-ordered at every commit (`./mill -i __.fix`);
- ensure reference docs are up-to date at every commit (`./mill -i generate-reference-doc.run`);
- ensure reference docs are up-to date at every commit (`./mill -i 'generate-reference-doc[]'.run`);
- ensure all tests pass at every commit (refer to the [dev docs](DEV.md) on how to run tests);
- nobody expects you to run all the unit and integration tests for all platforms locally, that'd take too long;
- just make sure the test suites relevant to your changes pass on your local machine.
Expand Down
41 changes: 26 additions & 15 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@ The Scala CLI sources ship with Mill launchers, so that Mill itself doesn't need

#### Running the CLI from sources

Run the `scala` target with Mill:
```bash
./mill -i scala …arguments…
```

This is the equivalent of running the `cli` task with the default Scala version:
```bash
./mill -i 'cli[]'.run …arguments…
```

#### Debugging the CLI from sources

```bash
./mill -i debug debug-port …arguments…
```

which is short for:
```bash
./mill -i 'cli[]'.debug debug-port …arguments…
```
E.g:
```bash
./mill -i cli.debug 5050 ~/Main.scala -S 3.3.0
./mill -i 'cli[]'.debug 5050 ~/Main.scala -S 3.3.0
```

#### Run unit tests
Expand Down Expand Up @@ -129,7 +140,7 @@ Otherwise, some IDE features may not work correctly, i.e. the debugger might cra
#### Generate a native launcher

```bash
./mill -i show cli.nativeImage
./mill -i show 'cli[]'.nativeImage
```

This prints the path to the generated native image.
Expand All @@ -140,7 +151,7 @@ whether the files it points at exists or not.)
#### Generate a JVM launcher

```bash
./mill -i show cli.launcher
./mill -i show 'cli[]'.launcher
```

This prints the path to the generated launcher. This launcher is a JAR,
Expand All @@ -153,7 +164,7 @@ JVM one (see below).
#### Generate a standalone JVM launcher

```bash
./mill -i show cli.standaloneLauncher
./mill -i show 'cli[]'.standaloneLauncher
```

This prints the path to the generated launcher. This launcher is a JAR,
Expand Down Expand Up @@ -224,36 +235,36 @@ We have a built-in tool to validate `.md` files called [Sclicheck](/sclicheck/Re
All `Sclicheck` tests can be run with `Mill` + `munit`: (and this is what we run on the CI, too)

```bash
./mill -i docs-tests.test
./mill -i 'docs-tests[]'.test
```

The former also includes testing gifs and `Sclicheck` itself.
To just check the documents, run:

```bash
./mill -i docs-tests.test 'sclicheck.DocTests.*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.*'
```

You can also check all root docs, commands, reference docs, guides or cookbooks:

```bash
./mill -i docs-tests.test 'sclicheck.DocTests.root*'
./mill -i docs-tests.test 'sclicheck.DocTests.guide*'
./mill -i docs-tests.test 'sclicheck.DocTests.command*'
./mill -i docs-tests.test 'sclicheck.DocTests.cookbook*'
./mill -i docs-tests.test 'sclicheck.DocTests.reference*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.root*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.guide*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.command*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.cookbook*'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.reference*'
```

Similarly, you can check single files:

```bash
./mill -i docs-tests.test 'sclicheck.DocTests.<category> <doc-name>'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.<category> <doc-name>'
```

For example, to run the check on `compile.md`

```bash
./mill -i docs-tests.test 'sclicheck.DocTests.command compile'
./mill -i 'docs-tests[]'.test 'sclicheck.DocTests.command compile'
```

## Scala CLI logos
Expand Down Expand Up @@ -296,15 +307,15 @@ image.
To generate the relevant configuration automatically, you can run:

```bash
./mill -i cli.runWithAssistedConfig <scala-cli-sub-command> <args> <options>
./mill -i 'cli[]'.runWithAssistedConfig <scala-cli-sub-command> <args> <options>
```

Just make sure to run it exactly the same as the native image would have been run, as the configuration is generated for
a particular invocation path. The run has to succeed as well, as the configuration will only be fully generated after an
exit code 0.

```text
Config generated in out/cli/runWithAssistedConfig.dest/config
Config generated in out/cli/<scalaVersion>/runWithAssistedConfig.dest/config
```

As a result, you should get the path to the generated configuration file. It might contain some unnecessary entries, so
Expand Down
Loading

0 comments on commit f3369c2

Please sign in to comment.