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

Create distributable cross-platform packages #329

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
177 changes: 101 additions & 76 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,118 @@ name: Release Artifacts
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build-jar:
name: Build Effekt compiler and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: "true"

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- uses: actions/checkout@v2
with:
submodules: 'true'

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Set up NodeJS
uses: actions/setup-node@v1
with:
node-version: '12.x'

- name: Install MLton
run: |
curl -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz --output mlton.tgz
tar -xzf mlton.tgz
mv mlton-20210117-1.amd64-linux-glibc2.31 $GITHUB_WORKSPACE/mlton
chmod +x $GITHUB_WORKSPACE/mlton/bin/mlton
echo "Trying to call directly"
$GITHUB_WORKSPACE/mlton/bin/mlton
echo "Adding mlton to path"
echo "$GITHUB_WORKSPACE/mlton/bin" >> $GITHUB_PATH

- name: Install Chez Scheme
run: sudo apt-get install chezscheme

- name: Run tests and assemble jar file
run: sbt clean deploy

- id: npmpackage
name: Generate npm package
run: mv $(npm pack) effekt.tgz

- name: Upload Effekt binary
uses: actions/upload-artifact@v1
with:
name: effekt
path: bin/effekt

- name: Upload the npm package
uses: actions/upload-artifact@v1
with:
name: effekt-npm-package
path: effekt.tgz
- name: Set up NodeJS
uses: actions/setup-node@v1
with:
node-version: "12.x"

- name: Install MLton
run: |
curl -L https://github.com/MLton/mlton/releases/download/on-20210117-release/mlton-20210117-1.amd64-linux-glibc2.31.tgz --output mlton.tgz
tar -xzf mlton.tgz
mv mlton-20210117-1.amd64-linux-glibc2.31 $GITHUB_WORKSPACE/mlton
chmod +x $GITHUB_WORKSPACE/mlton/bin/mlton
echo "Trying to call directly"
$GITHUB_WORKSPACE/mlton/bin/mlton
echo "Adding mlton to path"
echo "$GITHUB_WORKSPACE/mlton/bin" >> $GITHUB_PATH

- name: Install Chez Scheme
run: sudo apt-get install chezscheme

- name: Run tests and assemble jar file
run: sbt clean deploy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiribenes just told me MacOS minutes are much more expensive. Maybe we don't want to run the tests on all systems??? :)


- id: npmpackage
name: Generate npm package
run: mv $(npm pack) effekt.tgz

- name: Upload the npm package
uses: actions/upload-artifact@v1
with:
name: effekt-npm-package
path: effekt.tgz

build-native:
name: Build native image
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, ubuntu-latest, windows-latest]
include:
- os: macos-13
uploaded_filename: effekt-arm64-apple-darwin
local_path: effekt/jvm/target/native-image/effekt
- os: ubuntu-latest
uploaded_filename: effekt-x86_64-pc-linux
local_path: effekt/jvm/target/native-image/effekt
- os: windows-latest
uploaded_filename: effekt-x86_64-pc-win32.exe
local_path: effekt\jvm\target\native-image\effekt.exe
steps:
- uses: actions/checkout@v2
with:
submodules: "true"

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Set up NodeJS
uses: actions/setup-node@v1
with:
node-version: "12.x"

- name: Run tests and build native image
run: sbt clean effektJVM/native-image

- name: Upload Effekt native image
uses: actions/upload-artifact@v2
with:
path: ${{ matrix.local_path }}
name: ${{ matrix.uploaded_filename }}

release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-jar]
needs: [build-jar, build-native]
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Download JAR artifact
- name: Download native binary windows artifact
uses: actions/download-artifact@v1
with:
name: effekt
name: effekt-x86_64-pc-win32.exe
path: distribution/

- name: Download native binary macos artifact
uses: actions/download-artifact@v1
with:
name: effekt-arm64-apple-darwin
path: distribution/

- name: Download native binary linux artifact
uses: actions/download-artifact@v1
with:
name: effekt-x86_64-pc-linux
path: distribution/

- name: Download npm package
Expand All @@ -78,36 +124,15 @@ jobs:
name: effekt-npm-package
path: distribution/

- name: Create Release
id: create_release
uses: actions/create-release@latest
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: Prerelease ${{ github.ref }}
name: Prerelease ${{ github.ref }}
tag_name: ${{ github.ref }}
body: Automatic release for ${{ github.ref }}
files: |
distribution/*
draft: false
prerelease: true

- name: Upload jar file
id: upload_jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./distribution/effekt
asset_name: effekt.jar
asset_content_type: application/java-archive

- name: Upload npm package
id: upload_npm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./distribution/effekt.tgz
asset_name: effekt.tgz
asset_content_type: application/gzip
24 changes: 11 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
)
.settings(commonSettings)
.dependsOn(kiama)
// .enablePlugins(NativeImagePlugin)
.enablePlugins(NativeImagePlugin)
.jvmSettings(
libraryDependencies ++= (replDependencies ++ lspDependencies ++ testingDependencies),

Expand All @@ -96,19 +96,18 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
// disable tests for assembly to speed up build
assembly / test := {},


// Options to compile Effekt with native-image
// -------------------------------------------
marvinborner marked this conversation as resolved.
Show resolved Hide resolved
// nativeImageOptions ++= Seq(
// "--no-fallback",
// "--initialize-at-build-time",
// "--report-unsupported-elements-at-runtime",
// "-H:+ReportExceptionStackTraces",
// "-H:IncludeResourceBundles=jline.console.completer.CandidateListCompletionHandler",
// "-H:ReflectionConfigurationFiles=../../native-image/reflect-config.json",
// "-H:DynamicProxyConfigurationFiles=../../native-image/dynamic-proxies.json"
// ),

nativeImageVersion := "22.3.0",
nativeImageOptions ++= Seq(
"--no-fallback",
"--initialize-at-build-time",
"--report-unsupported-elements-at-runtime",
"-H:DynamicProxyConfigurationFiles=../../native-image/dynamic-proxies.json",
"-H:ReflectionConfigurationFiles=../../native-image/reflect-config.json",
"-H:+ReportExceptionStackTraces",
"-H:IncludeResourceBundles=jline.console.completer.CandidateListCompletionHandler",
),

// Assembling one big jar-file and packaging it
// --------------------------------------------
Expand Down Expand Up @@ -188,7 +187,6 @@ lazy val effekt: CrossProject = crossProject(JSPlatform, JVMPlatform).in(file("e
Compile / sourceGenerators += stdLibGenerator.taskValue
)


lazy val platform = Def.task {
val platformString = System.getProperty("os.name").toLowerCase
if (platformString.contains("win")) "windows"
Expand Down
38 changes: 27 additions & 11 deletions effekt/jvm/native-image/reflect-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
},
{
"name":"kiama.util.SetTraceNotificationParams",
"allDeclaredFields":true
"allDeclaredFields":true,
"allPublicConstructors":true
},
{
"name":"org.eclipse.lsp4j.CallHierarchyCapabilities",
Expand All @@ -50,6 +51,11 @@
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.ClientInfo",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.CodeAction",
"allDeclaredFields":true,
Expand Down Expand Up @@ -221,6 +227,12 @@
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.DocumentFormattingParams",
"allDeclaredMethods":true,
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.DocumentHighlightCapabilities",
"allDeclaredFields":true,
Expand Down Expand Up @@ -273,6 +285,11 @@
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.ExecuteCommandParams",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.FoldingRangeCapabilities",
"allDeclaredFields":true,
Expand All @@ -288,6 +305,11 @@
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.FormattingOptions",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.HoverCapabilities",
"allDeclaredFields":true,
Expand Down Expand Up @@ -420,16 +442,6 @@
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.SemanticHighlightingCapabilities",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.SemanticHighlightingServerCapabilities",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"org.eclipse.lsp4j.ServerCapabilities",
"allDeclaredFields":true,
Expand Down Expand Up @@ -616,5 +628,9 @@
"name":"sun.misc.Unsafe",
"allDeclaredFields":true,
"methods":[{"name":"allocateInstance","parameterTypes":["java.lang.Class"] }]
},
{
"name":"jline.UnixTerminal",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
]
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")

// to have separate projects for jvm and js details
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")

// build native images using GraalVM
// addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.1.2")
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.4")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

Expand Down
Loading