Skip to content

Commit

Permalink
Close #214 - Build with GraalVM - GitHub Actions to generate binary f…
Browse files Browse the repository at this point in the history
…or macOS, Linux and Windows
  • Loading branch information
kevin-lee committed Mar 18, 2021
1 parent c8d21d9 commit 7116000
Show file tree
Hide file tree
Showing 3 changed files with 796 additions and 6 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
branches:
- main

env:
CLI_SCALA_VERSION: "2.13.5"
CLI_SCALA_BINARY_VERSION: "2.13"

jobs:

build:
Expand Down Expand Up @@ -70,3 +74,116 @@ jobs:
echo "PR #${PR_NUMBER}"
java -version
.github/workflows/sbt-build-all.sh ${{ matrix.scala.version }} ${{ matrix.scala.report }}
graalvm_build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
gu-binary: [gu]
run-binary: [maven2sbt-cli]
exclude:
- os: ubuntu-latest
gu-binary: gu.cmd
- os: ubuntu-latest
run-binary: maven2sbt-cli.cmd
- os: macos-latest
gu-binary: gu.cmd
- os: macos-latest
run-binary: maven2sbt-cli.cmd
- os: windows-latest
gu-binary: gu
- os: windows-latest
run-binary: maven2sbt-cli
steps:
- name: Setup Graalvm
id: setup-graalvm
uses: DeLaGuardo/setup-graalvm@master
with:
# GraalVM version, no pattern syntax available atm
graalvm: '21.0.0.2'
# Java version, optional, defaults to 'java8'. Available options are 'java8' and 'java11'.
java: 'java11'
# Architecture flag, optional, defaults to 'amd64'. Available options are 'amd64' and 'aarch64'. Later is available only for linux runners.
arch: 'amd64'

- name: Install native-image component
run: |
${{ matrix.gu-binary }} install native-image
- uses: actions/checkout@v2
- name: Cache SBT
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-${{ env.CLI_SCALA_BINARY_VERSION }}-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }}
restore-keys: |
${{ runner.os }}-sbt-${{ env.CLI_SCALA_BINARY_VERSION }}-
- name: "GraalVM Build for Scala ${{ env.CLI_SCALA_VERSION }} - ${{ github.run_number }}"
env:
CURRENT_BRANCH_NAME: ${{ github.ref }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
run: |
./sbt -J-Xmx2048m "; ++${{ env.CLI_SCALA_VERSION }}! ; project cli; graalvm-native-image:packageBin"
ls -lGh cli/target/graalvm-native-image/
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} --version"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} --help"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} print --help"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} file --help"
graalvm_build_windows:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
gu-binary: [gu.cmd]
run-binary: [maven2sbt-cli.cmd]
steps:
- name: Setup Graalvm
id: setup-graalvm
uses: DeLaGuardo/setup-graalvm@master
with:
# GraalVM version, no pattern syntax available atm
graalvm: '21.0.0.2'
# Java version, optional, defaults to 'java8'. Available options are 'java8' and 'java11'.
java: 'java11'
# Architecture flag, optional, defaults to 'amd64'. Available options are 'amd64' and 'aarch64'. Later is available only for linux runners.
arch: 'amd64'

- name: Install native-image component
run: |
${{ matrix.gu-binary }} install native-image
- uses: actions/checkout@v2
- name: Cache SBT
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-${{ env.CLI_SCALA_BINARY_VERSION }}-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('**/build.properties') }}
restore-keys: |
${{ runner.os }}-sbt-${{ env.CLI_SCALA_BINARY_VERSION }}-
- name: "GraalVM Build for Scala ${{ env.CLI_SCALA_VERSION }} - ${{ github.run_number }}"
env:
CURRENT_BRANCH_NAME: ${{ github.ref }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
run: |
sbt -v '; project cli; graalvm-native-image:packageBin'
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} --version"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} --help"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} print --help"
sh -c "cli/target/graalvm-native-image/${{ matrix.run-binary }} file --help"
24 changes: 18 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,29 @@ lazy val cli = subProject("cli", file("cli"))
, packageDescription := "A tool to convert Maven pom.xml into sbt build.sbt"
, executableScriptName := ExecutableScriptName
, graalVMNativeImageOptions ++= Seq(
"-H:+ReportExceptionStackTraces",
"--initialize-at-build-time",
s"-H:ReflectionConfigurationFiles=${ (sourceDirectory.value / "graal" / "reflect-config.json").getCanonicalPath }",
"--verbose",
"--no-fallback",
"-H:+ReportExceptionStackTraces",
"--initialize-at-build-time",
s"-H:ReflectionConfigurationFiles=${ (sourceDirectory.value / "graal" / "reflect-config.json").getCanonicalPath }",
"--verbose",
"--no-fallback",
// "--report-unsupported-elements-at-runtime",
// "--allow-incomplete-classpath",
// "--initialize-at-build-time=scala.runtime.Statics",
// "--initialize-at-build-time=scala.Enumeration.populateNameMap",
// "--initialize-at-build-time=scala.Enumeration.getFields$1",
)
)
, graalVMNativeImageCommand := {
val os = System.getProperty("os.name")
println(
s"""########################
|# os: $os
|# JAVA_HOME: ${sys.env.get("JAVA_HOME")}
|# GRAALVM_HOME: ${sys.env.get("GRAALVM_HOME")}
|########################
|""".stripMargin)
graalVMNativeImageCommand.value
}

)
.settings(noPublish)
.dependsOn(core, pirate)
Expand Down
Loading

0 comments on commit 7116000

Please sign in to comment.