Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions .github/workflows/native-image-wasm-spring-shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: native-image/wasm-spring-shell
on:
push:
paths:
- 'native-image/wasm-spring-shell/**'
- '.github/workflows/native-image-wasm-spring-shell.yml'
pull_request:
paths:
- 'native-image/wasm-spring-shell/**'
- '.github/workflows/native-image-wasm-spring-shell.yml'
schedule:
- cron: "0 0 1 * *" # run every month
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'native-image/wasm-spring-shell'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Download GraalVM 25.1 EA builds
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the graalvm/setup-graalvm action here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not yet unfortunately, because we don't have a file for 25.1 in here.

run: curl -sL -o $RUNNER_TEMP/graalvm-jdk-25e1-linux-amd64.tar.gz https://github.com/graalvm/oracle-graalvm-ea-builds/releases/download/jdk-25e1-25.0.0-ea.01/graalvm-jdk-25e1-25.0.0-ea.01_linux-x64_bin.tar.gz
- uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/graalvm-jdk-25e1-linux-amd64.tar.gz
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Set up Binaryen
run: |
curl -sLO https://github.com/WebAssembly/binaryen/releases/download/version_122/binaryen-version_122-x86_64-linux.tar.gz
tar xzf binaryen-version_122-x86_64-linux.tar.gz
echo "$(pwd)/binaryen-version_122/bin" >> "$GITHUB_PATH"
- name: Run 'native-image/wasm-spring-shell'
run: |
cd native-image/wasm-spring-shell
./mvnw --no-transfer-progress -Pnative native:compile
node target/wasm-spring-shell help
node target/wasm-spring-shell hello Jane
2 changes: 2 additions & 0 deletions native-image/wasm-spring-shell/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
33 changes: 33 additions & 0 deletions native-image/wasm-spring-shell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
27 changes: 27 additions & 0 deletions native-image/wasm-spring-shell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compile Spring Shell into a Wasm Module

This demo illustrates how to use GraalVM Web Image to compile a Spring Shell application into a Wasm module that can then run on the command-line or in the browser. [Check out the live demo here](https://graalvm.github.io/graalvm-demos/native-image/wasm-spring-shell/).

## Prerequisites

This demo requires:

1. This [Early Access Build](https://github.com/graalvm/oracle-graalvm-ea-builds/releases/tag/jdk-25e1-25.0.0-ea.01) of Oracle GraalVM 25.1 or later.
2. The [Binaryen toolchain](https://github.com/WebAssembly/binaryen) in version 119 or later and on the system path.
For example, using Homebrew: `brew install binaryen`

## Run Spring Shell on Node

1. Build the Wasm module with the `native` profile:
```bash
$ ./mvnw -Pnative package
```
The demo uses the [Native Build Tools](https://graalvm.github.io/native-build-tools/latest/index.html) for building native images with GraalVM and Maven.
This command generates a Wasm file and a corresponding JavaScript binding in the `target` directory.

2. Run the Wasm module on Node:
```bash
node target/wasm-spring-shell help
node target/wasm-spring-shell hello Jane
```
This requires Node.js 22 or later.
Loading